Trees and Graphs Interview Questions
- 0of 0 votes
AnswersFind the distance of a node from the root in a binary tree.Print error message if node doesn't exist.
- Sneha Sharma June 07, 2011
Extend the problem to distance of any node to any other node that is below it.| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven a two balanced binary search trees.Merge both the trees so that it will form again a balanced binary search tree.
- kumar June 01, 2011 in -
(NOTE: Request for correction: should the input bst s have same number of nodes? if the input bst s have unequal nodes, we cant necessarily build a balanced bst for the result )| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersWrite code to calculate forward, reverse and cross edges of a given graph
- A May 16, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersWrite insert function for a binary search tree?
- SAN April 18, 2011
Given constraint:
1. The insertion should be such that the tree remains balanced.
2. You can move the any non-leaf/root node to be a leaf/non-root node.
At the end of inserting any random insertion the tree should be BST and balanced. he gave the sample data as {1,2,3,4,5,6,7,8}| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersQuestion 3: Asked to print the path of the tree in zig-zag fashion
- Sksharsha April 08, 2011| Report Duplicate | Flag | PURGE
Motorola Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersWrite a program to reverse pointers of a binary tree?
- Anonymous February 23, 2011
Means to reverse all the pointers like at the beginning root points to children..The function should reverse pointers such that children point to root...
I hope I am clear...| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
Answerwap to get the height of a BST?
- bk February 07, 2011| Report Duplicate | Flag | PURGE
One97 Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersA special type of tree is given, Where all leaf are marked with L and others are marked with N. every node can have 0 or at most 2 nodes. Trees preorder traversal is given give a algorithm to build tree from this traversal.
- mail2maulish January 10, 2011| Report Duplicate | Flag | PURGE
Amazon Trees and Graphs - 0of 0 votes
AnswersImplement the following Interface with a Tree implementation of a Map.
- Anonymous October 27, 2010
public interface Map<K extends Comparable, V> {
public void put(K key, V value);
public V get(K key);
public int size();
}| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersImplement count Non-leaf nodes on a binary tree.
- Cartman October 19, 2010| Report Duplicate | Flag | PURGE
Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersFollowing is a tree
- Kyon Bataoon October 14, 2010
A
/ \
B C
/ \ / \
D E F G
/\ /
H I J
You need to print
A CB DEFG JIH
Modified LEVEL order traversal| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersToday i had a interview with amazon , the question asked was for a n-tree where each node contains any no of nodes print the nodes in level order and each level must contain a line with a gap
- KK September 04, 2010| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Trees and Graphs - 0of 0 votes
AnswersPrint elements that are in a vertical column (per column) in a Binary tree
- AmazonPersonalRound July 30, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersDesign a format that describes the pathways you can traverse in the game Zelda.
- Brian July 29, 2010| Report Duplicate | Flag | PURGE
Zillow Solutions Architect Trees and Graphs - 0of 0 votes
Answersfind maximum length BST in a given binary tree.
- ajay July 27, 2010| Report Duplicate | Flag | PURGE
Deshaw Inc Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven a root and a node of a binary tree, write a function which finds all the nodes which are a 'k' distance from the given nodes. (distance can be upwards and downwards)
- Loony June 30, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding Trees and Graphs - 0of 0 votes
Answershow will you find a maximum path in a graph
- someone June 28, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersThere is a parking lot of cars that is full except for a single spot. Write some code to take it from one arbitrary configuration to another moving only one car at a time into the empty spot. Analyse the time complexity, how would you improve it, etc.
- jobseeker June 20, 2010| Report Duplicate | Flag | PURGE
Google Trees and Graphs - 0of 0 votes
AnswersWrite a program to find the mirror image of a n-ary tree
- Anonymous June 07, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Trees and Graphs - 0of 0 votes
AnswersGiven a binary tree print the nodes in this order:
all the left most nodes from top to bottom, then all the leaves, then all the right most nodes from bottom to top, then the root. like10 5 15 3 2 12 17
you would print 5 3 2 12 17 15 10
- Manox May 25, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Trees and Graphs - 0of 0 votes
Answersalgorithm - given binary tree, check if it has any 2 leaf nodes which differ by more than 1 level (write code for this)
- Mr. XYZ May 10, 2010| Report Duplicate | Flag | PURGE
Microsoft Program Manager Trees and Graphs - 0of 0 votes
AnswersHeight of a BInary tree.
- Anonymous April 12, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersGiven a log file which has customer id and corresponding to that id it has a page id visited by that customer. Given such log files for 3 consecutive days, design an algo to find those customers which visited the site on exactly 2 out of 3 days and visited at least 3 distinct pages. Discuss the design and space complexity. Optimize (question is not about using unix tricks)
- AnonymousUser March 28, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs