analysis

Bubble Sort Best Case Analysis

Given Input: [1 3 6 7 8 ]

 

Best Case Analysis

****************

  1. The best case for bubble sort occurs when the list is already sorted or nearly sorted.

  2. In the case where the list is already sorted, bubble sort will terminate after the first iteration, since no swaps were made.

  3. Any time that a pass is made through the list and no swaps were made, it is certain that the list is sorted

  4. The term best case performance is used to describe an algorithm's behavior under optimal conditions (i.e) for sorting, given inputs are sorted list.

 

For sorted list , bubble sort requires minimum no. of comparisons , it leads to better performance.

 

Total No of elements : 5

 

Total No of passes : 5-1 = 4 passes

 

For all the passes , bubble sort takes 10 comparisons in best case analysis.

 

Time complexity for Best Case : O(n2)

 

Back...

Sorting by MS.K.Abirami

  • BUBBLE SORT

    Bubble sort is a sorting algorithm that works by repeatedly stepping through lists that need to be sorted, comparing each pair of adjacent items and swapping them ...Read more »

  • INSERTION SORT

    A simple sorting technique that scans the sorted list, starting at the beginning, for the correct insertion point for each of the items from the unsorted list… Read more »

  • SELECTION SORT

    It starts by comparing the entire list for the lowest item and moves it to the #1 position. It then compares the rest of the list for the next-lowest item....Read more »

  • QUICK SORT

    A sorting technique that sequences a list by continuously dividing the list into two parts and moving the lower items to one side and the higher items to the other. … Read more »

  • BUBBLE SORT

    The number of comparison between elements and the number of exchange between elements determine the efficiency of Bubble Sort algorithm.Read more »

  • Insertion SORT

    Insertion sort is also a time taking technique as its complexity is O(n2)Read more »

  • selection SORT

    The number of comparison between elements and the number of exchange between elements determine the efficiency of Bubble Sort algorithm.Read more »

  • quick SORT

    The efficeieny of the quicksort depends on the pivot element. However the pivot element can also be choosen at random order or from the last element of the array

    Read more »