Skip to content

Aashish Sort 5

Aashish Bharadwaj edited this page Mar 27, 2018 · 11 revisions

Average time complexity - Θ(2n^2)

Best-Case time complexity - Θ(n^2)

Worst-Case time complexity - Θ(4n^2)

Worst-case space complexity - Θ(n + 1)

Aashish Sort 5 is a placeholder name for a sorting algorithm I made as an improvement upon Aashish Sort 2. Neither are good algorithms.

Aashish Sort 5 finds the minimum value in the array, places it into a new array next to the previous element, then deletes that item from the original array. It keeps doing this until the original array is empty.

Let's use the following array as an example:

Original array: 4, 1, 5, 2, 3

New Array: -, -, -, -, -

After the first pass, it places the 1 into the new array because it is the smallest element in the array. It then deletes it from the original.

Original array: 4, 5, 2, 3

New Array: 1, -, -, -, -

As can be seen, the 1 was deleted from the original array. Next is 2.

Original array: 4, 5, 3

New Array: 1, 2, -, -, -

And then 3.

Original array: 4, 5

New Array: 1, 2, 3, -, -

And then 4.

Original array: 5

New Array: 1, 2, 3, 4, -

And then 5.

Original array:

New Array: 1, 2, 3, 4, 5

Considering that it needs to shift the entire array down every time that it "deletes" an item from the original, it is not at all efficient in number of writes.

Clone this wiki locally