Beruflich Dokumente
Kultur Dokumente
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
List: Construction
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
List: Implementation
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
Step 2: copy the items from original array to the new array.
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
More later...
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
List: Extending
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
10
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
11
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
12
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
13
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
14
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
15
List: Slices
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
16
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
17
Worst Case
v = list()
len(v)
v=[0]*n
v[i] = x
v.append(x)
v.extend(w)
v.insert(x)
v.pop()
traversal
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Worst Case
v = list()
O(1)
len(v)
O(1)
v=[0]*n
O(n)
v[i] = x
O(1)
v.append(x)
O(n)
v.extend(w)
O(n) or O(n + m)
v.insert(x)
O(n)
v.pop()
O(n)
traversal
O(n)
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
20
Amortized Analysis
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Append Example
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
j=0 2
< 2n O (n)
n
i=1 1=n
j
2
j=0 +n
O (1)
2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
Chapter 2: Arrays
23