Showing posts with label heap sorting example. Show all posts
Showing posts with label heap sorting example. Show all posts

9.12.2012

Heap Sorting method and algorithm

In heap sorting process:

First of all organizing the whole data to be sorted as a binary tree i.e. heap. And after that impletment heap sorting.

Step 1: (How to data organizing as binary tree?)

Remember only 2 rule:

Rule:1.

The parent node must be greater then child node.
If parent node is not greater then to child node not replace it with parent node. And if binary tree is large then, if relaceing child node(now its parent node) is greater then to great-parent node then its also is replace the great-parent node.

Rule:2.

New element always insert in left side and after right side of parent node.
If left side of parent element has already element then new element would be insert in right side. And if right side of parent node has already element then new element will be insert in left side.

Step 2: (How to perform heap sorting:)