2 ms·
Because it is the body that people care about when they talk about algorithms. But even if you include it, it is ran exactly as many times as the body of the l
by user-the-name 6y ago
Because it is the body that people care about when they talk about algorithms.
But even if you include it, it is ran exactly as many times as the body of the loop, so not sure why you bring it up?
- Thorrez 6y ago>Because it is the body that people care about when they talk about algorithms. The article isn't just talking about what happens in the body. It's also talking about what the value of i is after an iteration is done. >But even if you include it, it is ran exactly as many times as the body of the loop, so not sure why you bring it up? That's exactly why I bring it up: After 0 iterations, the iteration statement ran 0 times, so i is 0. After 1 iteration, the iteration statement ran 1 time, so i is -1. After 2 iterations, the iteration statement ran 2 times, so i is -2. ... After |INT_MIN| iterations, the iteration statement ran |INT_MIN| times, so i is INT_MIN. This directly contradicts the article. My point is that the article has an error. If on the other hand you say the iteration statement isn't part of the iteration you get: After 0 iterations, the iteration statement ran 0 times, so i is 0. After 1 iteration, the iteration statement ran 0 times, so i is 0. After 2 iterations, the iteration statement ran 1 time, so i is -1. ... After |INT_MIN| + 1 iterations, the iteration statement ran |INT_MIN| times, so i is INT_MIN. I don't agree with that point of view. But it does agree with the article.