In this situation, the smallest element will move down one place on each pass through the list, meaning that the sort will need to make the maximum number of passes through the list, namely n - 1. So bubble sort is slower than most of sorting algorithms. Therefore, in the best scenario, the time complexity of the standard bubble sort would be. This result is based on simple summation (of steps) performed at each stage. The worst situation for bubble sort is when the list's smallest element is in the last position. for temp variable. Purpose of the article. Problem : What is the worst case scenario for bubble sort, and why? It has a time complexity of O(n^2) in average and worst cases. It takes much time to solve the sorting tasks. This is the most efficient bubble sort I've come across so far. The article Improving Bubble Sort, is dedicated to explain the mechanism behind bubble sort in detail, apart from that, it also offers an improved bubble sort. This is because the count variable makes the inner loop iterate less based on the amount of iteration already done relative to the input size. Bubble sort is a simple, inefficient sorting algorithm used to sort lists. So we need to do comparisons in the first iteration, in the second interactions, and so on. There are so many alternative algorithms which take O(n*log(n)) time for sorting. Time Complexity: O(n) for best case, O(n 2) for average and worst case. It is generally one of the first algorithms taught in computer science courses because it is a good algorithm to learn to build intuition about sorting. It is linear taking n steps (if array is sorted already). Hence the time complexity of Bubble Sort is O(n 2). The Worst case for this is Cworst(n) = 1/2n(n+1), best case is Cbest(n) = n-1. The space complexity for Bubble Sort is O(1), because only a single additional memory space is required i.e. The complexity of Bubble Sort Technique. Also, the best case time complexity will be O(n), it is when the list is already sorted. Disadvantages of Bubble Sort: What are the disadvantages of using Bubble sort? In the worst case, the array is reversely sorted. If you have array of length n items, bubble sort takes [math]n^2[/math] steps. The main advantage of Bubble Sort is the simplicity of the algorithm. It takes on Ω(n) time in the best case. In practice it is quadratic. This algorithm is not suitable for large number of data set. While sorting is a simple concept, it is a basic principle used in complex computer programs such as file search, data compression, and path finding. Bubble Sort as the name suggests, bubbles up the heaviest (or may be lightest, depending on the comparison operator) elements to the top.