Professional Documents
Culture Documents
Fall 2023 - CS502 - 2 - SOL
Fall 2023 - CS502 - 2 - SOL
02 (Solution)
Total Marks: 20
Fall 2023
CS502- Fundamentals of Algorithms Due Date: 10-01-2024
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;
Good Luck!
Question No. 1 Marks: 10
The following Graph shows the road connections among four cities labeled as A, B, C, and D. Your task is to
create both an adjacency matrix and an adjacency list to accurately represent it.
C
Answer:
Question No. 2 Marks: 10
Consider the string “babcbda”. You are required to do the following tasks:
1. How many Bits are required to encode the above string using 8-bit ASCII?
2. Calculate the frequencies of each character and draw a Huffman Encoding tree to fill the following table.
3. How many Bits are required to encode the above string using variable length codes (Prefix Code).
Answer:
1. Total bits are required to encode the above string using 8-bit ASCII = 7*8 bits = 56 bits
2.
a 2 10
b 3 0
c 1 110
d 1 111
Deadline: Your assignment must be uploaded / submitted on or before January 10, 2024
Total Marks: 20