Heap Sort in C

Advertisements

Merge Sort in C Data Structure 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.


Merge Sort in C Data Structure Tutorial in C

Google Advertisment

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

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

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements