Computer Science, asked by bititi2020, 10 months ago

how many times is the println statement executed

Answers

Answered by Punjabikudi4
1

I have been looking at this example for a while now and i'm stuck, my question is how many times the statement:

System.out.println(y);

would be executed in the following code:

for(int x=0;x<N;x++){

for(int y=x;y<N;y++){

System.out.println(y);

}

}

I was thinking it would surely be printed N+N-1+N-2(...) times right? We are studying Big-O complexity but i'm struggling with this at the moment.

hope this will help you♥✌

Similar questions