@Neha,

For your solution of 1, you needed to take m*n matrix into account.
Though i think your approach should work fine even in that case.
Function signature will change.

For 3rd solution, the corner cases actually little non-trivial while
writing code(need to consider root, root with no right subtree etc).
Logic is right.

For 2nd solution, the solution will work but you need not have
recursive calls printing a level, this way you are making calls for
all nodes along the way from root to given level. Using a queue is
better. Insert special flags when level changes.

On Aug 26, 4:50 pm, Neha Singh <neha.ndelhi.1...@gmail.com> wrote:
> For ques 2:
>
> ./*Function to print level order traversal of tree*/
> printLevelorder(tree)
> for d = 1 to height(tree)
>   {
>       printGivenLevel(tree, d);
>       printf(" %d\n",d);
>   }
>
> /*Function to print all nodes at a given level*/
> printGivenLevel(tree, level)
> if tree is NULL then return;
> if level is 1, then
>     print(tree->data);
> else if level greater than 1, then
>     printGivenLevel(tree->left, level-1);
>     printGivenLevel(tree->right, level-1);

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to