more on HeapSort Algorithm

A heap is a binary tree that satisfies these special SHAPE and ORDER properties:

  • Its shape must be a complete binary tree.
  • For each node in the heap, the value stored in that node is greater than or equal to the value in each of its children.
  • Largest value always at root

can store in an array

Running Time

(N/2) * O(log N) compares to create original heap

(N-1) * O(log N) compares for the sorting loop

= O ( N * log N) compares total

 

 

© Lynne Grewe