in ascending orderin bubble sortingconsecutive adjacent pairs of elements in the array are compared with each other if the element at the lower index is greater than the element at the higher indexthe two elements are interchanged so that the element is placed before the bigger one this process will continue till the list of unsorted elements exhausts this procedure of sorting is called bubble sorting because elements 'bubbleto the top of the list note that at the end of the first passthe largest element in the list will be placed at its proper position ( at the end of the listnote if the elements are to be sorted in descending orderthen in first pass the smallest element is moved to the highest index of the array technique the basic methodology of the working of bubble sort is given as follows(ain pass [ and [ are comparedthen [ is compared with [ ] [ is compared with [ ]and so on finallya[ - is compared with [ - pass involves - comparisons and places the biggest element at the highest index of the array (bin pass [ and [ are comparedthen [ is compared with [ ] [ is compared with [ ]and so on finallya[ - is compared with [ - pass involves - comparisons and places the second biggest element at the second highest index of the array (cin pass [ and [ are comparedthen [ is compared with [ ] [ is compared with [ ]and so on finallya[ - is compared with [ - pass involves - comparisons and places the third biggest element at the third highest index of the array (din pass - [ and [ are compared so that [ ]< [ after this stepall the elements of the array are arranged in ascending order example to discuss bubble sort in detaillet us consider an array [that has the following elementsa[{ pass (acompare and since no swapping is done (bcompare and since swapping is done (ccompare and since no swapping is done (dcompare and since swapping is done (ecompare and since swapping is done (fcompare and since swapping is done (gcompare and since swapping is done observe that after the end of the first passthe largest element is placed at the highest index of the array all the other elements are still unsorted pass (acompare and since swapping is done (bcompare and since no swapping is done (ccompare and since no swapping is done (dcompare and since swapping is done (ecompare and since swapping is done