Question 41
MediumA binary tree has 20 leaves, and every internal node has exactly two children. How many nodes are there?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
A binary tree has 20 leaves, and every internal node has exactly two children. How many nodes are there?
21
39
19
40
Sign up free to see the answer and a step-by-step explanation.
Inorder: D B E A F C. Preorder: A B D E C F. What is the postorder?
D B E F C A
E D B F C A
D E B F C A
D E B C F A
Sign up free to see the answer and a step-by-step explanation.
How many null (empty) child pointers does a binary tree with n nodes have?
n − 1
n
2n
n + 1
Sign up free to see the answer and a step-by-step explanation.
In a complete binary tree stored in an array from index 1, where are the children of node i?
2i and 2i + 1
2i − 1 and 2i
i + 1 and i + 2
i/2 and i/2 + 1
Sign up free to see the answer and a step-by-step explanation.
Which traversal is used to delete (free) all nodes of a tree safely?
Inorder
Postorder
Level order from the root
Preorder
Sign up free to see the answer and a step-by-step explanation.
Which traversal is used to copy a tree, creating each node before its children?
Reverse inorder
Postorder
Preorder
Inorder
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of any standard traversal of a binary tree with n nodes?
O(n log n)
O(log n)
O(n)
O(n²)
Sign up free to see the answer and a step-by-step explanation.
What extra space does recursive inorder traversal use for a skewed tree of n nodes?
O(1)
O(n)
O(n²)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
Which traversal uses O(1) extra space by temporarily changing null pointers?
Recursive preorder
Morris traversal
Iterative DFS with a stack
Level-order traversal
Sign up free to see the answer and a step-by-step explanation.
Which pair of traversals does NOT uniquely determine a general binary tree?
Inorder and preorder
Inorder and postorder
Preorder and postorder
Inorder and level order
Sign up free to see the answer and a step-by-step explanation.