Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.

Đạt Michio

New member
Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.
A. Yes
B. No
 
Answer: B
Explanation: No, The inorder traversal will not give elements in sorted order. As heap is implemented as either min-heap or max-heap, the root will be have highest or lowest value than remaining values of the nodes. So this traversal will not give a sorted list.
 

Tìm kiếm

Back
Top