Topic — Add New » Posts Last Poster Freshness
Balanced BST 2 kartik 1 month

Covert a doubly linked list to a balanced binary search tree

Vertical of a tree 1 k53 1 month

Given a binary tree, print the elements of the same verticals in a single line

Tree to DLL 1 k53 1 month

Given a binary tree, convert it into a doubly linked list which should contain the elements of tree in a zig-zag manner

Least Common Ancestor of k nodes 1 k53 1 month

Given a binary tree and an array of 'k' nodes of the tree, find the least common ancestor for all 'k' nodes

Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees 2 aksiith 2 months

Find the median of a Binary Search Tree. You are passed the root of the tree, and you should return the median which is the middle element, if the number of elements is odd, or the average of the two middle elements if the number of elements is even.

Microsoft
Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees 4 Aashish Barnwal 2 months

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
Adobe Interview Question 2 Abhimanyu Vohra 2 months

Convert Sorted Array to Balanced Binary Search Tree (BST)

i tried but it not giving correct o/p

for example u can take the array 12345 sorted...so can anybody help me in this

BinaryTree* sortedArrayToBST(int arr[], int start, int end) {
if (start > end) return NULL;
// same as (start+end)/2, avoids overflow.
int mid = start + (end - start) / 2;
BinaryTree *node = new BinaryTree(arr[mid]);
node->left = sortedArrayToBST(arr, s...

Adobe
Adobe Interview Question for Software Engineer/Developer (Fresher) about Algorithms, Aptitiude, C++, 4 5050 2 months

Given 2 trees A and B find if tree B is a subtree of Tree A or not. Provide the most optimized solution that you can think of.

Adobe
n-ary tree 2 freakCoder 2 months

How to search an element in an n-ary tree without using recursion ?

[closed] Amazon Interview Question for Software Engineer/Developer about Trees 7 geeksforgeeks 2 months

Find vertical sum of given binary tree.

Example:

      1
    /    \
  2        3
 / \      / \
4   5   6   7

The tree has 5 vertical lines

Vertical-1: nodes-4 => vertical sum is 4
Vertical-2: nodes-2 => vertical sum is 2
Vertical-3: nodes-1,5,6 => vertical sum is 1+5+6 = 12
Vertical-4: nodes-3 => vertical sum is 3
Vertical-5: nodes-7 => vertical sum is 7

We need to output: 4 2 12 3 7

Amazon
Amazon Interview Question for Software Engineer/Developer about Trees 4 camster 2 months

Given two nodes of a BST and all elements in BST are distinct, write code to determine the shortest distance between the two nodes. (unit distance between two adjacent nodes). Nodes dont have parent pointer.

Amazon
Adobe Interview Question for Software Engineer/Developer about Trees 4 camster 2 months

Merge two binary search trees.

Adobe
insert node in BST 4 kartik 3 months

A 'C' program to perform a insertion operation in a Binary Search Tree.

[closed] trees 5 kartik 3 months

given a binary tree where each node has positive and negative values, at each node store the sum of the left
and right sub trees.
ex:
10
-2 6
8 -4 7 5

output:
20(4-2+12+6)
...

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

Do Postorder traversal without using recursion.

Amazon
Amazon Interview Question for Software Engineer/Developer (0 - 2 Years) 4 nagesforyou 3 months

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
Amazon Interview Question for Software Engineer/Developer (Fresher) about Trees 6 3 months

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