Simple Heap Sort - Hackerrank Problem Solution
Simple Heap Sort
Hackerrank Problem Solution
PROBLEM STATEMENT
Heaps can be used in sorting an array. In max-heaps, maximum element will always be at the root. Heap Sort uses this property of heap to sort the array. You are given an array of integers in any order. Sort the elements of given array in ascending order using Heap sort.
Input Format
The first line contains an integer, n , the size of the array
The second line contains n space-separated integers a[i].
Constraints
2<=n<=600 1<=a[i]<=2*10^6
Output Format
First line prints the space separated initial heap elements (having all elements) Sorted Array in new line
Sample Input 0
5
1 2 3 4 5
Sample Output 0
5 4 3 1 2
1 2 3 4 5.
SOLUTION
SHARE
If you find this useful, please share with your friends and Community.
CODE TOGETHER..GROW TOGETHER.
CODE TOGETHER..GROW TOGETHER.
Newer Posts
Newer Posts
Older Posts
Older Posts
Comments