Normally the running time complexity of a buublesort is O(n^2) but the algorithm given below has a while loop and a for loop the for loop depends upon n but the while loop is simply a checker for a boolean value. Can anyone tell me how would i calculate the running time of this algorithm?
bool done; done = false; while ( ! done ) { done = true; for ( i = 0 ; i < a.length-1 ; i ++ ) { if ( a[i] > a[i+1] ) { // Swap a[i] and a[i+1] temp = a[i]; a[i] = a[i+1]; a[i+1] = temp; done = false; } } }