Data Structure and Algorithm W3
Data Structure and Algorithm W3
An array is a data
structure used to
store multiple
elements.
2
Where do Arrays
used?
3
Example Code using Python
4
Types of Arrays
1. One Dimensional
Arrays
2. Two Dimensional
Arrays
5
One Dimensional Arrays
7
N=5
ar = [0]*N
print(ar)
8
2
dimensional
Arrays
9
Using 2D arrays/lists the
right way involves
understanding the
structure, accessing
elements, and efficiently
manipulating data in a two-
dimensional grid.
10
import numpy as np
print(arr)
print(type(arr))
11
import numpy as np
print(arr)
print(type(arr))
12
Array Methods
13
Method Description
Example
cars.append("Honda")
16
Removing Array Elements
You can use the pop() method to
remove an element from the array.
Example
cars.pop(1)
17
Removing Array Elements
use the remove() method to
remove an element from the array.
Example
cars.remove("Volvo")
18