Greedy Fractional Knapsack

CSC-325 · Semester V · Design and Analysis of Algorithms

Array ADT
0
45
1
48
2
54
3
22
4
33
5
69
6
68
7
99
8
78
9
14

Length

10

Comparisons

0

Writes

0

Index access is O(1) — that is why arrays beat lists for random reads. But inserting at the front shifts every element, costing O(n). Try inserting at index 0.