# CS502 Assignment 3 Solution 2022 - VU Answer

VU Answer Gives Perfect CS502 Assignment 3 Solution Fall 2021 PDF. It's a Complete Step by Step CS502 Assignment 3 Solution 2022 and Easy to Download PDF, CPP, and Word Solution File Below.

CS502 ASSIGNMENT 3 SOLUTION FALL 2021

Total Marks: 20

Due Date: 10 Feb 2022

Question 1:

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.

Solution:

 Bricks Weight (KG) Price Price / Weight Ratio 1 4 \$120 \$30 2 3 \$110 \$36.66 3 9 \$130 \$1.4 4 7 \$140 \$20 5 5 \$200 \$40 6 1 \$50 \$50 7 2 \$70 \$35 8 11 \$160 \$14.54 9 6 \$153 \$25.5 10 13 \$170 \$13.07

Weight(KG):

1+5+3+2+4+6+7+(11-6)

1+5+3+2+4+6+7+5

## 33KG

Price:

\$50 + \$200+ \$110+ \$70+ \$120+ \$153+ \$140+ (160/11*5)

\$50 + \$200+ \$110+ \$70+ \$120+ \$153+ \$140+ \$72.72

## \$915.72

Maximum Profit = \$915.72

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

Solution:

Question 2:

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 the frequency of characters.

2. Generate Huffman Tree

3. Write the code of every character

4. Required total no of bits

Solution:

Giving String “allamaiiii”

 Character Frequency a 3 i 4 l 2 m 1

2. Generate Huffman Tree

Solution: 3. Write the code of every character

Solution:

 Character Frequency Character code Character Bits a 3 10 (3*2) =6 i 4 0 (4*1) =4 l 2 111 (2*3) =6 m 1 110 (1*3) =3

4. Required total no of bits

Solution:

Required Total No of Bits = 19

Make sure you can make some changes to your solution file before submitting copy-paste solution will be marked zero.

If you found any mistake then correct yourself and inform me.

Before submitting an assignment check your assignment requirement file.

If you need some help and question about file and solutions.

CS502 Assignment 3 Solution 2022

CS502 Assignment No 3 Solution Fall 2021

CS502 Assignment 3 Solution Fall 2022

CS502 Assignment Solution 2022