FNP(A,w)
- Sort A by value largest to smallest
- total ← 0
- i ← 0
- while total < w and i < A.size do
- if A[i].size ≤ w-total
- Take all of the objects of this value
- total ← total + A[i].size
- else
- Take w-total objects of this value
- total ← w
- i ← i + 1
PRIM(G=(V,E),w,r)
- for each v ∈ V do
- key[u] ← ∞
- π[u] ← NIL
- key[r] ← 0
- Q ← V
- while Q ≠ ∅ do
- u ← Q.extract_min()
- for each v ∈ Adj(u) do
- if v∈ Q and w(u,v) < key[v] then
- π[v] ← u
- key[v] ← w(u,v)