Microsoft | Video Call | Cousin in a binary Tree
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2023-12-31Added By Anonymous
Source: Link
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 1
2 2 3
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