initializing from 0

Ryan$

Junior Member
Joined
Jan 25, 2019
Messages
136
Hi guys;
I'm a lil confused and sorry if it was simple but I find it hard to understand.

lets assume I have n possibilities, which it starts from index 0 then why we say immediately at n-1 and not at n? to be more clear if I starts at index 2 then why I wouldn't say that I will end at n+2 otherwise we say would end at n+1? specifically I'm getting more and more confused once they saying to me you're now starting from index 0 and you have n/2 possibilities then we will end at index n/2 -1 , why not at n/2? exactly why starting from index zero will lead that we end at n-1 and not at n? thanks very very much
 

mmm4444bot

Super Moderator
Staff member
Joined
Oct 6, 2005
Messages
10,251
… exactly why starting from index zero will lead that we end at n-1 and not at n? …
Symbol n tells us how many index numbers we have. (When the index value starts at 1, then the value matches the count. That is, the nth index's value is n.)

When the index value starts at 0, that value is one less than the beginning index count. That's why the value is one less than n, at the end, too.

0 is the 1st index
1 is the 2nd index
2 is the 3rd index
3 is the 4th index
4 is the 5th index
and so on …
n-1 is the nth (last) index

Notice how the index value is always one less than the index count. Therefore, once we've counted off n index numbers, the nth index value will be one less than n.

Now look at a specific example: n = 7

This value of n tells us there will be seven index numbers. The first one is 0.

0 is the 1st index
1 is the 2nd index
2 is the 3rd index
3 is the 4th index
4 is the 5th index
5 is the 6th index
6 is the 7th index

We see that n-1 is the value of the nth index
 
Last edited:

Ryan$

Junior Member
Joined
Jan 25, 2019
Messages
136
Symbol n tells us how many index numbers we have. (When the index value starts at 1, then the value matches the count. That is, the nth index's value is n.)

When the index value starts at 0, that value is one less than the beginning index count. That's why the value is one less than n, at the end, too.

0 is the 1st index
1 is the 2nd index
2 is the 3rd index
3 is the 4th index
4 is the 5th index
and so on …
n-1 is the nth (last) index

Notice how the index count is always one more than the index value. Therefore, once we've counted off n index numbers, the nth index value itself will be one less than n.

Now look at a specific example: n = 7

This value of n tells us there will be seven index numbers. The first one is 0.

0 is the 1st index
1 is the 2nd index
2 is the 3rd index
3 is the 4th index
4 is the 5th index
5 is the 6th index
6 is the 7th index

We see that n-1 is the value of the nth index
firstly thanks for your cooperation ;
secondly but I can also labeling the indexes as
2 is the 1st index
3 is the 2nd index
4 is the 3rd index
5 is the 4th index
6 is the 5th index
but I will not get a label n-1 at the end.. why?! that's my point.
is starting from 0 labeling will lead definitely to n possibilities to end at index n-1 because we just started from index 0?!
 

Ryan$

Junior Member
Joined
Jan 25, 2019
Messages
136
For example if I have 2^3 possibilities, why the indexes from 0-(2^3 -1) will label all 2^3 possibilities? I claim that the last label/index must be 2^3 and not 2^3 - 1 .. so why it's
2^3-1?! thanks
 

Otis

Senior Member
Joined
Apr 22, 2015
Messages
1,156
Ryan$ said:
2 is the 1st index
3 is the 2nd index
4 is the 3rd index
5 is the 4th index
6 is the 5th index
The nth index value is n-1 only when the index starts at 0.

Were you to start with index 2, instead, you would be starting with a value that is one more than the beginning count, so the nth index would be n+1.

In your example, the index starts at 2 and n = 5. That's why the nth index (the 5th index) is n+1 (5+1=6).
 
Top