Computer Science EngineeringVery hard
The max-heap [90, 80, 70, 60, 50] stored in an array has the key 85 inserted with the standard sift-up. The resulting array is
- A. 90 85 70 60 50 80
- B. 90 85 80 60 50 70
- C. 90 80 85 60 50 70
- D. 85 90 80 60 50 70
Correct answer: C. 90 80 85 60 50 70
85 is placed at index 6, is larger than its parent 70 so they swap, and then it stays below 90.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The minimum number of comparisons needed to find both the largest and second-largest of 16 distinct elements (tournament method) is
- Which data structure follows the Last-In-First-Out principle?
- The height (in edges) of a complete binary tree having n nodes is
- The time needed to build a binary heap from n arbitrary elements using bottom-up heapify is
- The maximum number of nodes in a binary tree of height h (root at height 0) is
- The recurrence T(n) = 2T(n/2) + n log n solves to