Skip to content

kanow-algorithms/merge-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

merge-sort

Instalation

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

npm install

To run npm install you must have installed node.js

Description

Example input :

const testArray: number = [31, 41, 59, 26, 41, 58];
MergeSort.sort(testArray, SortDirection.ASC);

Output of example input :

[26, 31, 41, 41, 58, 59]

Static method MergeSort.sort of class MergeSort 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 merge-sort algortihm works :

MergeSort

How merge method works

If you do not know what is going on after step three (merge-sort graphic). You can find the answer on the graphic below:

Merge

Releases

No releases published

Packages

No packages published