Bubble Sorting
Bubble Sorting is one of the most commonly used sorting techniques among beginners. Although not the best sorting algorithm but bubble sort offers you a clean and concise algorithm and could be used if the input size is not very large. In a general bubble sort technique: Worst Case Complexity: O(n^2) Average Case Complexity: O(n^2) Best Case Complexity: O(n) The best complexity for a sorting technique so far is O(n logn). Concept of Bubble Sorting: In bubble sorting we basically iterate through an array and if we find that two constants are not in correct order then swap their position. Repeat this process until the array is sorted. For example: Consider an integer array ar={4,6,2,3,1,5} We need to sort array in increasing or ascending order. Lets mark the index position as i. Initially i=0. Now we will check that if ar[i] and ar[i+1] are not in correct order, if so then we will swap ...