Lec09 11 Arrays
Lec09 11 Arrays
Algorithmic Thinking
Data Organization
Lists, Arrays
Organizing data
• Humans hate disorder
Is it easy to be remembered? No !!
Real
https://www.cemc.math.uwaterloo.ca/~slgraham/csgirls/Tutorial/Variables/variables.html
What if your application
demands a collection of data
to be processed?
Collection of data usually
comprises related information
myArray[0]=10
• Each element can be accessed through the name of the array and the
element’s index (consecutive number) placed in the brackets
• Each element can be accessed through the name of the array and the
element’s index (consecutive number) placed in the brackets
https://www.freecodecamp.org/news/data-structures-101-arrays-a-visual-introduction-for-beginners-7f013bcc355a/
1 Byte=8 bits
Array Memory representation
NAME OF THE ARRAY IS REGNO
REGNO variable is
FIRST ELEMENT OF ARRAY integer
MEMORY “it occupy 4bytes of
ALLOCATED TO memory for an
REGNO IS FROM SECOND ELEMENT OF ARRAY element of Array”
316 TO 328
Algorithm:
Step 1: Start
Step 2: Declare n, i
Step 3: Read input n from user
Step 4: Declare an array of size n, myArray[n]
Step 5: Initialize i=0
Step 6: Repeat
Step 6.1: myArray[i]=i
Step 6.2: i=i+1
Step 6: Until i==n
Step 7: Assign i=0 and sum=0
Step 8: Repeat
Step 8.1: Display myArray[i]
Step 8.2: i=i+1
Step 9: Until i==n
Step 1o: Stop
Read and print all the elements in an array
• Input: Array size, Array values
• Output: Sum of all elements in an array
Algorithm:
Step 1: Start
Step 2: Declare n, i
Step 3: Read input n from user
Step 4: Declare an array of size n, myArray[n]
Step 5: Initialize i=0
Step 6: Repeat
Step 6.1: Read array value from user and assign it to myArray[i]
Step 6.2: i=i+1
Step 6: Until i==n
Step 7: Assign i=0 and sum=0
Step 8: Repeat
Step 8.1: Display myArray[i]
Step 8.2: i=i+1
Step 9: Until i==n
Step 1o: Stop
Summary
Data organisation
• list
• array
• Array representation
• Memory representation
• Assigning value to array using loop construct
• Operations on array
Find the sum of all the elements in an array?
• Input: Array size, Array values
• Output: Sum of all elements in an array
Algorithm:
Step 1: Start
Step 2: Declare n, i, j, sum
Step 3: Read input n from user
Step 4: Declare an array of size n, myArray[n]
Step 5: Initialize i=0
Step 6: Repeat
Step 6.1: Read array value from user and assign it to myArray[i]
Step 6.2: i=i+1
Step 6: Until i==n
Step 7: Assign j=0 and sum=0
Step 8: Repeat
Step 8.1: sum=sum + myArray[j]
Step 8.2: j=j+1
Step 9: Until j==n
Step 10: Display sum
Step 11: Stop
To find player with maximum age from the
array of players age.
Real World Examples
• Digital Signal Processing
• Filter Design
• Convolution
• Auto-correlation
• Spectral Estimation
• Speech & audio processing
• Communication Engineering
• Digital Modulation and demodulation [m-QAM]
• Digital communication sub systems
• Lempel Ziv, LDPC, TURBO Codes
• Decoders, Viterbi Decoding
Real World Examples
• Control Systems
• State Space Representation
• State Feedback Controller
• Circuit Analysis
• Solving Linear Circuit Equations
• Image Processing
• Edge detection and filtering
• RF design
• Antenna array design
• Beamforming Weights