Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
29 views40 pages

DSA-Lecture02 - ArraysII

Uploaded by

Engr Sameer Hani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views40 pages

DSA-Lecture02 - ArraysII

Uploaded by

Engr Sameer Hani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Data Structures

and Algorithm

SE-202
Fall 2024
Task
Find the
logical
error
Find number of elements that must be
moved if Brown, John and peters are
inserted into array NAME
Task
Consider the 25 × 4 matrix array SCORE. Suppose
Base(SCORE) = 200 and there are w = 4 words per
memory cell. Furthermore, suppose the programming
language stores two-dimensional arrays using row-
major order. Then the address of SCORE[12, 3], the
third test of the twelfth student, follows:
Multidimensional Array
• Two dimensional Array
– used to store information that we normally represent in table form
– Two-dimensional arrays, like one-dimensional arrays, are
homogeneous
– Examples of applications involving two-dimensional arrays include
• a seating plan for a room (organized by rows and columns), a monthly
budget (organized by category and month)

Intructor: Sadia Arshid, DCS&SE 29


Declaration of Two-Dimensional Arrays
• const int MAX_STUDENTS=40;
• const int MAX_LABS=14;
• int labScores [MAX_STUDENTS][MAX_LABS];
• Manipulation of a two-dimensional array requires the manipulation of
two indices

Intructor: Sadia Arshid, DCS&SE 30


• two-dimensional array may also be visualized as a one-
dimensional array of arrays

Intructor: Sadia Arshid, DCS&SE 31


• Accessing a Two-Dimensional Array Element
– labScores [1][9] = 90;
• Two-Dimensional Array Initialization
– int A[3][4] = {{8, 2, 6, 5}, //row 0
– {6, 3, 1 ,0}, //row 1
– {8, 7, 9, 6}}; //row 2

Intructor: Sadia Arshid, DCS&SE 32


• Three Dimensional Arrays
– Int Array[r][c][v]
– for (int row=0; row < 4; row++) {
• for (int col=0; col < 5; col++) {
– for (int ver=0; ver < 3; ver++) {
– M[row][col][ver] = row+col+ver; } } }

Intructor: Sadia Arshid, DCS&SE 33


Announcements

• Quiz next class.


• All contents till date

You might also like