0% found this document useful (0 votes)
7 views2 pages

Ucs415 MST e Mar25

This document outlines the structure and content of a mid-semester examination for B.E. students in Computer Science and Engineering at Thapar Institute, focusing on the Design and Analysis of Algorithms course. It includes various algorithm-related questions, such as time complexity analysis, majority element detection, greedy algorithms for tape utilization, customer compartment allocation, plagiarism detection, and identifying fertile land patches. The exam is scheduled for March 13, 2025, with a total of 75 marks and multiple questions requiring detailed solutions and intermediate steps.

Uploaded by

surendrabis49
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)
7 views2 pages

Ucs415 MST e Mar25

This document outlines the structure and content of a mid-semester examination for B.E. students in Computer Science and Engineering at Thapar Institute, focusing on the Design and Analysis of Algorithms course. It includes various algorithm-related questions, such as time complexity analysis, majority element detection, greedy algorithms for tape utilization, customer compartment allocation, plagiarism detection, and identifying fertile land patches. The exam is scheduled for March 13, 2025, with a total of 75 marks and multiple questions requiring detailed solutions and intermediate steps.

Uploaded by

surendrabis49
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/ 2

Roll Number:

Thapar Institute of Engineering & Technology


Department of Computer Science and Engineering
MID SEMESTER EXAMINATION

B. E. (2nd Yr. COE/CSE) Course Code: UCS415


13th March, 2025 Course Name: Design and Analysis of Algorithms
Thursday, Time- 11:00 AM To 1:00 PM Name of Faculty: Tarunpreet Bhatia, Sumit Sharma,
Time: 2 Hours, Max Marks: 75 (Weightage: 30) Shubhra Dwivedi, Nisha Chauhan, Ritesh Sharma, Kapil
Tomar, Neeraj Sharma, Shruti Aggarwal

Note:Attempt all Questions in sequence. Answer all sub-parts of each question at one place. Do mention
Page No. of your attempt at front page of your answer sheet. Assume missing data (if any).
Q.No Questions Marks CO BL
Q.1 (a) Determine the worst-case time complexity of the following recurrence relation. (5) CO1 L2
3 , ,__,
T(n) = ra T(ln) + n3 where T(1) = 1

(b) Consider the segment of code fun(int n), int fun(int n){ (5) CO1 L2
write the recurrence relation and calculate i f (n > 1)
the worst-case time complexity using {
recursion tree method. for(i = 1; i 5_ n; i = i+1)
printf ("%d',' 1);
return (n3 + fun(n/10) + fun(9n/10));
}I

(c) You are given a one dimensional array A = (2, 3, —8, 7, —1, 2, 3) that may contain
both positive and negative integers. You need to determine the subarray with the largest (5) CO1 L3
sum of the given array A using divide and conquer approach. Show the intermediate
steps.
Q.2 Assume you have an array A[1.. n] of n elements. A majority element of A is any element CO1 L6
occurring in more than n/2 positions (so if n = 6 or n = 7, any majority element will occur
in at least 4 positions). Assume that elements cannot be ordered or sorted, but can be
compared for equality only. You might think of the elements as chips, and there is a tester
that can be used to determine whether or not two chips are identical.
(a) Design an efficient algorithm based on divide and conquer approach to find a (3)
majority element in A if it exists otherwise return -1.
(b) Apply your algorithm on the array All = (1, 1, 2, 1, 3, 5, 1) and show the (4)
intermediate steps.
(c) Write the recurrence relation for the proposed algorithm and calculate the time (3)
complexity using master method.
Q.3 Let P1, P2 , ..., P, be a set of n programs to be stored on a tape of length 1. Program P, CO2 L3
requires a, amount of tape. If E a, .. 1, then clearly all the programs can be stored on the
tape. You need to assume E ai > I for the following tasks:
(a) Design an efficient greedy algorithm Algol to determine the maximum subset (5)
Q where Q refers to the subset containing the maximum number of programs.
Also, calculate the worst-case time complexity of your algorithm.
(b) Design another greedy algorithm Algol to determine the subset R which (5)
maximizes the tape utilization ratio i.e., (Ep u2 ai)/1.
(c) Given a set of 5 programs where a = [3, 1, 4, 2, 5] and 1 = 7, apply Algol and (5)
Algol and compare the tape utilization ratio for both the subsets Q and R.

Page 1 of 2
Q.4 The chef has recently opened a new restaurant which is divided into K compartments (10) CO2 L3
(numbered from 1 to K) and each compartment can be occupied by at most one customer.
Each customer i that visits the restaurant has a strongly preferred compartment pi, and if
that compartment is already occupied, then the customer simply leaves. Now obviously,
the chef wants to maximize the total number of customers that dine at his restaurant and
so he allows (or disallows) certain customers so as to achieve this task. Given a list of N
customers with their arrival time, departure time and the preferred compartment (as
shown in Table 1), you need to calculate the maximum number of customers that can dine
at the restaurant using greedy approach. Show intermediate steps. Assume that the ith
customer leaves just before di so that another customer can occupy that compartment
from d1 onwards.
Table 1
Customer i 1 2 3 4 5 6 7 8 9 10 11
Arrival Time ai 10:00 AM 12:00PM 1:00PM 12:30 PM 1:45 PM 11:30 AM 10:30 AM 11:00AM 1:15 PM 10:15 AM 1:40 PM
Departure Time di 12:30 PM 1:00 PM 2:30 PM 2:00PM 3:00 PM 12:30PM 11:45 AM 12:00 PM 1:45 PM 11:00AM 2:30 PM
Preferred
1 2 3 1 3 2 1 2 3 1 3
Compartment pi

Q.5 TIET aims to develop a plagiarism detection tool to identify s'milarities between CO2 L3
student assignments by comparing their content. The tool checks if one student's
submission has been copied or closely matches another student's work. It performs a
word-by-word comparison of both submissions and identifies sequences of words that
appear in the same order in both texts. Given submissions of 2 students:
S1 submission: "The quick brown fox jumps over the lazy dog".
S2 submission: "The fast brown fox leaps over lazy dog".
The tool detects "The brown fox over lazy dog" as longest common subsequence (LCS).
After comparing two submissions, the system will calculate a similarity score using the
formula:
Number o f words in the LCS * 100
Similarity Score =
Number of words in shorter submission
(a) Develop a bottom-up dynamic programming (DP) algorithm to calculate the (4)
number of words in the LCS of two submissions.
(b) Apply the algorithm to determine the LCS for the given submissions S1 and S2. (4)
You need to show the contents of DP table to get the final answer.
(c) Write the recursive code for LCS computation and show the recursive calls to (5)
highlight which words appear in the same order in both submissions.
(d) Determine the similarity score for the given submissions S1 and S2. (2)

Q.6 A space-tech startup is introducing AgriVision, an advanced system designed to help CO2 L3
farmers optimize crop yield by identifying the largest fertile land patches. Using high-
resolution imagery, the system maps farmland into a binary grid, where 1 represents
fertile soil suitable for cultivation and 0 indicates barren or unsuitable land. AgriVision
must efficiently detect the largest square of fully fertile land, enabling farmers to make
strategic planting decisions and enhance productivity.
(a) Write the recursive equation for determining the (3)
largest square of fully fertile land using dynamic
[1 0 1 0 0
programming.
1 0 1 1 1
(b) Apply the recursive equation to the binary grid Grid =
0 1 1 1 1 (7)
given in Fig. 1 which is obtained using high-
1 0 1 1 1
resolution imagery and determine the length of
largest square. You need to show the contents of Fig. 1
DP table to get the final answer.

Page 2 of 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy