Posting few questions which Playdom asked a friend of mine in telephonic
interviews. He had to write code in all cases.
1. Print m*n matrix in spiral form. Modify to make it iterative.
2. Print level order traversal or tree along with level information. Tree
need not be complete
a 1
b c
1.
int top,bottom,left,right,size;
void printTop(int arr[][size])
{
int i=top,j;
for(j=left;j=right;j++)
printf(%d ,arr[i][j]);
}
void printBottom(int arr[][size])
{
int i=bottom,j;
for(j=right;j=left;j--)
printf(%d ,arr[i][j]);
}
void printLeft(int arr[][size])
{
for ques 3:
]1) If right subtree of node is not NULL, then succ lies in right subtree.
Do following.
Go to right subtree and return the node with minimum key value in right
subtree.
2) If right sbtree of node is NULL, then succ is one of the ancestors. Do
following.
Travel up using the parent