Microsoft | Video Call | Cousin in a binary Tree

Anonymous User
505
Dec 31, 2023
Jan 02, 2024

YOE - 8 years
Applied online on Microsoft website

Question:
Given a Binary Tree and a Node in the input, print all the Cousin nodes of that node

Example:

			  1
		2           3
     4     5     6     7	

Input node is 5, then the output should print the nodes 6 and 7 only

Definition of cousin
cousin are all the nodes that share the same grand parent, not all the Nodes at that level in the tree

Comments (5)