Algorithms & Data Structures 05
Algorithms & Data Structures 05
Structures
Taibah University
1
Some applications of arrays
2
Arrays
3
Pros and Cons
● One limitation of arrays is that they are fixed size, which means you need to
specify the number of elements , Unless you're using a dynamic array.
● A dynamic array is an array with big improvement
● Strengths:
○ Fast lookups O(1)
○ Append takes O(n)
○ Insert and delete jus like normal array O(n) Delete index 3 Insert into index 3
○
4
When to choose arrays
5
Linked Lists
0 1 2 3 4
10 4 1 3
7
Linked list operations
8
When to choose Linked list
● When you need to store of elements but do not know their total amount in
advance.
● When your application need to often add or remove elements from the
beginning or from the end.
9
Lists
11
● Copy
○ N = l.copy()
○ A = list(l)
● Length
○ len(squares)
● Nested list
●
● [['a', 'b', 'c'], [1, 2, 3]]
12