CSE 220 Week 1
CSE 220 Week 1
Mushtari Sadia
Introduction
Faculty Name: Mushtari Sadia (MIS)
Consultation Hours:
Wednesday: 9:30AM-1:45PM
Thursday: 9:30AM-10:40AM
Room: UB-80601
1. Definition of an Array
2. Properties of an Array
3. Operations on an Array
Linear Array
Linear Array
Linear Array - Properties
1. Dimension
2. Index
3. Length
4. Single Type
Dimension
Dimension
Dimension
Linear Index =
Multidimensional Array Index -> Linear Index
Linear Index =
Multidimensional Array Index -> Linear Index
Linear Index =
Multidimensional Array Index -> Linear Index
Linear Index =
Multidimensional Array Index -> Linear Index
Linear Index =
Multidimensional Array Index -> Linear Index
imagine you have a 4D array with dimensions 4x3x5x6, named box
Linear Index = ??
Linear Index -> Multidimensional Array Index
Imagine you have a 3D array with dimensions 4x4x8.
What are the multidimensional indexes of the element stored at
location 111?
Find x,y,z
Linear Index -> Multidimensional Array Index
Imagine you have a 3D array with dimensions 4x4x8.
What are the multidimensional indexes of the element stored at
location 111?
= 111
Linear Index -> Multidimensional Array Index
Imagine you have a 3D array with dimensions 4x4x8.
What are the multidimensional indexes of the element stored at
location 111?
Linear Index = x * (4*8) + y*8 + z where 0 <= x <= 3, 0 <= y <= 3 and
0 <= z <= 7
= 111
Linear Index -> Multidimensional Array Index
Imagine you have a 3D array with dimensions 4x4x8.
What are the multidimensional indexes of the element stored at
location 111?
Linear Index = x * (4*8) + y*8 + z where 0 <= x <= 3, 0 <= y <= 3 and
0 <= z <= 7
= 111
Remember that indexing starts from 0
in each dimension!
Linear Index -> Multidimensional Array Index
Imagine you have a 3D array with dimensions 4x4x8.
What are the multidimensional indexes of the element stored at
location 111?
Linear Index = x * (4*8) + y*8 + z where 0 <= x <= 3, 0 <= y <= 3 and
0 <= z <= 7
= 111
Remember that indexing starts from 0
in each dimension!
Quotient
4*8 =
x=3
Remainder
Linear Index -> Multidimensional Array Index
Linear Index -> Multidimensional Array Index
Practice
Find the dimension of 96, 107, and 60 of the linear
index.
Circular Array/Buffer
Indexing A Circular Array
Assume the capacity/length of a circular array, named buffer, is 10.
a = buffer[(9 + 1) % 10]
= buffer[0]
Indexing A Circular Array
This works for going leftwards also.
For example, if you ask for the element that is two steps left of the element at
index zero; then you do the following:
a = buffer[(0 - 2) %10]
Self Study