## richa.cseit

BAN USER- 1of 1 vote

AnswersIn a Binary maze with 0 and 1, 0 is the valid cell to which we can travel and 1 means that the cell is blocked. Given source and destination. We have to find-

- richa.cseit in India

1. IF path exists, if yes, find shortest path.

2. If we are given a chance to toggle single cell from 1 to 0 , which cell you will toggle so that you will surely get the shortest path.| Report Duplicate | Flag | PURGE

Uber SDE-3 Algorithm - 0of 0 votes

Answers. 10

- richa.cseit

6 12

4 -> 5 <-------->11<-----> 13 <--

|_________________________________|

In the BST you have the leaf nodes connected to form a doubly LL. Given a node, identify its height| Report Duplicate | Flag | PURGE

Microsoft Software Engineer / Developer Data Structures

i think .. current ->left->right = current.. if it holds gud then the current will be leaf.

this only is sufficient.

x is value of the node whose hight, we need to know

root is the root of the BST

int level ( node * root, int x)

{

static int level = 0;

if ( root == NULL)

{

level = -1;

return level ; }

else if ( root->val == x)

{ level = 0;

return level ; }

if( roo->left)

{

if ( root->left->right == root)

level = -1;

else

level = (root->left)? level(root->left) ;

if(root->right)

{

if ( root->left->right == root)

level = -1;

else

level = level( root->right);

}

I think question is very clear.It was asked in MS interview when it visited our campus last yr.We find the hight of a BST.Now the variation is, if leafs of that tree are connected to each other.so that from one leaf, we can go to next leaf... so for such tree, find the height of the node

- richa.cseit December 18, 2009**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

i think .. current ->left->right = current.. if it holds gud then the current will be leaf.

- richa.cseit December 18, 2009this only is sufficient.

x is value of the node whose hight, we need to know

root is the root of the BST

int level ( node * root, int x)

{

static int level = 0;

if ( root == NULL)

{

level = -1;

return level ; }

else if ( root->val == x)

{ level = 0;

return level ; }

if( roo->left)

{

if ( root->left->right == root)

level = -1;

else

level = (root->left)? level(root->left) ;

if(root->right)

{

if ( root->left->right == root)

level = -1;

else

level = level( root->right);

}