RizOrt218 / sorting-algorithms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bubble-Sort

Sorting Algorithm

A sorting algorithm is a step-by-step operation to perform a certain task. In sorting algorithm we have multiple ways to take bunch of numbers that's not in order and sort them out from least to greatest.

This sorting algorithm includes:

  • Bubble Sort
  • Quick Sort
  • Merge Sort

Bubble Sort

Dear Joe,

If you want to sort numbers bubble sort style, you'd want to look at the first number and compare it to the number next to it. If your number you're currently on is higher, swap places with it. You would wanna do that until you reach the end. Once you reach the end of the number list, start all over again and do the same thing all over until you go through the list without having to do any swapping.

--------------------------------------------- procedure bubbleSort( list of sortable items ) count = keep track of swaps

for ( iterate through sortable items ) if( compare two elements ) swaps places if left element is greater than element next to it increment count

if( you've reached the end of sortable items )
  if ( no swaps took place )
    return the items

  else
    run the procedure again

---------------------------------------------

The performance of this procedure would

i gotta dig into this later. Going to work on the visualize right now

About


Languages

Language:JavaScript 97.9%Language:CSS 1.8%Language:HTML 0.3%