What will be the complexity of the algorithm below -


i have piece of code. think complexity of code o(n). not sure, can please confirm me?

int low=0; int high=array.length-1;  while(low<high)     {         while(array[low]!=0)             low++;         while(array[high]==0)             high--;          int temp=array[low];         array[low++]=array[high];         array[high--]=temp;     } 

your program keeps increasing low , decreasing high until meets, it's o(n)


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -