Question 11
EasyThe values 50, 30, 70, 20, 40 are inserted in that order into an empty binary search tree. What is its inorder traversal?
- 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
The values 50, 30, 70, 20, 40 are inserted in that order into an empty binary search tree. What is its inorder traversal?
20 40 30 70 50
50 30 20 40 70
20 30 40 50 70
50 30 70 20 40
Sign up free to see the answer and a step-by-step explanation.
The values 50, 30, 70, 20, 40 are inserted in that order into an empty binary search tree. Which nodes are visited when searching for 40?
50, 30, 40
50, 70, 40
40 only
20, 30, 40
Sign up free to see the answer and a step-by-step explanation.
What is the average time to search a balanced binary search tree of n nodes?
O(log n)
O(1)
O(n)
O(n log n)
Sign up free to see the answer and a step-by-step explanation.
The values 50, 30, 70, 20, 40 are inserted in that order into an empty binary search tree. What is the inorder successor of 30?
70
20
50
40
Sign up free to see the answer and a step-by-step explanation.
How is a leaf node deleted from a BST?
The whole tree is rebuilt
It is simply removed, and its parent's pointer set to null
It cannot be deleted
It is replaced by the root
Sign up free to see the answer and a step-by-step explanation.
How is a node with exactly one child deleted from a BST?
Its child takes its place
It is replaced by the root
It can't be deleted
Both it and its child are deleted
Sign up free to see the answer and a step-by-step explanation.
A tree has root 10 with left child 5 and right child 8. Is it a valid BST?
Yes
Only if 5 is a leaf
Only if 8 is a leaf
No, because 8 is in the right subtree but is smaller than 10
Sign up free to see the answer and a step-by-step explanation.
Roughly what is the height of a balanced BST with n nodes?
log₂ n
n/2
√n
n
Sign up free to see the answer and a step-by-step explanation.
What does AVL in 'AVL tree' stand for?
Automatic Value Lookup
Adelson-Velsky and Landis, its inventors
Array Value List
Average Value Level
Sign up free to see the answer and a step-by-step explanation.
Which balance factors are allowed for every node of an AVL tree?
Any value from −2 to +2
−1, 0 or +1
Only 0
Only positive values
Sign up free to see the answer and a step-by-step explanation.