F2024 AOA Assignment 4 (Greedy Algorithm, Dynamic Programming)
F2024 AOA Assignment 4 (Greedy Algorithm, Dynamic Programming)
And Technology
Analysis of Algorithms
Assignment No: 4 Instructor: Mr. Mian Ahmed Shafiq
Session: Fall 2024 Due Date: 12th February, 2025
Section: Total marks: 50
1 4 C4 50
• Make sure that you read and understand each and every instruction. If you have any
questions or comments you are encouraged to discuss (only) with your colleagues and
instructor.
• In case of hand written assignment, take pictures and convert them into PDF format.
Upload PDF file on the LMS and submit the hand written form to class teacher.
• All the submitted evaluation instruments (quizzes, assignments, class work, exams, and the
project) will be checked for plagiarism.
• Later Submission and Plagiarism will be dealt as per university Policy
• Start early otherwise you will struggle with the assignment.
Note: Keep all your files. It will be required at any time of evaluation.
1
University of Management
And Technology
Question 1 [CLO 4] [25]
i. Find the shortest path through Kruskal, Prims and Dijkstra algorithm.
ii. Find the shortest path through Kruskal, Prims and Dijkstra algorithm.
iii. Solve the following using fractional knapsack algorithm and 0/1 knapsack algorithm.
a) You are given a set of items, each with a weight and a value. You have a knapsack with
a limited capacity. Your goal is to determine which items to include in the knapsack to
maximize the total value without exceeding the knapsack's capacity.
Knapsack capacity: 7
Item Weight Value
1 2 3
2 3 4
3 4 5
2
University of Management
And Technology
b) You are a treasure hunter who has stumbled upon a hidden cave filled with valuable
artifacts. However, your backpack has a limited weight capacity. You must choose
which artifacts to take to maximize their total value while staying within the weight
limit of your backpack.
Knapsack capacity: 10 kg
3
University of Management
And Technology
v. Solve the following by Huffman Encoding.
Character Frequency
a' 5
b' 9
c' 12
d' 13
e' 16
f' 45
Instructions:
i. Hard copy of assignment is required (Hand Written).
ii. Also submit the soft copy on LMS.
iii. Due Date is 12th February, 2025 Wednesday in office.