Greedy Fractional Knapsack

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

Array ADT
0
98
1
51
2
69
3
53
4
21
5
71
6
31
7
73
8
25
9
80

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.