Data Structures · Question 26 · Medium

Data Structures question 26

An array-based binary min-heap holds [2, 5, 3, 9, 6, 4, 8]. One deleteMin operation is performed (the last element moves to the root and then sifts down). What is the resulting array?

  1. [8, 5, 3, 9, 6, 4]
  2. [3, 5, 8, 9, 6, 4]
  3. [3, 4, 5, 9, 6, 8]
  4. [3, 5, 4, 9, 6, 8]
Answer and explanation

Answer: D. [3, 5, 4, 9, 6, 8]

Explanation: Removing 2 puts 8 at the root: [8, 5, 3, 9, 6, 4]. 8 swaps with the smaller child 3, giving [3, 5, 8, 9, 6, 4], then with its child 4, giving [3, 5, 4, 9, 6, 8].

Previous: In a doubly linked list, you are given a pointer to a node (not the head or… · Next: A binary tree has preorder traversal A B D E H C F G and inorder traversal D B…

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge