Which of the following is an advantage of balanced binary search tree, like AVL tree, compared to binary heap?

Ngoc Hue

New member
Which of the following is an advantage of balanced binary search tree, like AVL tree, compared to binary heap?
A. insertion takes less time
B. deletion takes less time
C. searching takes less time
D. construction of the tree takes less time than binary heap
 
Answer: a
Explanation: Insertion and deletion, in both the binary heap and balanced binary search tree takes O(log n). But searching in balanced binary search tree requires O(log n) while binary heap takes O(n). Construction of balanced binary search tree takes O(nlog n) time while binary heap takes O(n).
 

Tìm kiếm

Back
Top