0% found this document useful (0 votes)
6 views

hw-5

Uploaded by

kisilusherry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

hw-5

Uploaded by

kisilusherry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SCS 3313: Analysis and Design of Algorithms

Assignment 5

Date due: Monday, 20th January 2025


1. What is the greedy method?
2. You have chosen to you the greedy method to solve the following instance of the
activity selection problem:
i 1 2 3 4 5 6 7
si 0 1 2 4 5 6 8
fi 2 3 5 6 9 9 10
Describe the greedy algorithm that you would use to solve the problem. What is
its runtime complexity?
3. Consider the Fractional Knapsack Problem: ‘Given n items with values and weights
and a knapsack with capacity C. You may take fractions of each item and as many
of each item as you want. Find the selection of items that maximizes the possible
value that can be fit in your knapsack.’
Describe an efficient greedy strategy for this problem and prove that your greedy
choice strategy works.
4. Develop a Huffman coding over the following (node, frequency) pairs by running
the Greedy Huffman algorithm. Show each step of your iterations.

(a, 7), (b, 3), (c, 12), (d, 11), (e, 5)

What are the codes for each character?


5. A problem is solved in a time complexity of T (n) = 3nn and can be validated in
T (n) = 2n . Is it NP-complete or NP-hard. Explain
6. Explain P = NP
7. If we could solve an NP-complete problem in polynomial time, would all other
problems in NP necessarily be solvable in polynomial time? Briefly explain your
answer.

You might also like