Problem Solving - All Chapters (/communities/aspire-2016/course/problem-solving-6)
Home (/communities/aspire-2016) See Leaderboard
3.3.Linked Lists (/communities/aspire-2016/content/linked-lists-4)
Go to Doubts
Single Dimensional Array
An array data structure stores a number of elements of same kind in a specific order. Array elements are
accessed using an integer (subscript) to specify which element is required (although the elements may be of
almost any type). Arrays may be expandable or fixed-length. Let us consider some real world examples for
Most squash clubs operate a squash ladder (similarly chess clubs). This is physically a card with numbered
slits in. Each member of the ladder writes their name on a tabbed card that fits into the slots (as shown in Fig:
3.1). If you play someone higher than you on the ladder and beat them, you swap places, the aim being to be
the person at the top of the ladder. The labels on the slits thus give each player their current rank in the club.
The squash ladder is an array structure. All the entries are of the same kind: they are all names of squash
players. Each position is numerically labeled, so you can easily ask questions such as, who the current No 1 is
or who is three positions higher than me? The ladder also has a predetermined number of positions. If there
are more people wishing to be on the ladder than there are slots, a waiting list may be set up, or a second
(division) ladder may be created, but the original physical ladder cannot have new slots added as there is no
space. When a new person arrives who is known to be good, a new slot cannot be created in the middle of the
ladder to start them in a position close to their correct one. The best that could be done if this were required is
to shuffle each player down one position to create a gap. This would be time-consuming.
At sports events such as ice-skating (gymnastics and boxing are similar), marks are awarded by a panel of
judges. The judges sit in a line of seats, with the seat labeled by their country. Before technology took over, the
judges would hold up cards with their scores. On the television screen each skater's scores are given in a row,
again with the marks. This is another example of an array- a fixed size list of things of interest (such as scores)
each with a label to identify them (such as the country).
In ice skating scores, the "things" are thus numbers and the labels are letter pairs that indicate the countries of
the judges (as shown in Fig: 3.2).
A row of houses down one side of a street is also organized like an array. Each house is labeled by its postal
address: for example 1, 3, 5, 7, etc. assuming it is on the even side of the street in Hyderabad. When a
postman has a letter to deliver, they know where it goes from the number. The number is just a label; the actual
house is the thing it is labeling. In normal circumstances, new houses are not added in the middle. Once your
house is given a number, it is not changed.
A one-dimensional array such as the examples above is in many ways similar to a list. The difference is that
arrays are of fixed sizes, with each cell "named" by a subscript. An array consists of a fixed number of slots,
that things can be put in or taken out of. New slots cannot however be created. Since each element in the array
is referenced by a single subscript, it is called as one-dimensional array. The below example (Figure : 3.3) tells
how a list of marks scored by 10 students in one subject is represented by a one-dimensional array.
here, the name of the array is "marks". All the elements inside it are integers representing the marks of the
students. Usually an array is indexed as zero-based indexing; i.e. the first element of the array is indexed by
subscript of 0. In the above example (Figure : 3.3),
marks represents the marks obtained by the first student i.e., 70
marks represents the marks obtained by the second student i.e., 30
marks represents the marks obtained by the 10th student i.e., 45
In addition to one-dimensional arrays, we also have two-dimensional and three-dimensional arrays where the
elements are pointed by two and three subscripts respectively. These will come under the category of Multidimensional arrays, since we require multiple subscripts to refer an element in them.
A two-dimensional array data structure stores the elements in a rectangular form i.e., in rows and columns. See
the below real world example (Figure : 3.4).
If you observe the seating arrangement in a cinema theatre, you will find the seats arranged in rows and
columns. Here, a row is a horizontal list of elements i.e., seats in this example and a column is a vertical list of
elements. To address a seat, we need its row number i.e., in which row it is and it's column number i.e., in
which column it is present.
Observe this time table of 10th class examinations.(Figure : 3.5).
Here, 12 different subject's dates are mentioned. In each row, we have two columns for "Date of examination"
and "subject name". One row is providing a date on which test for a specific subject is going to be conducted.
Like this, we have the details for 12 subjects in 12 different rows.
The below example represents the monthly sales report of a particular company in four different countries India,
US, Germany and UK (Figure : 3.6).
Here, rows are representing the "months" and columns are representing the "countries". i.e.,
column - India
column - US
column - Germany
column - UK
row - January
row - December
sales represents sales made in India (country) in the month of January (month).
sales represents sales made in US (country) in the month of March (month) etc.,
For further reading you may refer to the below links
Misuse of 'Ask a Doubt' Section will be dealt as per the Terms & Conditions of Campus Commune
Note: Please do not use the doubts section for any quiz/quiz-content related queries.
Use the helpline (/feedbacks/new) ( ) located above in top right corner for problems/queries related to
Characters (including HTML): 0
Souvik Chanda (/users/ct20131048480) • about 16 days ago
For insertion and deletion, how will be the array elements will be shuffled?
Preeti Kumari (/users/ct20141176532) • about 1 month ago