Trace first pass of heap sort

Quick Overview

This question evaluates understanding of heap sort and heap operations, specifically max-heap construction, root extraction, and subsequent heapify steps during an in-place array sort.

Trace first pass of heap sort

Company: Bitkernel

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Online Assessment

Given the integer array `[7, 6, 3, 5, 4, 1, 2]`, you apply heap sort to sort it in ascending order using a max-heap implementation. After building the initial max-heap and performing the first extraction step (swap the root with the last element and then heapify the remaining elements), what is the resulting order of the array? Options: - A. `1-2-3-4-5-6-7` - B. `2-6-3-5-4-1-7` - C. `6-5-3-2-4-1-7` - D. `5-4-3-2-1-6-7`

Quick Answer: This question evaluates understanding of heap sort and heap operations, specifically max-heap construction, root extraction, and subsequent heapify steps during an in-place array sort.

|Home/Software Engineering Fundamentals/Bitkernel
Bitkernel logo
Bitkernel
Oct 24, 2025
mediumSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
3
0

Given the integer array [7, 6, 3, 5, 4, 1, 2], you apply heap sort to sort it in ascending order using a max-heap implementation.

After building the initial max-heap and performing the first extraction step (swap the root with the last element and then heapify the remaining elements), what is the resulting order of the array?

Options:

  • A. 1-2-3-4-5-6-7
  • B. 2-6-3-5-4-1-7
  • C. 6-5-3-2-4-1-7
  • D. 5-4-3-2-1-6-7
Loading comments...