Binary trees Interview Questions | Glassdoor

Binary trees Interview Questions


interview questions shared by candidates

Binary trees Interview Questions

Sort: RelevancePopular Date

Find the deepest common ancestor of two nodes in a tree structure.

13 Answers

This interview was frustrating because it felt like the woman couldn't write code in C++. I first asked whether I could assume a standard Tree node structure (as I've built several custom structures and they all have many of the same basic components) and she was pretty much dumbstruck and told me ti write the implementation for one. So i did. Then I started walking through my solution and practically had to spell the word iterator when I said I declared one. My solution was basically to just descend in the tree toward the first value until the two values are on different sides of the current node or you fall out the bottom of the tree. I had to repeat the conditional statements character by character for the interviewer.

Isn't the root node always the "deepest" common ancestor? Either the question is worded wrong, or you answered it incorrectly, but I think it's most likely that it's worded wrong.

@mliu the question is correct. u r thinking wrong. depth of a tree grows towards its leaves. root is the least deep node in a tree.

Find the minimum depth of binary search tree

10 Answers

Write a function that takes 2 arguments: a binary tree and an integer n, it should return the n-th element in the inorder traversal of the binary tree.

7 Answers

Define binary search tree. Develop a procedure to verify a binary search tree.

6 Answers

First explain what a tree, then binary tree, then a binary search tree is. Now implement a function that verifies whether a binary tree is a valid binary search tree.

5 Answers

find lowest common ancestor of 2 nodes in a binary tree

3 Answers

Find the height of a binary tree

3 Answers

Given a binary tree, convert it into a doubly circular linked list. The structure of the tree was given by the interviewer and also the structure of the doubly circular linked list.

2 Answers

print out binary tree's nodes in certain layout (it was in order traversal)

1 Answer

using recursion to traverse a binary tree

1 Answer
110 of 21 Interview Questions