@sivarajans/heap-sort-asc

1.0.2 • Public • Published

Heap Sort - Ascending Order

Min Heap Invarient data structure is used.

  1. Do min heap invarient structure.
  2. Swap last element with root
  3. Pop last element (which is root) that has minimum value.

Zero Based Index Formula:

All the parent = floor(n / 2) - 1 -- here n is total elements.

Child-1 of parent = 2i + 1 -- here i is index (0 based)
Child-2 of parent = 2i + 2

npm i @sivarajans/heap-sort-asc

Readme

Keywords

Package Sidebar

Install

npm i @sivarajans/heap-sort-asc

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

1.3 kB

Total Files

3

Last publish

Collaborators

  • sivarajans