Asymmetric Bounds – Intro to Java Programming


When I start at some value a, and then it goes up to b including b, with a less than or equal sign here. Then there are b minus a plus 1 values. That plus 1 is a fence post, plus 1. For example, over here, we start at 10, we go to 20, and we have 20 minus 10 plus 1. That’s 11 values. What about the case? When i starts at some point and then it goes less to another point, in that case we have b minus a values. For example, if over here we change the less equal to a less than sign. Then we have 20 minus 10, or 10 values. Namely the values, 10, 11, up to 19. That’s a very common situation that you’ve seen before. Let me remind you, the situation where you, you have a less than for the upper bound. Is actually very common and you’ve seen it several times before. For example, now look at your left. There is the program that looks at all of the letters in a string. And when you look at the bounds you again notice a less than sign here. We go less than and the length of the word. So when we look at our formula over here. In this case, a is 0, and b is word.length. So how many iterations do we have? We have word.length minus 0 iterations. And that makes perfect sense. Because we have one iteration for every letter in the word. And word.length is the number of letters in the word.

Leave a Reply

Your email address will not be published. Required fields are marked *