UrbanPro
true

Learn C++ Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why Indexing Should Start From Zero In Array ?

Sunil Yadav
30/06/2017 0 0

Why numbering should start at zero?

To denote the subsequence of natural numbers 2, 3, ..., 12 without the pernicious three dots, four
conventions are open to us
a) 2 ≤ i < 13
b) 1 < i ≤ 12
c) 2 ≤ i ≤ 12
d) 1 < i < 13

Are there reasons to prefer one convention to the other? Yes, there are. The observation that
conventions a) and b) have the advantage that the difference between the bounds as mentioned
equals the length of the subsequence is valid. So is the observation that, as a consequence, in
either convention two subsequences are adjacent means that the upper bound of the one equals
the lower bound of the other. Valid as these observations are, they don't enable us to choose
between a) and b) so let us start afresh.

There is a smallest natural number. Exclusion of the lower bound as in b) and d) forces for a
subsequence starting at the smallest natural number the lower bound as mentioned into the realm
of the unnatural numbers. That is ugly, so for the lower bound we prefer the ≤ as in a) and c).
Consider now the subsequences starting at the smallest natural number: inclusion of the upper
bound would then force the latter to be unnatural by the time the sequence has shrunk to the
empty one. That is ugly, so for the upper bound we prefer < as in a) and d). We conclude that
convention a) is to be preferred.

Remark The programming language Mesa, developed at Xerox PARC, has special notations for
intervals of integers in all four conventions. Extensive experience with Mesa has shown that the
use of the other three conventions has been a constant source of clumsiness and mistakes, and on
account of that experience Mesa programmers are now strongly advised not to use the latter three
available features. I mention this experimental evidence for what it is worth because some
people feel uncomfortable with conclusions that have not been confirmed in practice. (End of
Remark.)

When dealing with a sequence of length N, the elements of which we wish to distinguish by
subscript, the next vexing question is what subscript value to assign to its starting element.
Adhering to convention a) yields, when starting with subscript 1, the subscript range 1 ≤ i < N+1;
starting with 0, however, gives the nicer range 0 ≤ i < N. So let us let our ordinals start at zero:
an element's ordinal (subscript) equals the number of elements preceding it in the sequence. And
the moral of the story is that we had better regard after all those centuries zero as a most
natural number.

Remark Many programming languages have been designed without due attention to this detail.
In FORTRAN subscripts always start at 1; in ALGOL 60 and in PASCAL, convention c) has
been adopted; the more recent SASL has fallen back on the FORTRAN convention: a sequence
in SASL is at the same time a function on the positive integers. Pity! (End of Remark.)

The above has been triggered by a recent incident, when, in an emotional outburst, one of my
mathematical colleagues at the University not a computing scientist accused a number of
younger computing scientists of "pedantry" because as they do by habit—they started
numbering at zero. He took consciously adopting the most sensible convention as a provocation.
(Also the "End of ..." convention is viewed of as provocative; but the convention is useful: I
know of a student who almost failed at an examination by the tacit assumption that the questions
ended at the bottom of the first page.) I think Antony Jay is right when he states: "In corporate
religions as in others, the heretic must be cast out not because of the probability that he is wrong
but because of the possibility that he is right."

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Structure And Function
A computer is a complex system; contemporary computers contain millions of elementary electronic components.How,then,can one clearly describe them? The key is to recognize the hierarchical nature of most...

Polarization of Plane Waves
(a) Linear polarization A plane wave is linearly polarized at a fixed observation point if the tip of the electric-field vector at that point moves along the same straight line at every instant of time. (b)...

Scope And Methodology Of Economics: Micro Economics
Scope and Methodology of Economics: What is Economics? Who contributed wealth definition of economics? Who defined economics as “the study of the nature and causes of nations’ wealth or...
P

Praveen Pilassery

0 0
0

Why do pointers have a datatype?
Before we start with pointers you must know what is a variable and a datatype. int a; This is the basic line in every program in 'C' . It means that we are asking the compiler to give us 2 bytes of space...

Product Design
Product DesignThere are three Main Point to Be Consider To Start Product Design: Functionality Mechanism Assembly These point is important role in any prodct design start .like :- mechanical parts, plastics parts, Sheetmetal Part.
A

Acad Design Solutation

0 0
0

Looking for C++ Language Classes?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C++ Language Classes?

The best tutors for C++ Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C++ Language with the Best Tutors

The best Tutors for C++ Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more