Real life examples of 0-indexing

Computer Science Educators Asked on August 21, 2021

It can be perplexing for students to begin counting at 0 when they enter a CS class. I made it a point over and over to talk about “Day 0” and “Week 0” in the opening days and weeks just to build familiarity with the idea. Even so, I sought when explaining this idea to ground it in some real-life/non-CS example where we as humans use 0-indexing naturally and possibly without knowing it.

Question: where can we find 0-indexing outside of CS and grounded in everyday human experience?

I’ll share the one example I can think of below (Q&A style), but I’d love to hear more, potentially better, examples.

[Note: This question relates to another I just posed.]

20 Answers

I realize this post is old. However, what helped me and what may help others is that 0 is indeed on the number line. The best analogy I can give to support this cause is related to a bank account.

If you are -5$ in your account and you add 10$. Your total sum is 5$. Placing this on the number line (as seen below) -5 becomes your "0" as you count up by 10. If you start -5 as 1, your short 1$. If you skip 0 in your addition of 10, you gain 1$.

-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5

Simplifying things to its core has been my most successful tool in life.


Answered by spiffykat404 on August 21, 2021

where can we find 0-indexing outside of CS and grounded in everyday human experience?

This is really begging the question (in the strict sense): you assume that there's any need for it, whereas I boldly claim that there's none whatsoever, making the question moot. In fact, I think it's really counterproductive, and is an attempt to solve a non-existent problem.

As far as educational theories go, such a question is very loaded. Are you sure that such everyday human experience will have any other applicability to the problem? It's like trying to teach quantum mechanics while referring to everyday human experience: it's totally futile, since there's no everyday human experience that has any resemblance to what happens on quantum level, and if there is then the resemblance is wholly superficial.

See, the heart of the problem is whether there is any way to continue deduction based on human experience. If you refer to human experience, the students will naturally try to rely on what they know from "real life" as they go on in their studies, and they'll try to rely on that first, before reaching into the "unfamiliar" but task-specific knowledge. In most cases, the real-life "analogues" are baggage, since any further deductions one makes based on them tend to be either outright invalid, or subtly broken.

I personally don't think that there's much to 0-indexing. Tell the students that it's a convention no different from starting to count at 1. It's something we agreed to, and when you use some programming languages, the convention is 0-based. That's all there's to it. You can explain to the students that it's no different to agreeing to greet the teacher by saying "hello" or "good [morning|afternoon]" rather than "yo brother, what's up?". It's entirely arbitrary, it's based on a-priori decision to treat the "yo brother" form of address as informal or disrespectful or what have you.

Answered by Kuba hasn't forgotten Monica on August 21, 2021

Distances in boardgames with discrete spaces. For example: Chess, wargames, Dungeons & Dragons played on a battlemap, etc. Counting movement, the space you start in counts as space zero (or more accurately: if a piece stays in the same space, then it has moved zero distance).

There are a number of situations in wargames and RPGs where two pieces might share the same space; and if one shoots at the other, then the distance between them is considered to be zero. Many D&D magic spells have a range listed as zero to reflect this (thinking past editions here; current edition explicitly says "Self" or "Touch" in these cases).

Answered by Daniel R. Collins on August 21, 2021

The ground floor is the de facto 0th floor.

Humans are born at age 0.

Military time starts at 0:00. Despite the day having 24 hours, it is not correct to write 24:00.

As a side-note, Japanese TV uses 0-indexed 12-hour notation. That means 11 AM is followed by 0 PM, not 12 PM.

Answered by haley on August 21, 2021

Rulers start at zero:

enter image description here

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-memory units contain x units of data, the next unit contains unit x+1.

Answered by user2768 on August 21, 2021

Think about human ages. Babies that are newly born are at age 0. That's zero-based indexing.

Answered by ncmathsadist on August 21, 2021

Some train stations (but not many) have a platform 0:

If you are lucky enough to live in one of these towns, then it may be a very good example.

Answered by ctrl-alt-delor on August 21, 2021

Subtraction paradox: In North-American football, if a runner goes from the 3 yard line to the 4 yard-line, there is a (4-3) = 1 yard gain. However, if your math teacher assigns problems 3-4 (integers), you have to do two problems. So in what engineers call an "analog" system, the Result = Stop - Start; but for integers it can be more complex.

So in North American football, the yard line starts at "0" which is called the "Goal Line" typically.

Answered by JosephDoggie on August 21, 2021

Light gang switches, same the way you teach binary counting. (Well, the same way that I was taught binary arithmetic back when knowing binary and hex were important.)

EDIT: An off transistor (simulated by a light switch) is considered to be 0 (no voltage) and an on to be 1 (voltage passing). Since "all zeros" is a valid configuration, 0 is a valid address where Important Bits can reside. That's why many languages base arrays using 0.

EDIT 2: It's also the basis of pointer arithmetic. Your array has a base address at location A, so that's where the first element goes. When you're referencing the elements in a loop, you add an offset O to get to each array element. To access the first element, the value of O must be 0.

enter image description here

Answered by RonJohn on August 21, 2021

UK school years

We used to have years 1,2, 1,2,3,4, 1,2,3,4,5,6th form.

We then changed to 1,2,3,4,5,6,7,8,9,10,11,12,13 (years 12 and 13 are 6th form, no one know where this name comes from).

Then we added reception year, to get R,1,2,3,4,5,6,7,8,9,10,11,12,13.
R is just a different symbol for 0. (In the US K is used for 0.)

Answered by ctrl-alt-delor on August 21, 2021

Exponents representing the values of the digits in positional number systems.

e.g. the-arabic-system / denary / the-system-you-learnt-in-primary-school.

10³  10² 10¹ 10⁰
1000 100 10  1

or binary

2³ 2² 2¹ 2⁰
8  4  2  1

The binary example in binary

10¹¹ 10¹⁰ 10¹ 10⁰
1000 100  10  1

This was @GypsySpellweaver idea, see comment.

Answered by ctrl-alt-delor on August 21, 2021

A common example I use is centuries/years. We start with the first century on a range of 0-100 years. Or the first year of a century, which always ends in 00. It describes the amount of x that has passed, not the n-th x.

The word "first" is the confusing thing for beginners I feel.

Answered by Karnat on August 21, 2021

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 some long-standing, but weird tradition.

I remember that when I was a pre-school child (<7 years old) and has not been yet influenced by social traditions of numbering (I didn't visit a kindergarten), I used a mixed numbering scheme. For example, when we had in our house a lot of guests sitting around a table, and I was crawling under the table, plotting some childish prank — and I needed to make an association between torsos (I see above the table when I'm out of under-the-table area) and pairs of legs (I see when I'm under the table); I don't remember what prank I was planning, but I strongly remember that to remember a position of a victim-guest, I used scheme like "three+one":
"three+one" numbering (picture based on "Break" by Llisole (cc))
I.e. neither referring this guest as third, nor referring him as fourth was not enough intuitive for me. Indeed: "three" is a number of guests before him — not his position; "four" is a number of guests including him — not his position; probably, if I knew fractional numbers at that time, I'd referred him as "3½-th", but I didn't.
I remembered this episode well, because when I was running to another room to take equipment needed for prank, muttering "three plus one" to myself aloud (not to forget it), the same age girl who was one of guests shouted "four" — which annoyed me very much ("[email protected]#k, I know how to add much larger numbers, but '3+1' is a position specification rather than just sum").

0-based stuff is preferrable everywhere, where gauges are used. You start time from zero (you say "0 hours" at midnight, not "1 hour"; "0 minutes" when a new hour starts, not "1 minute"; "0 seconds" when a new minute starts, not "1 second"), temperature from zero, distance from zero, etc. What really confuses is actual discrepancy between 0-based and 1-based, not the 0-based itself; for example, I needed some time at school to realize why people usually call it "<N+1>-th second" ("minute", "hour", etc) when it's still "0:00:<N>" on stopwatch:
Time scale: time range from 0:00:<N> to 0:00:<N+1> is usually called as <N+1>-th second
IMHO: Nothing would break if some day people will finally switch to 0-based indexing; even vice versa, it would become much more intuitive and comfortable — a stopwatch shows "0:00:<N>", so let's call it "<N>-th second" (not "<N+1>-th"); but some-why people had chosen this weird way of 1-based indexing long ago.

TL;DR: In 0-based indexing we count items before (up to, but excluding) current; in 1-based indexing we count items through (up to and including) current. Neither way is in fact intuitive (for a child that has free choice). Both ways need to be learned.

Answered by Sasha on August 21, 2021

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: "*hello world", or here: "h*ello world". They'll certainly be able to identify the correct answer.

Then ask, "how far from the start of the string do we have to go to get to the 'h'? Answer in a number of characters. Do we have to move 5 characters away? 3? 1?" Again, they should be able to identify 0.

Now, it's time for the big reveal. (My description here is in Java)

"When I want to get at that first character, h, I do it with myString.charAt(0). Given what we just discussed, why do you think I would use 0, and not 1?"

At this point, they will naturally move to the idea that it is at the beginning, and that we have moved no steps from the beginning.

"Excellent. This is an example of an index value. And, in Java, when we do index values, we don't count from '1', we actually count the DISTANCE from the start. So, if we want the first character, we move no distance. And how far do we move to get the 3rd character? ..."

When you later get to arrays, you can remind them of the concept, and just say that it is being used again here.

Answered by Ben I. on August 21, 2021

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 clock

In the 12-hour clock system we start at 12 and make our way up to 11.

This needs some explanation. The 12 hour clock has a funny way of counting, that you may not have noticed. It goes 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. (look carefully at a clock that has AM and PM indicators. Without these, then it is just a regular circular (mod 12) counting system.) 12am, 1am, 2am, 3am, 4am, 5am, 6am, 7am, 8am, 9am, 10am, 11am 12pm, 1pm, 2pm, 3pm, 4pm, 5pm, 6pm, 7pm, 8pm, 9pm, 10pm, 11pm

The 24-hour clock:

In the 24-hour clock things are simpler. Numbers just go up, until we get to the end of the day (mod 24). However we start with zero, this may be to keep it backward compatible with the 12-hour system, but also makes the time of day, be the elapsed time since the start of the day (see other answers that stat that starting at zero is just how you measure things).


Note I have finally found an advantage of daylight shifting time. In the summer noon is at 13:00, and midnight at 1-oclock. This makes the 12hour system start at 1: i.e 1, 2, 3 … 11, 12; (instead of 12, 1, 2, 3 … 11). However AM and PM are now wrong, as the meridian does not move.

Answered by ctrl-alt-delor on August 21, 2021

For anyone old enough (>30years):

In the UK a few years back we had only a few TV channels, first 1, then 2, they slowly increased to 5: BBC1, BBC2, ITV, channel 4, and eventually channel 5 The TVs typically had 10 numbered slots (sometimes 8). the slots where 0 - 9, we would but the channels into the slots 1 = BBC1, 2 = BBC2, 3 = ITV, 4 = channel-4, 5 = channel-5. So where to but the video recorder ( a device to record TV shows for later viewing). Well if we use slot 6 and the TV companies finally add a 6th channel, then we will have to move it, so we put it in slot zero.

Eventually we suddenly got a load more, with digital TV (Freeview). This story ignores, payed for channels (satellite and cable).

Answered by ctrl-alt-delor on August 21, 2021

This one in related to computing, but sufficiently different, as it related to the social side. You can link it in by teaching the social side before indexing.

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbour (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

Extract from (Creative Commons Attribution-NoDerivatives 4.0 International License).

Answered by ctrl-alt-delor on August 21, 2021

An example from thermodynamics: the study of heat and temperature.

In thermodynamics there are 4 laws, numbered from zero. Look to see when your pupils study this in physics (science). You now have cross curricular linking, which is also good.

Like Asimov's 0th law of robotics, the zeroth low of thermodynamics was added after the other 3: “The zeroth law was not initially recognized as a law, as its basis in thermodynamical equilibrium was implied in the other laws. The first, second, and third laws had been explicitly stated prior and found common acceptance in the physics community. Once the importance of the zeroth law for the definition of temperature was realized, it was impracticable to renumber the other laws, hence it was numbered the zeroth law.” —

  • Zeroth law of thermodynamics: If two systems are in thermal equilibrium with a third system, they are in thermal equilibrium with each other. This law helps define the notion of temperature.

  • First law of thermodynamics: When energy passes, as work, as heat, or with matter, into or out from a system, the system's internal energy changes in accord with the law of conservation of energy. Equivalently, perpetual motion machines of the first kind are impossible.

  • Second law of thermodynamics: In a natural thermodynamic process, the sum of the entropies of the interacting thermodynamic systems increases. Equivalently, perpetual motion machines of the second kind are impossible.

  • Third law of thermodynamics: The entropy of a system approaches a constant value as the temperature approaches absolute zero. With the exception of non-crystalline solids (glasses) the entropy of a system at absolute zero is typically close to zero, and is equal to the logarithm of the product of the quantum ground states.

Extract from Text is available under the Creative Commons Attribution-ShareAlike License

Answered by ctrl-alt-delor on August 21, 2021

An analogy that will work well in Europe, but not in North America:

Lift Control Panel

Image licensed under the CC BY-SA 3.0 by Bidgee of Wikimedia Commons.

Floors (in European countries) are typically numbered with 0 (or G) as the ground floor, then 1 as the first floor above ground, etc. This could easily be compared to a list/array of floors, with floors[0] being ground, floors[1] being the first floor, and so on.

Note that this analogy won't work particularly well in North American countries, as their convention is to number the ground floor as 1. Nevertheless, the visual element of a building and lift numbered from zero could serve as an intriguing example to illustrate zero-based indexing.

Answered by Aurora0001 on August 21, 2021

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 in his/her second year of life is 1 just as the second element of an array is found at index 1.

Edit: another example is the counting of centuries. An event occurring in the 100s would be in the second century.

Edit #2: watching the Champions League Final, I just thought of another: the timing of soccer. A goal scored during the 20th minute is scored while 19:xx is on the clock.

Answered by Peter on August 21, 2021

Add your own answers!

Related Questions

AP Computer Science A vs. OCP

1  Asked on June 19, 2021 by marwi


Cheating on labs

11  Asked on May 14, 2021


How to learn Java as a beginner?

2  Asked on April 4, 2021 by long-le-thanh


games for teaching html

0  Asked on March 8, 2021


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir