Simple question from an algorithm noob...
If $i=1$ then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode?
For i=1 to n
For k=1 to i-1
...
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communitySimple question from an algorithm noob...
If $i=1$ then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode?
For i=1 to n
For k=1 to i-1
...
It is acceptable.
The loop says “do something for each integer $k$ in some range”. If there is no integer in that range, the loop just won’t do anything.