Microsoft Interview Question for SDE-2s
- 0of 2 votes
Given a binary tree, connect all node in the same level in toggle manner.- neer.1304 November 27, 2015 in United States
Toggle the linking every K level. For first K level, you should link to next right node. Next K you should link to next left and so on.
Node structure is :
struct node *left, *right, *next;
Each level next should point to the next right or left node in the level. For last node in each level, next should be NULL
For ex - if K=2 then for first 2 level of tree connect next pointer from left to right and for next 2 levels connect next pointer from right to left and so on.
| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm
Open Chat in New Window