Heap Sort in C

Google Advertisements

Prev Tutorial Next Tutorial

Heap Sort Program in C

Heap Sort technique is based on binary tree. Heap Sort is very fast data sorting technique and it is widely used for sorting. Heap sort algorithm is divided into two basic parts

heap sort
  • Creating a Heap of the unsorted list.
  • Then a sorted array is created by repeatedly removing the largest/smallest element from the heap, and inserting it into the array. The heap is reorganize after each removal.

What is heap

Heap is a special tree-based data structure. Heap sort is based on binary tree concept. Binary tree have mainly two property

  • Shape Property
  • Heap Property

Shape Property

binary tree

Heap sort data structure is always a Complete Binary Tree. In case of Complete binary tree all levels of the tree are fully filled.

Shape Property

binary tree

In binary tree value of each node is either (greater than or equal to) or (less than or equal to) of the parent node. If the parent or father nodes are greater than their children node then this type of heap is called a Max-Heap, and if the parent nodes are smaller than their child nodes then this type of heap is called Min-Heap.

Heap Sort Working

First receive un-sorted list and create a Heap data structure(Max-Heap or Min-Heap). Now you can put the first element of the heap in your array ( the first element of the Heap is either largest or smallest(depending upon Max-Heap or Min-Heap)). Again make heap using remaining list data. pick first element and put this into array. This process is repeated until list complete sorted.

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs