45

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.]

Peter
  • 9,082
  • 2
  • 22
  • 61
  • 17
    The index of an array is a measure of the distance from the start. (not what you asked for, but another way to explain it). – ctrl-alt-delor May 27 '17 at 10:12
  • 4
    There are a few here: https://en.wikipedia.org/wiki/Zero-based_numbering – ctrl-alt-delor May 27 '17 at 10:32
  • 7
    When playing board games, my six year old starts counting from zero, for the square her counter is on. – Miles May 27 '17 at 19:13
  • Was there a, very good, answer about azimov's laws of robotics here? Or did I dream it? – ctrl-alt-delor May 28 '17 at 09:05
  • If you thing zero-indexing is weird (see answer below for why it is not), then consider temperature: °F and °C have a strange starting point, −459.67°F and −273.15°C. – ctrl-alt-delor May 28 '17 at 10:04
  • 5
    One is the first natural number, but nought is the zeroth. – Miles May 29 '17 at 18:41
  • 10
    As seen by the majority of the comments, the key is to separate `index` from `count`. `index` relates to distance or movement, which has zero as the beginning, while `count` relates to quantity, which has a (possibly) natural beginning of one. If the students have the proper level of mathematics, you can also use the powers-of-10 (the first, lowest, digit is x*10^0. – Gypsy Spellweaver May 30 '17 at 13:44
  • 2
    @GypsySpellweaver love the positional (Arabic number system) ($10^n 10^2 10^1 10^0$). You should add this as an answer. I think this question will benefit from lots of answers, as different pupils will grok different analogies. – ctrl-alt-delor Jun 04 '17 at 07:56
  • @richard That's one that needs decent algebra to fathom, but can fit if the class is right. – Gypsy Spellweaver Jun 04 '17 at 08:00
  • @GypsySpellweaver Reminded me of [xkcd - Powers of 1](https://xkcd.com/271/) –  Jun 15 '17 at 19:26
  • 1
    ob xkcd: https://xkcd.com/163/ – Ellen Spertus Jul 21 '17 at 03:27
  • another cartoon: http://i.imgur.com/uqhv4mB.png – Ellen Spertus Jul 27 '17 at 23:02
  • Why not just explain the hardware reason why array indexes start at zero *in some languages*? There isn't a good abstract reason why the compiler writers did this, and suggesting there is is likely to be a block for some students. – Dikran Marsupial May 30 '22 at 08:27
  • @DikranMarsupial it is just distance.Try using a language that indexes starting at 1. You end up subtracting 1 doing the calculation then adding 1. It is a complete pain. e.g find the centre index. – ctrl-alt-delor May 30 '22 at 08:58
  • @ctrl-alt-delor I have used languages which index starting at 1. The two languages I program in most are C/C++ and MATLAB. The point is that it is better to be honest when teaching and give the real reason why something is the way it is, rather than give a post-hoc fiction. I personally don't find it a problem, unless people try to fudge it (e.g. "Numerical Recipes in C" where they did pretty much exactly that IIRC and made it much harder to integrate into C programs). – Dikran Marsupial May 30 '22 at 10:05
  • I love this question. This is the type of thing I am always looking for, and encouraging my students to develop, but it never would have occurred to me to ask it here. :-) – codingCat May 31 '22 at 14:09

21 Answers21

47

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.

Ben I.
  • 32,726
  • 11
  • 68
  • 151
  • 6
    I like this. You can get more real-life examples based on counting the DISTANCE. e.g. If you knock on the first door in an apartment block and ask where Alice lives, they say 'go down 3 doors', that's like indexing into the array of apartments. And if Alice lives in the first then you don't move, ie you go down 0 doors. – Rory May 27 '17 at 21:26
44

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.

Peter
  • 9,082
  • 2
  • 22
  • 61
  • 10
    I thing this answer is exactly it. Just like a ruler, and @Choirbean's string answer: we measure from 0, but (usually) count from 1. In arrays we are giving the distance, a measure. – ctrl-alt-delor May 27 '17 at 11:22
  • 8
    I really like the idea of thinking of the index not as a count per se but as a measurement from the origin. – Peter May 27 '17 at 18:46
  • I think this is the right answer to the original question, but want to add for the OP something unrelated that I've found useful: the words that languages and libraries use can make this much easier or harder to grasp. Whenever I'm dealing with 0-based indexes, I mentally translate to skip and take, which makes them perfectly clear. If you can find a library that uses these terms as your first introduction to the concept, it might make it easier to learn. – ShawnMartin Sep 24 '20 at 22:09
  • "For the first year of life, children are 0 years old. " but we would say that they were in their first year of life – Dikran Marsupial May 30 '22 at 08:22
  • A valid point and true if the measuring criteria is years. When a child is in it first year of life I've often heard its age being referred to in terms of months. As an alternative to your example, and this is very much a custom of a group or a culture, many years ago I often heard migrants from eastern Europe refer to people, whether child or adult, as being in their such-and-such year of life, not so many year old. ... –  Jun 04 '22 at 10:33
  • ... To use your example, a child that hadn't yet reached its first birthday would be in its first year of life. An adult who, by our custom, would be 40 years years old would be referred to as being in their 41st year of life. –  Jun 04 '22 at 10:34
37

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.

Aurora0001
  • 3,506
  • 14
  • 43
  • 2
    The problem with this is, that, while they are numbered 0, 1, and so on, the floor with number one is also called the first floor (at least in Germany and other European countries I know of), while in an array the first element is not indexed with 1. – Raimund Krämer Jun 06 '18 at 14:29
  • 2
    @RaimundKrämer well, that's a defect of the way we talk about arrays, probably stemming back to Fortran days. I avoid using _erstes_, _zweites_ etc. to refer to array elements, and say instead _Startelement_ and _Nachfolgerelement_. In English, I use list terminology: the _head_ and the _head of tail_. (Naming more than the frontmost two, the last, or the middle elements is seldom necessary.) – leftaroundabout Sep 03 '18 at 10:56
  • 1
    , you beat me to it. An elevator was the first example I thought about. :-) – codingCat May 31 '22 at 14:07
24

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).

$00\colon{}00\colon{}00$$23\colon{}59\colon{}59.99\dot9$


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.

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 3
    I think the idea is that the first hour of the day in the 24-hour clock is 00:00. Hence, what would be 12:01 am is in fact 00:01. See http://militarytimechart.com/ – Peter May 27 '17 at 18:55
  • 2
    So what does the phrase "The Eleventh Hour" mean, 10 am? Big deal. Still have more than 13 hours to go. –  Jun 15 '17 at 19:33
  • 1
    @nocomprende strangely the 11th hour meant from 11pm. So the **12th** hour of the afternoon. – ctrl-alt-delor Jun 15 '17 at 21:36
  • 2
    @nocomprende I just realised that the 11hour is like an octave. An octave is named because depending how you count there is ether 7 or 12 notes in an octave. The 2 biggest cases of error are, null references, not validating inputs, and out by one errors. – ctrl-alt-delor Aug 23 '17 at 14:00
  • 1
    Also, a 'third' in music is the 3rd note in the scale, not three up from the first note. A fifth, seventh, etc - same thing. Octave is thus: 8 notes up, or the entire scale starting over again. The hours of the day used to be noted from sunrise, so there were only about 12 (near the equator). Hours at night were not noted, because no one could see the sundial. "Ship's Bells" start at noon / midnight with a single ring and add one at the half hour. They start over after 8 rings, thus 4, 8 and so on. –  Aug 23 '17 at 14:35
11

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 ("f@#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.

Sasha
  • 320
  • 1
  • 9
  • 3
    When I was a child, I thought that adding past 10 required adding two: one to change the 9 to a zero and one more to put the one in front. It took a while for a tutor to figure out why all my sums were off by one. –  Jun 15 '17 at 19:39
9

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.

user2768
  • 281
  • 2
  • 2
  • 1
    I think comparing an array to a ruler is probably the nicest, most visual thing at hand. If you have a ruler with both inches and centimeters you also have a metaphor for different memory sizes for variable types. – ObscureOwl Mar 06 '20 at 17:55
  • Since this question was posted, I have come to realise that a ruler is not a metaphor for this think. It is the think. Zero indexing is simply measuring the distance from the start. There are many examples of this in the other answers. – ctrl-alt-delor May 29 '22 at 18:05
  • A great visual example – codingCat May 31 '22 at 14:14
  • 1
    I don't think the ruler is a good metaphor at all. The ruler begins with the *first* centimetre, not the zeroth. And the first centimetre - that is, centimetre 1 - starts at zero and ends at one. There is unfortunately no way to reconcile these concepts. The ordinal number words (and equivalents in other languages) predate the invention of the number zero by millennia. – Steve Jul 25 '22 at 18:13
8

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.

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 1
    Same for polynomials: p(x) = a₀ x⁰ + a₁ x¹ + a₂ x² + … + aₙ xⁿ. – Sasha May 06 '18 at 06:30
  • I think this is my favorite example, and moreso because it's likely to come up in an intro computing course before any other use-cases (arrays, etc.). It connects to basic knowledge students should already possess, so I've come to highlight it and foreshadow that we'll be using that a lot in later topics. – Daniel R. Collins Sep 30 '22 at 16:06
4

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

ncmathsadist
  • 2,319
  • 7
  • 14
  • This is also true for anything that is measured. In the end I realised that zero indexing is not counting; it is measuring. – ctrl-alt-delor Oct 01 '22 at 13:52
3

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.)

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 1
    In the U.S. there would be 'K' and 13 would mean college, 'K' has been around for quite a while -- everything else is the same! – JosephDoggie Sep 14 '18 at 19:55
  • 1
    @JosephDoggie In UK years 12 and 13, can be college, but some(may be most) schools, have a 6th form. This Does the same as the early college years, but at a school. After these 2 years, a lot of pupils go on to university (or work, or more college). – ctrl-alt-delor Sep 15 '18 at 10:01
  • In the US, there's also sometimes Pre-K, which I guess would be -1. – Solomon Ucko Jan 12 '19 at 00:26
  • @SolomonUcko same in UK, (I love -1 indexed arrays) – ctrl-alt-delor Jan 12 '19 at 09:22
3

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).

Daniel R. Collins
  • 1,252
  • 1
  • 6
  • 14
2

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). 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). If we use slot 6 and the TV companies finally add a 6th channel, then we will have to move it, so if the TV has a slot zero, then we put it in slot there.


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

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 2
    The US had a channel 1 at some point but it was repurposed very early on. TV channels started at 2. Zero was right out. –  Jun 15 '17 at 19:40
  • This numbering system was far from universal on UK TVs. A Hitachi model we had in the early 90s had 12 presets, but they were numbered up from 1 to 12. Some models I encountered later c.2000 would treat channel 0 as the AV/SCART input, but only a subset did this. – Kaz May 29 '22 at 14:07
  • @Kaz. True, I have updated the answer. – ctrl-alt-delor May 29 '22 at 17:44
2

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.

haley
  • 121
  • 2
  • Counting 12,1,2,3,4,5,6,7,8,9,10,11 is what is strange. Measuring from 0 is, (what is a good word for this, oh yes) measuring. – ctrl-alt-delor Jul 01 '20 at 21:35
  • Nice note about Japanese TV. However the rest is already covered in other answer. If you were to write about just Japaneses TV, then I would upvote. – ctrl-alt-delor Aug 30 '20 at 14:20
  • 1
    In Japan, they also use the implied modulo system, where it's common to indicate hours with numbers 24 or greater. For example, a bar might be open from 20 till 26. It makes it clear that the closing time is past midnight. I love that system! – Kuba hasn't forgotten Monica Aug 31 '20 at 17:10
2

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.

  • 3
    There was no your zero, therefore the end of a century ends in 00. 2000 was the last year of the 20th century. Most people get this wrong, the rest of us let it pass for a year, then have a 2nd party. – ctrl-alt-delor Jun 15 '17 at 21:42
  • 4
    I sometimes say "oneth" to avoid the ambiguity of "first". – Ellen Spertus Jul 27 '17 at 23:00
  • 4
    @ctrl-alt-delor actually, it’s the perfect example of what a mess is created when not using index zero. ”Most people get this wrong” by intuitively assuming that a century should start with year zero and end with year 99 and are “wrong”, because there was no year zero. But we still live in the 21st century whose index (year number) starts with a 20 (except for the last one) and the third millennium whose index (year number) starts with a two (except for the last one). And if that one guy was truly born 24.12.1, your 2nd party was wrong as well (otherwise, that number is totally meaningless). – Holger Sep 06 '18 at 11:55
  • 2
    @ctrl-alt-delor: You are correct. However, this 0-based system is actually used to express the age of a person, and people are not known to struggle with that. The difference is that when you're at "age 0", we omit the year count altogether: "He is 3 months old", not "He is 0 years and 3 months old". When you 0-index, and you're at index 0, that often entails deferring to a more precise (non-0) measurement. – Flater Sep 18 '18 at 06:33
  • 1
    @Flater yes you bring up an interesting point. In Europe and US, we measure age, so 3 years old, means that you are between 3 and 4 years old, that is have been alive 3 years, but no more than 4 (Well maybe an extra ¾ day, see leap year). In some parts of the world, they say what year you are in. Therefore a new born is 1, (in 1st year). This is similar to school year, before we added year zero (K in US, R in UK). In any respect the systems are all self consistent. but can result in an out by one error if the 2 people communicating are using a different system. – ctrl-alt-delor Sep 18 '18 at 07:11
  • @ctrl-alt-delor so the year zero was part of the -1th century? Or was the first century 101 years long? That's a cool fact. – W. Vrielink Jan 25 '19 at 13:31
  • 1
    @Karnat Good question. No there rely was no year zero, I see my comment was not clear, but not only was the first year year 1, the year before was year -1 (no year zero). The person that invented it, did not know about zero. So we get -3, -2, -1, 1, 2, 3. Dates and time are hard https://www.youtube.com/watch?v=-O4mYiP2zPQ https://www.youtube.com/watch?v=-5wpm-gesOY – ctrl-alt-delor Jan 26 '19 at 09:17
1

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.” — https://en.wikipedia.org/wiki/Thermodynamics#Laws_of_thermodynamics

  • 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 https://en.wikipedia.org/wiki/Laws_of_thermodynamics Text is available under the Creative Commons Attribution-ShareAlike License

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 2
    Similarly, [Asimov's Laws](https://en.wikipedia.org/wiki/Three_Laws_of_Robotics#Zeroth_Law_added) start from zero (although chronologically, the zeroth law was added later). – Aurora0001 May 27 '17 at 10:18
  • 1
    @Aurora0001 I added in a bit on asimov. (also I think you should make an answer on asimov) – ctrl-alt-delor Jun 04 '17 at 07:50
1

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 https://www.gnu.org/philosophy/free-sw.en.html (Creative Commons Attribution-NoDerivatives 4.0 International License).

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • 1
    You are missing 5 freedoms. And the fact that a bunch of computing folks used an 0 indexed array as is kinda... expected. OP is looking for non-computing examples, like military time and people's age (as mentioned in other answers/comments) – ivanivan Jan 23 '18 at 14:26
  • 1
    @ivanivan can you tell us about the 5 freedoms, I know not of this. And added answer on 24hour time. – ctrl-alt-delor Jan 23 '18 at 17:01
  • 1
    the freedoms you list are from the Free Software Foundation - Stallman and co. However, the Open Source Definition lists other requirements/freedoms needed for a license to be considered Open - https://opensource.org/osd-annotated. Remember, Stallman insists that all software be free, the Open Source Initiative wants as much as possible to be free, but not at the expense of extremism – ivanivan Jan 23 '18 at 19:57
  • @ivanivan the Free Software foundation also have a longer version: these 3 points are only a summary. The freedoms in the rest of the [Free Software definition](https://www.gnu.org/philosophy/free-sw.en.html), and the [Open Source definition](https://opensource.org/osd-annotated) do not add any extra freedoms. They only add clarification. The Free Software definition has 3 levels: the name "Free Software" (where free refers to freedom not price), the 4 freedoms, and the detailed explanation. The Open Source definition only has a detailed explanation, so is harder to grok. – ctrl-alt-delor Aug 30 '20 at 14:15
1

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

RonJohn
  • 111
  • 4
  • 1
    @Buffy sorry. I assumed that CS Educators all know the light-switch analogy. – RonJohn Jan 15 '18 at 14:33
  • 1
    @Buffy ok. I added (a hopefully clear) explanation. – RonJohn Jan 15 '18 at 14:38
  • 2
    @Buffy interesting. This was *Standard Knowledge* 35 years ago when students had to learn pointer arithmetic and take at least one class in Assembly. – RonJohn Jan 15 '18 at 14:49
  • 1
    Welcome to CSEducators. Come back often. – Buffy Jan 15 '18 at 14:52
  • 1
    Using 0 and 1 for binary states is unrelated to the mathematical values of 0 and 1. We could instead use "nothing" and "something" and the entire field of logic would remain correct. This is why programming now favors `true` and `false`, instead of "a non-zero integer" and "a zero integer". It disambiguates logical evaluations from mathematical ones and prevents developers mistakenly assuming one for the other. – Flater Sep 18 '18 at 06:37
  • Maybe as a simpler example: while the logic (of an electrical device) links 0 to 0V, the same does not apply to e.g. an abstract logical statement ("all bald men wear hats"). 0 does not bind to any particular integer value. Similarly, setting a temperature switch to 0 does not inherently mean that it's now 0° (before you argue that a temperature switch is still electrical: non-electrical switches exist too!). There are only fringe cases in which the logical 0 corresponds to a mathematical 0. The logical 0 is not defined by the mathematical 0, their fringe correlation is coincidental. – Flater Sep 18 '18 at 06:39
  • I use the three light switches in my room to show binary counting... never occurred to me to use it for array indexes. Bravo. :-) – codingCat May 31 '22 at 14:16
1

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.

JosephDoggie
  • 111
  • 3
  • 1
    `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)` The core difference here is that the former denotes the distance between points, and the latter denotes the points themselves. 2017 and 2018 are two distinct years (points), but the timespan (distance) between NYE 2017 and NYE 2018 is _one year_. This does not actually answer why 0-based indexing is used, as you're simply comparing two inherently different things. (_"from 3 to 4"_ vs _"3 and 4"_) – Flater Sep 18 '18 at 06:27
  • One must use 0 as a base, however. – JosephDoggie Sep 18 '18 at 12:15
  • 1
    `One must use 0 as a base`. I don't quite agree, 0-indexing is not universally superior to 1-indexing. As I mentioned in my earlier comment, it depends on what you're actually expressing (points, the distance between them, ...). There are many cases where the 0th element is a literal "nothing", thus precluding 0 from being relevant (especially when pertaining to physical objects). – Flater Sep 18 '18 at 13:34
  • 1
    I think this is what is called a fence-post error: You have questions 3,and 4. These are the posts. It is an error in this case to count the fence panels ($4-3$). You are not measuring the distance between the posts (number of panels), you are counting the posts. See also inclusive and exclusive ranges. Some languages use inclusive lower and exclusive upper, as this choice has **less** problems than other choices. – ctrl-alt-delor Aug 30 '20 at 14:23
  • Note that in North American football, the "Goal Line" is the same as a zero-yard line, which is zero-based. For the math problems, you aren't doing problem 2, but if you subtract 4-2 = 2 you get the right answer. Thinking about 'how' this works is difficult, at least for me, and I have a Ph.D. in Electrical Engineering, focusing on computer simulations using eigen-spaces. – JosephDoggie Aug 31 '20 at 16:45
  • The 3-4 is not a subtraction it is a range (inclusive range). It is 3→4 or {3,4}. – ctrl-alt-delor May 29 '22 at 17:55
1

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

https://www.youtube.com/watch?v=SPQRNmXVP8s

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

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
1

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.

GL,

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
1

Since this question was posted, I have come to realise that a ruler is not a metaphor for this think. It is the think. Zero indexing is simply measuring the distance from the start. There are many examples of this in the other answers.

We need to not see the index as on ordinal number, but as the distance from the start.

ctrl-alt-delor
  • 10,635
  • 4
  • 24
  • 54
  • I'm surprised that it never occurred to me to use a rule for this exact reason. When I explain the concept in class, I say the address of the array is the location of the first position, and the index is the distance from that position. – codingCat May 31 '22 at 14:19
0

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.

  • While I agree in general. It turns out that there are many good examples. And that it is not counting, it is measuring (see other answers). I think I will use your last paragraph as advice for a lot of thinks. I have sometimes just shown students that what they think is normal is not the only way (e.g. base 12/24/60 clocks, so why not binary). – ctrl-alt-delor Sep 01 '20 at 06:39