I am a bit confused about the time complexity, in the case of two seperate while loops.
I am aware that the code:
while(i<N){
code
while(k<N){
code
}
}
will have a complexity of O(n^2)
What about the case where we don’t have nested loops, though?
while(i<N){
}
while(k<N){
}
>Solution :
So you run two loops, one after the other. If they both perform n iterations, then your code performs 2n loop iterations in total.
Now, 2n = O(2n) = O(n) (by the properties of big-O notation), so that is your time complexity.