The bubble sort is the simplest way of sorting which is sometimes called sinking sort. In a bubble sort, we repeatedly compare each pair of adjacent elements and swap them if they are in the wrong order. We repeat this process until all elements get sorted. Let us use an example to understand this example clearly. Consider the following array. We will compare the first two elements in the array, i.e., 56 (index 0) and 63 (index 1). If the left element (at a lesser index) is greater than the right element (at a greater index), we will swap the numbers otherwise ignore them. So, in the first comparison between 56 and 63, we ignore them. During the second comparison, we compare 63 (index 1) and 84 (index 2). Again, the element at the lower index, that is, 63 is smaller than the element at the higher index, 84, so we ignore them. During the comparison of 22 (index 2) and 84 (index 3), we notice that the element at index 2 is greater than the element at index 3 so we swap the two numbers. The below image represents the complete first iteration during the bubble sorting of the above array. The coloured elements are the ones which are taken into consideration during the comparison. The elements coloured in light blue represent that the items are not swapped after comparison. The elements coloured in orange represent that the element was swapped after comparison. Finally, we get an array in which the last item (84 coloured in red) is frozen and it won’t be considered for any further sorting operation.Now, during the second set of iterations, the second highest number will get sorted. During each successive iteration, it will not consider the frozen elements from previous iterations. The further iterations for the sorting are –