229
votes
Why do we count starting from zero?
None of the reasons you suggest really get to the heart of why we use zero-indexing in CS. Dijkstra's EWD831 explains why this convention works out the best. It comes down to the fact that we want to ...
114
votes
Why do we count starting from zero?
If I can modify the question, I can answer what I believe you are looking for.
The question is "Why do we count starting from zero?" The answer is "we don't" Not even in computer science do we "count"...
63
votes
Why do we count starting from zero?
I'm surprised that the following hasn't been stated yet. All of the answers given so far seem to be "after the fact" explanations of something that is really based on the way people built most (not ...
47
votes
Real life examples of 0-indexing
You can get at this concept very intuitively in strings before you ever get to arrays. Take a string like "hello world" and ask them a subtle-sounding point: does the string begin here: ...
44
votes
Real life examples of 0-indexing
Ages in the United States (it's not the same around the world).
For the first year of life, children are 0 years old. Only after completion of a year is the age changed to 1. By this logic, a child ...
40
votes
Why do we count starting from zero?
You have already gotten several good answers about why zero-based indexing is useful, and you have been explained the difference between indexing and counting.
I now want to challenge the basic ...
37
votes
Real life examples of 0-indexing
An analogy that will work well in Europe, but not in North America:
Image licensed under the CC BY-SA 3.0 by Bidgee of Wikimedia Commons.
Floors (in European countries) are typically numbered with 0 ...
27
votes
Accepted
How to respond to the two-handed approach to swapping
Don't overcomplicate things. Your first instinct, that the computer only has one hand, was the correct one.
This is a regular problem that new teachers have, and it sometimes takes a few years of ...
24
votes
Real life examples of 0-indexing
The clock (24 hours system)
If we look at the clock, we have two examples of counting hours. The 24 hour system starts at 0. The 12 hour system is interesting, neither starting at 0 or 1.
The 12-hour ...
23
votes
Why do we count starting from zero?
When I've explained this to beginning students, I don't stray far from your third reason, though I agree that the beginning of arrays is early to introduce the concept of memory addresses. Among ...
22
votes
How to respond to the two-handed approach to swapping
Re-evaluate what you think is "right", because you aren't
but isn't right in computer science
This is simply incorrect. Your student can create two variables called ...
16
votes
How to respond to the two-handed approach to swapping
Your problem is that you tried to let your student "program" without establishing a language. Thus they were free to write their own "language" in which you can do two things at ...
11
votes
Real life examples of 0-indexing
I don't see anything confusing in 0-based indexing. In fact, it seems that 0-based indexing is not less natural for humans than 1-based indexing. Humans use 1-based indexing just because of following ...
11
votes
Lesson Idea: Arrays, Pointers, and Syntactic Sugar
You overestimate the complexity of 0-based indexing a lot. There is nothing complex in 0-based indexing.
On the other side, the topic of the pointers is relatively complex. I don't think it has any ...
10
votes
Lesson Idea: Arrays, Pointers, and Syntactic Sugar
This is a great explanation of why 0-indexing exists. As someone who barely knows what a pointer is, your explanation made perfect sense. If you wanted to dumb it down a little you could phrase it as:
...
10
votes
Why do we count starting from zero?
In computer science, we usually count starting from 0.
In programming or in (theoretical) computer science?
In Programming
In C programming language you count from 0 to (N-1). And of course in ...
9
votes
Real life examples of 0-indexing
Rulers start at zero:
At zero centimetres, you have nothing, whereas at one centimetres, you have one unit of length. Memory is similar: You start filling at the beginning (zero), hence, the first x-...
9
votes
Why do we count starting from zero?
In languages such as C, the first item in an array has an offset of zero from the pointer. If the size of your objects are 4 bytes, the next item has an offset of 1 x 4 bytes.
...
8
votes
Real life examples of 0-indexing
Exponents representing the values of the digits in positional number systems.
e.g. the-arabic-system / denary / the-system-you-learnt-in-primary-school.
...
8
votes
Accepted
Array or vector? Two dimensional array or matrix?
First, see this question on being pedantic. Second, consider the fact that you are teaching Computer Science and not Mathematics. The former is not a subset of the latter. There is some overlap, of ...
7
votes
Single-dimensional array and simple looping activities of significance
The Dutch National Flag problem is linear in running time. Essentially sort an array with only 3 distinct values each of which may appear 0 or more times. (not length 3). You are allowed only one pass ...
7
votes
Single-dimensional array and simple looping activities of significance
A variant on the ENIGMA machine encryption works well in a single loop, and is sufficiently complex to give students a real challenge.
The core idea of the ENIGMA machine for this assignment is that (...
7
votes
Why do we count starting from zero?
Simply put, we do not count from zero, we shift from zero
You can think C as a neat way to not write different assembly for every architecture/machine/processor in existence. Instead, take a simple ...
7
votes
Array or vector? Two dimensional array or matrix?
I believe that the CS notion of a vector is not related to the concept of a vector as a fixed size set of components, and rather comes from the idea of a rank 1 tensor (which is also called a vector). ...
7
votes
Array or vector? Two dimensional array or matrix?
You are correct and incorrect at the same time. Nomenclature is important when teaching, and when programming. Being pedantic about nomenclature is a slipper slope and a morass. As noted by @Buffy in ...
6
votes
Lesson Idea: Arrays, Pointers, and Syntactic Sugar
Draw ongoing attention to the potentially confusing point by banning cardinal descriptions of an element's position.
Avoid referring to the "first element" or "second element" and talk only about "...
6
votes
Why do we count starting from zero?
I will try to answer, without reference to low-level programming (or any programming language), without mention of history, or much maths.
As already stated in some answers, we do not count from zero ...
6
votes
Why do we count starting from zero?
From time to time I have had to do numerical work in MATLAB and the 1-based indexing always stuck out like a sore thumb, so I have a few examples I can provide where 0-based indexing is advantageous.
...
6
votes
Why do we count starting from zero?
Rather than answer myself based off my personal preference, as all other posters have done, I would instead like to link the following very in-depth analysis instead:
Arrays Indexed From One by Loki ...
6
votes
Array or vector? Two dimensional array or matrix?
When introducing terms that have different meanings in different fields, first, accept that both uses are correct. As others have alluded, this is a case of two different fields using the same term ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arrays × 9lesson-ideas × 3
labs × 2
abstraction × 2
teaching-analogy × 1
algorithms × 1
ap-computer-science-a × 1
c × 1
computational-thinking × 1
cs-theory × 1
syntax × 1
looping × 1
primary-school × 1
scratch × 1
secondary-education × 1
concurrency × 1