complexity of bubble sort the complexity of any sorting algorithm depends upon the number of comparisons in bubble sortwe have seen that there are - passes in total in the first passn- comparisons are made to place the highest element in its correct position thenin pass there are - comparisons and the second highest element is placed in its position thereforeto compute the complexity of bubble sortwe need to calculate the total number of comparisons it can be given asf( ( ( ( (nn ( )/ (nn / (no( thereforethe complexity of bubble sort algorithm is ( it means the time required to execute bubble sort is proportional to where is the total number of elements in the array programming example write program to enter numbers in an array redisplay the array with elements being sorted in ascending order #include #include int main(int intempjarr[ ]clrscr()printf("\ enter the number of elements in the array ")scanf("% "& )printf("\ enter the elements")for( = ; < ; ++scanf("% "&arr [ ])for( = ; < ; ++for( = ; < - - ; ++if(arr[jarr[ + ]temp arr[ ]arr[jarr[ + ]arr[ + tempprintf("\ the array sorted in ascending order is :\ ")for( = ; < ; ++printf("% \ "arr[ ])getch()return output enter the number of elements in the array enter the elements the array sorted in ascending order is bubble sort optimization consider case when the array is already sorted in this situation no swapping is done but we still have to continue with all - passes we may even have an array that will be sorted in or