Heap Sort Problem Statement

Your task is to sort an array of integers in non-decreasing order using the Heap Sort algorithm.

Input:

The first line contains an integer 'T' denoting the number of test cases.
Each test case consists of two lines:
- The first line contains a single integer 'N', the number of elements in the array.
- The second line contains 'N' space-separated integers, the elements of the array.

Output:

For each test case, output 'N' space-separated integers sorted in non-decreasing order.
Each test case's output should be on a separate line.

Example:

Input:

2
4
4 10 3 5
3
9 7 6

Output:

3 4 5 10
6 7 9

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 105
  • -109 <= ARR[i] <= 109

Note:

Implement the function; you do not need to handle any printing as it has been managed externally.
Be the first one to answer
Add answer anonymously...
RadiSys Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter