We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Fundamentals of Algorithms (CS502)

Assignment#02

Total marks = 20

 Submission Deadline =10-01-2018

Lectures Covered:Thisassignment covers Lecture # 23 to 26.

Objectives:

Objectives of this assignment are:

  • To implement Activity Selection Algorithm in real life problems
  • Generation of Variable-length codes using Huffman Coding Algorithm

 

Instructions:

Please read the following instructions carefully before solving & submitting the assignment:

  1. The assignment will not be accepted after due date.
  2. Zero marks will be awarded to the assignment that does not open or the file is corrupt.
  3. The assignment file must be an MS Word (.doc/.docx) file format; Assignment will not be accepted in any other format.
  4. Zero marks will be awarded to the assignment if copied (from other student or copied from handouts or internet).
  5. Zero marks will be awarded to the assignment if the Student ID is not mentioned in the assignment file.

 

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

Please do not post queries related to assignment on MDB.


 

Question # 1:                                                     10Marks (5+5)

 

 

In the context of Activity Selection Problem, consider the following set of activities:

 

Activity

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

Start

Time

2

4

6

1

6

3

1

8

5

6

7

4

2

5

7

Finish Time

9

5

7

3

8

5

2

9

8

9

9

8

3

6

8

 

 

You are required to find the optimal solution (usingGreedy Algorithm) for the following two greediness approaches:

 

  1. Select the activities that start first and schedule them(5 marks)
  2. Select the activities that finish first and schedule them(5 marks)

 

 

Note:

No need to provide any pseudo/working code. Just provide the results for each greediness approach of the following two steps in the below mentioned tabular form:

  1. Sorted Activities
  2. Final Selected Activities

 

Activity

 

 

 

 

 

 

 

StartTime

 

 

 

 

 

 

 

Finish Time

 

 

 

 

 

 

 

 

 

 

 

 

Question # 2:                                                               10 Marks

 

Consider the following scenario in which a set of Alphabets along with their frequencies is given.  You are required to generate the output binary tree and find the Variable-length codes for the given Alphabets using the provided Huffman Coding Algorithm.

 

Total File Length: 210

Frequency table:

A

B

C

D

E

F

10

20

30

40

50

60

 

Huffman Coding Algorithm:

  1. Consider all pairs: <frequency, symbol>.
  2. Choose the two lowest frequencies, and make them brothers, with the root having the

combined frequency.

 

  1. Iterate.

 

 

 

Note:

No need to provide all the steps of the binary tree generation.  Only mention the Final Binary Tree and the Variable-length codes for the given Alphabets in tabular form.

Your solution should be strictly according to the below-mentioned template.

 

Solution Template:

Alphabets: A, B, C, D, E, F

Total File Length: 100

Frequency table:

A

B

C

D

E

F

45

13

12

16

9

5

 

Output Tree:

Letter to be encoded

A

B

C

D

E

F

Frequency

45

13

12

16

9

5

Variable-length code

 0

 101

100 

 111

1101 

1100 

 

 

 

 

Good Luck


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 12179

Attachments:

Replies to This Discussion

q2 complete kr lya 

q1 ky 1st part m problem hai bs

kahan py

just 5 mint tk mi ap ko check krwata hn koi id dye 

complete solution tu send kro

sai tou h... nai? kya ghalati h?

kl complete solution send kr dn ga

Fazal Bhai kal last date plz zara jaldi send kardeye ga Thank you

inbox me

fazal bhai kindly send me please faisalsheharyar@gmail.com

zeeshan.study.khi@gmail.com plz is per send karde Thank you

complete solution upload kr day plzz

Cs502 Question 2 correct answer uploaded

any mistake plz comments 

Attachments:

RSS

Looking For Something? Search Here

Latest Activity

Profile Icon+Anastasiya and iqra faiz joined Virtual University of Pakistan
22 minutes ago
AAESH ZEE replied to +M.Tariq Malik's discussion VU MSCS (MS Computer Science) Entry Test Past Papers
55 minutes ago
AAESH ZEE replied to +M.Tariq Malik's discussion VU MSCS (MS Computer Science) Entry Test Past Papers
55 minutes ago
AAESH ZEE replied to +M.Tariq Malik's discussion VU MSCS (MS Computer Science) Entry Test Past Papers
56 minutes ago
Mani Siddiqui BS VIII posted a status
"*_شراب پلا کر مجھے بے دین نہ کر ساقی *_مدہوش ہی کرنا ہے تو محفل میں ذکر یار کر دے."
1 hour ago
Mani Siddiqui BS VIII liked +++**Zuni khan**+++'s discussion ❤️❤️❤️Rasool (S.A.W) Farmaty Hain ❤️❤️❤️
2 hours ago
Mani Siddiqui BS VIII posted a status
"زندگی بڑی عجيب ہے کبھی گلزار سی کبھی بیزار سی"
2 hours ago
Mani Siddiqui BS VIII liked +++**Zuni khan**+++'s discussion ***** Meri Ujri Hui Basti *****
4 hours ago

HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.