1.

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

Answer»

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.



Discussion

No Comment Found

Related InterviewSolutions