Algorithm Design and Analysis Lab
SWE · Final · Summer 26
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Daffodil International University
Department of Software Engineering
Faculty of Science & Information Technology
Lab Final, Summer 2026
Course Code: SE215; Course Title: Algorithm Design & Analysis Lab
Sections & Teachers: 44I2 (AF)
Time: 35 Minutes
Marks: 40
Question 1: You are given n items, each with weight and value, and a knapsack with capacity W.
You must solve the Fractional Knapsack problem using a greedy approach.
Special Condition:
• Take the last two digits of your student ID
• If their sum is even → use Insertion Sort
• If their sum is odd → use Selection Sort
to sort items based on value/weight ratio (descending) before applying greedy selection.
• Show the calculation in the word file
Input:
• First line: Integer n
• Second line: n weights
• Third line: n values
• Fourth line: Capacity W
Output:
• Maximum obtainable value (fraction allowed)
Requirements:
• Must implement the specified sorting algorithm manually
Sample Input | Sample Output
3 | Maximum value = 240.00
10 20 30 |
60 100 120 |
50 |
Question 1: A student will enter their full student ID as an array of digits.
• If the sum of last 2 digits of the student ID is even, sort the array in ascending order using the Insertion Sort algorithm.
• If the last digit is odd, sort the array in descending order using the Insertion Sort algorithm.
Input:
• The digits of the student's ID as an integer array.
Output:
• Print the original array.
• Print the sorted array.
Example
Input
2 2 1 9 0 2 3 4 5
Last digit: 5 (Odd)
Output
Original Array: 2 2 1 9 0 2 3 4 5
Sorted Array (Descending): 9 5 4 3 2 2 2 1 0