Sorting is a need in the computational system including in big data analysis, database management systems, and real time applications. Heap sort is an efficient, comparison-based sorting algorithm that visualizes an array as a binary tree and transforms it into a heap data structure (usually a max heap for ascending sort). The algorithm repeatedly takes the largest element from the root of the heap, swaps it with the last element, and thus reduces the heap size until the heap is sorted The algorithm repeatedly takes the largest element from the root of the heap, swaps it with the last element, and thus reduces the heap size until the heap is sorted. The steps of this algorithm: a. Create Max Heap: Convert the input array into a Max Heap. b. Sort: Swap the root element (the largest element) with the last element, decrease the heap size by 1, and then convert the new root element into a heap. c. Repeat step 2 until the heap is empty. C++ is a known programming language. In this journal we use C++ programming to sort unsorted array. The code is presented in the details. One thorough step by step simulation is given in real data with heap sort and the program is run. The analysis is given by 7 data, namely: [13, 10, 30, 2, 6, 7, 9]. The result is a presented with sorted heap sort. With 7 datasets to be analysed, it is concluded that 6 swaps happened.
Copyrights © 2026