You are on page 1of 3

Assignment No.

03
Total Marks: 20
Fall 2021
CS502- Fundamentals of Algorithms Due Date: 10-02-2022

Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
 The assignment is submitted after due date.
 The submitted assignment is other than MS Word file.
 The submitted assignment does NOT open or file is corrupted.
 The assignment is copied (from other student or ditto copy from handouts or internet).

Uploading instructions
For clarity and simplicity, you are required to upload/submit only one .doc/docx file.

Objectives
The objectives of this assignment are;

 To make you familiar with Knapsack using Greedy Approach.


 To make you familiar with Huffman encoding and tree.

For any query about the assignment, contact at CS502@vu.edu.pk

Good Luck!

Total Marks: 20

Question No. 1 Marks 10


A thief enters in a Gold shop carrying knapsack (bag). Knapsack (bag) capacity is 33KG of weight. The shop has
only 10 gold bricks; each brick has a specific weight and price. Now, the thief’s dilemma is to make such a
selection of bricks that it maximizes the profit (i.e. total price) without exceeding the knapsack (bag) weight.
You are required to do the following task:

1. Help the thief for the selection of bricks using greedy method for getting maximum profit.

2. Which approach will be used for this scenario (write only name)?

Bricks Weight (KG) Price


1 4 $120
2 3 $110
3 9 $130
4 7 $140
5 5 $200
6 1 $50
7 2 $70
8 11 $160
9 6 $153
10 13 $170

Question No. 2 Marks 10


A well-known Network Solution company that deals with large volumes of data over the network wants to use a
data compression technique that reduces the coding redundancy without loss of data quality. For trial/test
execution the company has decided to use Huffman encoding algorithm to encode the given string "allamaiiii”
before transmitting over the network.

You are required to do the following task:

1. Calculate frequency of characters.

2. Generate Huffman Tree

3. Write the code of every character

4. Required total no of bits

Lectures Covered: Lecture No. 23 to 30.


Deadline: Your assignment must be uploaded / submitted on or before 10-02-2022.

You might also like