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

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -