Skip to content

kanow-algorithms/insertion-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

insertion-sort

Instalation

After you clone this repo you need to move inside insertion-sort directory and run command

npm install

To run npm install you must have installed node.js

Description

Example input :

const testArray: number = [2, 5, -12, 91, 5];
insertionSort(testArray, SortDirection.DESC);

Output of example input :

[-12, 2, 5, 5, 91]

insertionSort method takes two parametrs:

  • elementsList -> it is the list which you want to sort
  • direction -> it is optional parameter which you can set as ASC or DESC (ASC is default option)

ASC (Ascending), DESC Descending)

How it works

On this graphic you can see how insertion-sort algortihm works :

InsertionSort