Computer Science EngineeringVery hard
The array [4, 10, 3, 5, 1] is converted into a max-heap by the standard bottom-up build-heap procedure. The resulting array is
- A. 10 5 3 4 1
- B. 10 4 3 5 1
- C. 10 5 3 1 4
- D. 5 10 3 4 1
Correct answer: A. 10 5 3 4 1
Node 10 is already fine; sifting 4 down swaps it with 10 and then with 5, giving 10 5 3 4 1.
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
- A binary tree has exactly 15 nodes with two children. How many leaves does it have?
- The auxiliary space used by a recursive DFS on a graph with V vertices, in the worst case, is
- What does f(37) return for int f(int n){ if(n==0) return 0; return f(n/2) + (n%2); }
- How many structurally distinct binary trees exist with 5 nodes?
- Which of the following algorithms can detect a negative-weight cycle reachable from the source?
- The worst-case running time of the Rabin-Karp string matching algorithm (text length n, pattern length m) is