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

Category: QuestionsDoes there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.
Editor">Editor Staff asked 5 months ago

Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.
 
(a) Yes
 
(b) No
 
Question is taken from Weak Heap in chapter Heap of Data Structures & Algorithms I
 
I got this question by my college director while I was bunking the class.

1 Answers
Editor">Editor Staff answered 5 months ago

Right answer is (b) No
 
Best 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.


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702