0% found this document useful (0 votes)
33 views4 pages

(CSE221-12 & 13) Assignment 3 Question

The document outlines Assignment 3 for CSE221, focusing on algorithms such as topological sorting, greedy, and dynamic programming. It includes tasks related to football passing strategies, Huffman encoding, exam question optimization, and finding the longest common sequence between two strings. Each part requires detailed calculations and algorithmic approaches to solve the problems presented.

Uploaded by

lamiakabir2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

(CSE221-12 & 13) Assignment 3 Question

The document outlines Assignment 3 for CSE221, focusing on algorithms such as topological sorting, greedy, and dynamic programming. It includes tasks related to football passing strategies, Huffman encoding, exam question optimization, and finding the longest common sequence between two strings. Each part requires detailed calculations and algorithmic approaches to solve the problems presented.

Uploaded by

lamiakabir2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSE221 Section 12 & 13

Fall 2024 [MUNR]


Assignment 3

Part 1: Topological Sorting, SCC

1. As we all know, the Spanish National Football Team is notorious for their passing
football, especially their back passes. After their disastrous 2022 World Cup campaign,
The King of Spain made you the coach and declared that no back passes are allowed on
the field from now on till Spain scores 2 goals. However, they played dominantly and
scored 2 goals in no time. After scoring 2 goals, Spain changed their strategy and
started to back pass again incorporating 2 more players, the master of dark arts
Busquets and the young sensation Ansu Fati. These are the passes for the new
strategy
Passes

Simon → Cesar

Simon → Rodri

Cesar → Gavi

Gavi → Busquets

Gavi → Pedri

Gavi → Fati

Busquets →

Pedri Busquets

→ Rodri

Pedri → Morata

Fati → Pedri

Morata → Fati
Rodri → Pedri

Rodri → Cesar

a) Now, using a suitable algorithm, find out the largest group of players who can
pass the ball among themselves. For example, one such group can be (Fati,
Morata, Pedri) where Morata can pass to Pedri, Pedri can pass to Fati and Fati
can pass to Morata. It is important to keep in mind that the king will be
observing every step of the algorithm. Any discrepancies can lead you to lose
your job.

2.

Find the valid topological ordering of the above graph starting from vertex 0 using any
suitable algorithm. Show your work with proper details.
Part 2: Greedy & DP Algorithms

3. You are given the following tree generated by simulating the Huffman encoding
algorithm on a text message.
a) Write the encoding for each of the characters. Consider left to be 0, and right to
be 1 when traversing the tree.
b) Decode the following encoded message using the character codes you wrote on
question(i):
01001001111011110000101111011000101101100010111101110100110
110001111000101
4. You are now attending the CSE221 final exam and there is a limited time to solve
the questions. Each question requires a different amount of time and offers varying
marks. After answering some questions, you suddenly realized that only 6 minutes
remained. You aim to maximize the total marks you can score, given the constraints on
time.

Questions and their properties:


● Question 4: Time = 4 minutes, Marks = 7
● Question 5: Time = 2 minutes, Marks = 9
● Question 6: Time = 3 minutes, Marks = 10
● Question 7: Time = 5 minutes, Marks = 8
● Question 8: Time = 6 minutes, Marks = 12
● Question 9: Time = 1 minute, Marks = 3

a) If your faculty doesn’t give partial marks for incomplete answers, which
combination of questions maximizes your total marks without exceeding the
time limit? Hurry up, you need a quick, efficient approach—no time for brute
force. Show a full detailed calculation.
b) Fortunately, your faculty enters the hall and announces a new rule: partial marks
will be given for partially completed answers. If you can solve part of a
question, you’ll get marks proportional to the time you spend on it. For example,
solving half of a 4-minute question gives you half the marks.
Now, with this new opportunity, how does your strategy shift? How will you
maximize your score within the time limit, factoring in that you can now earn
something even if you don’t fully complete a question? Calculate the maximum
marks you can score with this fortunate announcement. Did you score more
than the previous scenario?
c) How does Dynamic Programming have a lower time complexity than brute force
or recursive solutions? Explain briefly.
5. You are given two strings, 'cbabdcb' and 'badcbc', and tasked with finding a common
sequence with the longest length. Initially, you considered a recursive solution, but
person 'X' suggested using a dynamic programming approach instead.

Find the longest common sequence using the approach proposed by person ‘X’.
Show the necessary simulation to find the answer.

You might also like