Trees and Graphs Interview Questions
- 0of 0 votes
AnswersAlgo to check if given binary tree is binary search tree or not. Code it and return true or false. Also it should find the number of nodes in the tree irrespective if the tree is BST or not.
- AnonymousUser March 28, 2010| Report Duplicate | Flag | PURGE
Amazon Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersFind diameter of tree. Code it
- AnonymousUser March 28, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersMirror a binary tree
- Anonymous March 03, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersTake a tree (binary or otherwise), write a method in any language that, when given the root node, will print out the tree in level order. With a new line after the end of every level.
- Jason Jiang February 25, 2010
Helper methods are ok, big O run time efficiency doesn't matter (though obviously a quicker solution is better). Do not destroy original tree.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Trees and Graphs - 0of 0 votes
Answersimplement the pre-order traversal of a tree.
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersCheck whether a binary tree is BST(if the binary tree is very large, you can not simply in-order print all the nodes out.)
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersCalculate the Depth of Binary Tree
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersWrite code to get the mirror image of a tree ( the same tree needs to be modified to get its mirror image)
- Emma January 18, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Trees and Graphs - 0of 0 votes
AnswersGiven a BST and sum,find minimum node from root to leaf till u get the sum of node values equal to that sum.
- iiit hyd January 16, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Coding Trees and Graphs - 0of 0 votes
AnswersConvert a binary search tree to a sorted doubly linked list
- Anonymous December 20, 2009
inplace.| Report Duplicate | Flag | PURGE
Adobe Microsoft Software Engineer / Developer Data Structures Trees and Graphs - 0of 0 votes
AnswersGiven a Binary Tree(not a BST) find the maximum element.
- Vaishnavi December 04, 2009| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersBalance factor of a node in a binary=(number of all its descendants/level of node);
- t2 November 23, 2009
balance factor of tree=sum of BF of all nodes
Find the balance factor of a binary tree in most efficient way.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven a variation of a binary tree(not BST) in which each node has a parent, left and right pointer. The nodes do not have any key elements or any other data to identify itself. The root is the node that has a null parent pointer. You are given the pointers to two random nodes in the tree which may or may not be at the same level. Find the first common ancestor to the two random nodes given in the tree.
- Anonymous November 16, 2009| Report Duplicate | Flag | PURGE
Amazon Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven 2 nodes in a binary tree, find their lowest common ancestor.
- Hari November 14, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Trees and Graphs - 0of 0 votes
Answersfind LCA (lowest common ancestor) for non binary tree.
- Anonymous October 23, 2009| Report Duplicate | Flag | PURGE
Amazon Microsoft Software Engineer / Developer Algorithm Trees and Graphs - 0of 0 votes
AnswersHow to develop a sorted lexicographic tree.
- RKB October 17, 2009| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Trees and Graphs - -1of 1 vote
AnswersHow to implement tries to create a tree, and find the words as per the prefixes.
- RKB October 17, 2009| Report Duplicate | Flag | PURGE
Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGenerate a binary search tree from a continuous stream of numbers.
- Rohan October 08, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Trees and Graphs - 0of 0 votes
AnswersGiven a binary tree, write code to find if is a symmetric tree.. Extrapolate it to n-ary trees.
- SK October 01, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersHow can you think of a way to implement a stack using BST
- Anon September 12, 2009| Report Duplicate | Flag | PURGE
Amazon Trees and Graphs - 0of 0 votes
AnswersHow many binary tree can be formed if n number are given
- Arvind August 23, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersWrite a c program to search for an element in a binary tree[not BST] and if found return its level. root is labelled level 0 and children are one level incremented than its parent.
- technicalChaos July 21, 2009
if not found return -1| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven a binary tree with the following node structure
- Idea July 20, 2009
struct node
{
//data
//pointer to left subtree
//pointer to right subtree
//pointer to sibling
};
The sibling pointers are NULL for all the nodes.Make the sibling pointers point to their respective nodes in O(n)time complexity| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs Algorithm - 0of 0 votes
AnswersWrite code to print out a binary tree so that each depth is printed on its own line. The spacing doesn't need to be correct, but the items within a depth must be in order and on a single line.
- Han April 09, 2009
1
/ \
2 3
/ \
4 5
\
7
1
2 3
4 5
7| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Trees and Graphs - 0of 0 votes
AnswersWrite a function to find the longest path of a tree
- mp March 22, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs