A greedy approach Pi/Wi를 내림차순으로 정렬한다.(Greedy) knapsack이 찰 때까지 item을 고른다. Implementation 1 Sort the item -> O(nlogn) Repeat the choice -> O(n) O(n+nlogn) = O(n logn) Implementation 2 Put the items in a heap -> O(n) Repeat the choice -> O(k logn) O(n+k logn) = ? Implementation2 방식으로 하면 k값에 따라 시간복잡도가 달라진다. 확실한 것은 가장 최악이 O(n logn)으로 Implementation1 방식보다 훨씬 효율적이다. Knapsack Example 2: n=6, W=10 Huffma..