Google Interview Question for Software Engineer / Developers


Country: United States




Comment hidden because of low score. Click to expand.
5
of 5 vote

First of all its not from Google.

The left most node of BST is minimum.

Node* findMin(Node* n)
{
	if(n==NULL) return NULL; // tree is empty
	while(n->left != NULL)
		n=n->left;

	return n;
}

- Abhi October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

y -1??

- Abhi October 05, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

+1

- S O U N D W A V E October 05, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

if 0.5 is the left child of 3 then it does not satisy BST property as root of the tree 2 is greater than 0.5.

correct me if I am wrong

- not a geek October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

The case you use is not a BST.

- IdleMind October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

if( node == nil) return nil;    // empty tree, no minimum
while( 1 )  {
    if(node.left == nil) return node; //has no left child, so we are at min.
    node = node.left;        //has left child, so min. is recursively in left tree
}

- S O U N D W A V E October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 4 vote

Can you mark these without company name? Because you are just practicing, this is not from a Google interview.

- S O U N D W A V E October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void MinValue(struct binraytree *b, struct binarytree **result) //result is initialized to NULL 
{
if(b)
{
  if(*result==NULL || (b->data < (*result)->data))
      *result=b;
  MinValue(b->lc,result);
  MinValue(b->rc,result);
}
}

- Anonymous October 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

algorithm minBST(node<root pointer>)
{
if(node.left == null)
return node
else
minBST(node.left)
}

- Harshit Loharuka October 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

crash on empty tree

- Kenneth October 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

check if(node==NULL)
#Please_don't_quote_me_as_captain_obvious :P

- Nimish November 23, 2013 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More