Google Interview Question for Software Engineer / Developers


Country: United States




Comment hidden because of low score. Click to expand.
8
of 12 vote

BTrees? Or Binary Trees? They are different...

Even if you meant Binary Trees, wtf is the question? Makes no sense.

- Anonymous November 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 5 vote

bool check(node* r1, node* r2){
	if(!r1 && !r2) return true;
	if(!r1 || !r2) return false;
	if(r1->data != r2->data) return false;
	bool b = check(r1->left, r2->left) && check(r1->right, r2->right);
	if(b) return true;
	return check(r1->left, r2->right) && check(r1->right, r2->left);
}

- Anonymous November 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 3 votes

LOL. IDIOTS.

- Anonymous November 03, 2013 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

i had a worse and longer code than above but i deleted it after downvoting on my codes

- algos November 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Last 3 lines could be grouped with a lazy OR operator.

- Stéphane January 04, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

bool isIsomorphic(tree t, tree s) 
{
	return  isSame(t,s) || isMirror(t,s);
}

- Mohit the genius Verma - check my stupid website topicquestions.com November 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Wrong.

- Anonymous November 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is nothing like left and right in a BTree. The number of branches from a node depend on the order of the tree.

- teli.vaibhav November 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Search for tree-isomorphism-problem in geekforgeeks . org.
I guess that is what you are looking for.

- Anonymous November 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This question is from glassdoor where someone said it was asked in the on-site interview rounds. It is a very vague description.

- Anonymous November 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The below answer is for lookup for a BT in a list of millions of BT.

We can do it in O(1) time, but it requires preprocessing.
1) Create a string hash for each tree
2) Remember to separate the node values using some separator. for example use left brace & right brace. Also remember to maintain the some sorted order of child's values (either asc, or desc)
3) Insert into a HashMap<String, Tree> map;


During lookup operation, convert the input tree into string (as mentioned in step 2), and look for it in the map.
Complexity:
HashMap addition is O(1) - Amortized.
HashMap lookup is O(1) - Amortized.

- sathishp123 November 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

jbkjmb kj

- Anonymous November 29, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a

- a April 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

gthg

- a April 04, 2015 | Flag Reply


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