Skip to main content

Bubble Sort

 Let's begin!

Bubble Sort is a Sorting Algorithm which has two parts:

  1. Bubbles up the largest element at the last.
  2. Keep checking if the list is sorted.
One function will keep bringing the biggest elements at the last of the list and another function will recursively calling it until the list is sorted.

Comments

Popular posts from this blog

Merge Sort

 Let's begin! We've learned that Merge Sort is a sorting algorithm which follows the principle of Divide and Conquer and it have average time complexity as n(log n). I have used two functions to implement Merge Sort: 1. Merge Sort (To Produce Sub Array) It will divide array in two parts form left to mid and mid+1 to end. It will produce sub array until it's a single element. 2. Merge (To Merge Sorted Array) It will sort the array by comparing elements in left array and right array and store it into temporary array. It will save the remaining value. It will copy the temporary array into main array

Quick Sort

 Let's begin! Quick Sort is a sorting algorithm which follows the principle of Divide and Conquer with average time complexity as n(log n) and worst time complexity as n^2.  We have two functions to implement Quick Sort: Quick Sort Functions quickSort( )  Recursively call the function until start is less than end. partition( ) Swap elements to left which are less than pivot and brings pivot to it's ideal position.