End Semester Examination (2 Yr. COE/CSE) : Thapar Institute of Engineering & Technology
End Semester Examination (2 Yr. COE/CSE) : Thapar Institute of Engineering & Technology
Q.1 (a) You are a team member responsible for enhancing the efficiency and reliability of an urban (5) CO3 L6
bike-sharing system. The city is represented as a graph, with bike stations serving as vertices
and bike lanes connecting them as edges. Your primary objective is to design an algorithm for
bike lane maintenance that ensures every bike lane is traversed exactly once by a maintenance
crew, which conducts station checks for maintenance needs and redistributes bikes if necessary.
(b) Suppose you are flying by Vistara Airlines from New Delhi to Tokyo, and you know the weight
(7+3) CO2 L3
restriction for cabin baggage, which is 7 kg. Additionally, the items you carry are unique, each
with different weights and values, as shown in Table 1. However, the combined weight of all the
items exceeds 7 kg, so you must inform the customs officer to retain the items with less weight
but higher value. Each item is either allowed to be taken in baggage or not carried. Your primary
objective is to carry the items with maximum value in your cabin baggage without surpassing
the baggage limit.
Table 1
Items Smartphone Tablet Power bank Laptop
Weights 3 4 2 5
Values 40 50 10 70
i) Which items will be carried in your cabin bag? Write the recursive equation and show
your calculations with the help of dynamic programming.
ii) How would your answer vary if greedy programming is used to select the items for filling
your cabin bag? Justify your answer with proper reasoning.
Q.2 (a) You are organizing a fundraising event for your local charity. You have a list of potential (8) CO2 L3
donors, each willing to contribute a certain amount of money. The potential donor contributions
are {5K, 6K, 10K, 11K, 16K}. However, you want to find out all the possible combinations of
donors whose contributions sum up to a target amount of 21K to efficiently reach your
fundraising goal. Show the state space tree to find all possible combinations of donors whose
contributions sum up to the target amount using the backtracking technique by clearly
specifying the pruning conditions on the state space tree.
(b) Given a wall of length 𝑊 and two shelves of length 𝑚 and 𝑛, we are tasked with fitting the (3) CO1 L4
wall of length 𝑊 with shelves of length 𝑚 and 𝑛 so that the space left empty (which can't be filled
with shelf) is to be minimized, and if possible the solution having larger number of longer
shelves is preferred as longer shelves are the cheaper ones. However, cost is still secondary in
our adventure of minimizing the cost, we should be more worried about minimizing the empty
space (if possible it should be zero). Design a greedy algorithm for this problem.
(c) Differentiate between Las Vegas and Monte Carlo randomized algorithms with the help of an (4) CO4 L1
example.
Page 1 of 3
Q.3 (a) Imagine a warehouse floor laid out in a grid pattern, awaiting the deployment of N (10) CO2 L2
autonomous robots assigned to collect items from various locations and deliver them to
designated destinations. The challenge here is to ensure that no two robots collide or interfere
with each other's paths while navigating the warehouse. The two robots collide if they occupy
the same row, column, or diagonal. Each cell in the grid represents a possible position for a robot.
To tackle this logistical puzzle, you decide to use the Backtracking approach to find a valid
arrangement for the N robots within the warehouse. Design a pseudo code or algorithm for this
problem using the Backtracking approach. Also, apply your algorithm to find one of the possible
solutions for 𝑁 = 4. You need to show the function calls while applying your algorithm. What
will be the worst-case time complexity of your algorithm?
(5) CO3 L6
(b) TIET has a summer school session that offers eight Table 2
courses (A-H). An "X" in Table 2 shows which courses have A B C D E F G H
students in common. There are time slots available (9:00 to A X X X
12:00 p.m.) each day (Monday, Tuesday, Wednesday, B X X X X
Thursday, Friday, Saturday and Sunday) to schedule final C X X X X X X
exams. TIET wishes to schedule the eight final exams over D X X X X
as few days as possible without creating conflicts for the E X X X X
students scheduled to take them. Having more than one F X X X X X X
exam scheduled on the same day is fine as long as the G X X X X
courses do not have any students in common. Find the H X X X
complete schedule of the exams. Show the steps involved
in finding the schedule. Is it P or NP problem?
Q.4 (a) Given a text "ABCCDDGCDD" along with a pattern "CDD", determine the location(s) of the (7) CO4 L3
pattern within the text by utilizing the Rabin Karp algorithm. Let 𝑑 be the number of characters
in the input set {A, B, C, .., J}. Further, choose 𝑞 as 13 in the computation to ensure that all
calculations can be carried out using single-precision arithmetic. Assign a numerical value to the
characters in the input set {A, B, C, .., J} as {1, 2, 3, .., 10}. Show all the intermediate calculations.
(b) Goods will be transported from a warehouse to 4 distribution centers: Ahmedabad, Bombay, (8) CO3 L3
Chennai, and Delhi, and finally to the market. The maximum number of goods that can be
transferred from the warehouse to Ahmedabad is 7 units, and to Delhi is 4 units; from
Ahmedabad to Bombay is 5 units; from Ahmedabad to Chennai is 3 units; from Delhi to
Ahmedabad is 3 units; from Delhi to Chennai is 2 units; from Chennai to Bombay is 3 units; from
Chennai to market is 5 units, and from Bombay to market is 8 units. This network configuration
facilitates the efficient flow of goods from the central warehouse through the distribution
centers to the final market destination. You need to find the maximum units of goods that can be
transported from the warehouse to the market, showing all the intermediate stages of the
residual graph. You need to select warehouse Delhi Ahmedabad Chennai market as
the first augmented path in the flow network.
Q.5 Imagine you are tasked with surveying a set of 4 landmarks in a (10+3 CO4 L2
national park. A graph of these landmarks is shown in Figure 1, +2)
where the graph edges represent the distance between each
landmark. You need to determine the most efficient route to visit each
landmark exactly once and return to the starting point 'A.' You
decided to apply two different algorithmic approaches:
i) Least Cost Branch-and-Bound (LCBB)
ii) 2-Approximation
You need to calculate the tour's total cost and path for both
approaches by showing all the intermediate steps and state space
tree for LCBB. Also, compare and contrast both LCBB and the 2-
Approximation algorithms in terms of solution optimality and
Figure 1
computational complexity (P, NP, NP-hard or NP-complete problems).
Page 2 of 3
Bloom's Level wise Marks Distribution
4
10
0
3
25
33
24
20 18
16
12
8
3
4
0
CO1 CO2 CO3 CO4
Page 3 of 3