Topic — Add New » Posts Last Poster Freshness
Amazon Interview Question for Software Engineer/Developer about Algorithms 4 PsychoCoder 18 hours

Get the depth of a tree without using recursion

Amazon
Amazon Interview Question for Software Engineer/Developer (Fresher) about Trees 5 PsychoCoder 1 day

What is the complexity of an algorithm to check whether a binary tree is symmetric or not. No need to check the data only the structure needs to be verified.

Amazon
Amazon Interview Question for Software Engineer/Developer (0 - 2 Years) about Trees 3 PsychoCoder 2 days

Given a Binary Search Tree, write a function that returns the kth smallest element without using any static/global variable. You can’t pass the value k to any function also.

Amazon
Amazon Interview Question for Software Engineer/Developer about Trees 5 atul007 6 days

you have two BST , they contain the same amount of elements "N" but there structure is different. how will you cross check that the trees are identical with complexity O(N). Also how will you do the same in case its only Binary tree and not a Binary search tree.

Amazon
Amazon Hyderabad Interview Question 7 dheerajsharma1990 1 week

Reverse a binary search tree in such a manner so that parent child relationship maintained and left child become right child and vice versa.

Find the minimum and maximum element in stack in O(1).

given an array find the next minimum element in array for each element. for example if give array is 4,2,1,5,3 resultant array would be 2,1,-1,3,-1.

Given two string A and B . remove each character from string A which occur in B. if a occur 2 times in B remove 2 a from A.

...

Amazon Hyderabad Online Written 2 dheerajsharma1990 1 week

You are given a function isSumTree which takes in the root of a binary tree as it's parameter. Complete the function to return true if the given binary tree is a SumTree else false. A SumTree is a BinaryTree where the value of a node is equal to the sum of the nodes present in it's left subtree and the right subtree.

An empty tree is a SumTree and the sum of an empty tree can be considered as zero.A leaf node is also considered as SumTree

Amazon Banglore Online Written 4 kartik 1 week

You are given a function getInorderSuccessor which takes a BST (Binary Search Tree) as it's parameter. Every node has an extra pointer "next" , which is intialized to null, fill next with node pointers which represent Inorder Successor.

In a binary tree, inorder successor of a node is the next node in inorder traversal of the binary tree. Inorder successor is NULL for the last node in inorder traversal.

In BST, inorder successor of an input node can also be defined as the node w...

Minimum/Maximum Sum path in A Binary Tree 10 camster 1 week

Find and Print the Root to leaf path with minimum sum.Every node has a Integer value.No need to consider edge weight or no. of edges.Only 1 root-leaf path will be printed who has the minimum sum(i.e the sum of all nodes including the root and the leaf)

Amazon Interview Question for Software Engineer/Developer (0 - 2 Years) 3 PsychoCoder 2 weeks

Question 2 / 3
In a special type of Binary tree 2 conditions are followed:
All leaf nodes have value as the character 'L' and all the non-leaf nodes have the value as character 'N'.
Also, each node is has either 0 or 2 children.

The tree to the left is an example tree.
You are supposed to implement a function namely, constructTree. This function takes a string representing the pre-order traversal of the tree as an argument and returns the pointer to the root nod...

Amazon
Largest Binary Search Tree in a given Binary Tree 8 aayush kumar 2 weeks

Given a binary tree, find the largest binary SEARCH tree in this binary tree.

When I mean largest, the tree with maximum number of nodes. And the binary search tree should be a sub-tree in the given binary tree.

Note: Not every binary tree is a binary search tree

How to verify if given data structure represents Binary Tree 3 gaurav 2 weeks

Given the following data structure having nodes of the form :

struct node
{
     int data;
     node* link1;
     node* link2;
}

Given node* root , How will you determine if it represents a binary tree or not ?

Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees 3 2 weeks

write postorder non recursive traversal algorithm.

Microsoft
Binary Tree to BST 14 Abhi 2 weeks

convert a binary tree to binary search tree inplace. We cant use any extra space.

[closed] Convert a Sorterd Linked list in to a balanced Binary Search Tree 5 kartik 2 weeks

Given a Sorted Linked List.
Convert it in to any balanced Binary Search Tree.
Validate that the output is really a balanced tree.

Ex:
Input

1 --> 2 --> 3 --> 4--> 5 --> NULL

Output

                                        3
                                  /         \
                             1                 5
                               \              /
                                 2          4
Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees 3 Aashish Barnwal 3 weeks

2. Write a C program to convert a BST (Bin search tree) into DLL (Doubly Linked List) of increasing nodes values. The constraint is to write a recursive program, no other solution will be accepted.

Microsoft
Google Interview Question for Software Engineer/Developer (Fresher) 2 DAYADRU NAYAK 3 weeks

convert sorted doubly link list ->BST

Google
Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees 3 Dheeraj 3 weeks

You are given a binary tree where each node consists of a left pointer, a right pointer, and a sibling pointer. The left and right pointers are initially populated and the tree is a normal binary tree. He wanted a function to populate the sibling pointers such that they point to the node to the right of the current node in the tree, and which is on the same level. If there is no such node, the sibling pointer must be set to NULL. He again wanted an optimized solution, optimized for space.

Microsoft