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

Design and Analysis of Algorithms (Ict 2222)

The document is a question paper for the B.Tech IVth Semester Midterm Examination in Design and Analysis of Algorithms at Manipal Academy of Higher Education, scheduled for March 18, 2024. It consists of multiple-choice questions and descriptive questions covering various topics related to algorithms, data structures, and their complexities. The total marks for the exam are 30, with a duration of 120 minutes.

Uploaded by

chappri90
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 views4 pages

Design and Analysis of Algorithms (Ict 2222)

The document is a question paper for the B.Tech IVth Semester Midterm Examination in Design and Analysis of Algorithms at Manipal Academy of Higher Education, scheduled for March 18, 2024. It consists of multiple-choice questions and descriptive questions covering various topics related to algorithms, data structures, and their complexities. The total marks for the exam are 30, with a duration of 120 minutes.

Uploaded by

chappri90
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

Question Paper

Exam Date & Time: 18-Mar-2024 (10:45 AM - 12:45 PM)

MANIPAL ACADEMY OF HIGHER EDUCATION


B.Tech IVth Semester Midterm Examination March 2024
DESIGN AND ANALYSIS OF ALGORITHMS [ICT 2222]
Marks: 30 Duration: 120 mins.

MCQ
Answer all the questions. Section Duration: 20 mins

1) Consider the following array of elements 289,219,250,217,212,215,22,25,27,211,26,29, 300.What (0.5)


is the number of interchanges required to convert it into a max heap?

5 2 4 3

2) Consider the array A= {4,1,3,2,16,9,10,14,8,7}, After building max-heap from the array A, the depth (0.5)
of the heap and right child of root are -------- and ----------- respectively.

3,10 3,14 4,14


4,10

3) When the balance factor of X is 2 due to insertion of nodes at either B1 or B2, a rotation would result (0.5)
to

B2 is the left B2 is the left subtree of B1 is the left subtree of B2 is the right subtree of
subtree of Y right child of Z right child of Z left child of Z
4) How does a 2-3 tree balances when the root node has to be deleted? (0.5)

Swap of the elements Demotion (movement from Promotion of Deletion of one


in the subtrees of the higher levels to lower levels) of nodes from lower of the child
root the nodes levels nodes

5) Consider the following C program (0.5)

int main() {

int x, y, m, n;

Page 1 of 4
scanf ("%d %d", &x, &y); /* x > 0 and y > 0 */

m = x; n = y;

while (m != n)

if(m>n)

m = m - n;

else

n = n - m;

printf("%d", n); }

What does the program compute?

x + y using
x mod y using The greatest common The least common
repeated
repeated subtraction divisor of x and y multiple of x and y
subtraction
6) Consider the following pairs of functions f(n), g(n). Which pair the functions are such, that f(n) is (0.5)
O(g(n)) and g(n) is not O(f(n)) ?

f(n)=n3 g(n) = n2 log(n2 f(n)=log(n) g(n) = 10 f(n)=1 g(n) = log f(n)=n2 g(n) = 10n
) logn n logn

7) Consider the following array: A[]= {12, 11, 13, 5, 6}. Apply the insertion sort algorithm to sort the (0.5)
array. Assuming that the cost associated with each swap is 25 rupees, what will be the total cost of
the insertion sort when all the elements are sorted?

50
200 175 150

8) Which of the following analogies best represents the process of sorting the numbers (15, 3, 28, 10, (0.5)
6, 19, 25) in ascending order using bubble sort?

Sorting a deck of Arranging a list of Organizing a collection Placing a set of


shuffled playing books on a shelf by of various-sized boxes differently colored
cards by comparing repeatedly comparing on a shelf by comparing marbles in a jar by
adjacent cards and two adjacent books their sizes and comparing their colors
swapping them if and swapping them if rearranging them to and rearranging them
they are not in the they are not in ensure they are in to ensure they are in
correct order. alphabetical order. ascending order. rainbow order.

9) Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size 64. (0.5)
Which of the following most closely approximates the maximum input size of a problem that can be
solved in 6 minutes?

256 512 1024 2048

10) If one uses a straight two-way merge sort algorithm to sort the following elements in ascending (0.5)
order: 20, 47, 15, 8, 9, 4, 40, 30, 12, 17 Then, the order of these elements after the second pass of
the algorithm is

8, 15, 20, 47, 4, 9, 30, 8, 9, 15, 20, 47, 4, 12, 15, 20, 47, 4, 8, 9, 12, 4, 8, 9, 15, 20, 47, 12,
40, 12, 17 7, 30, 40 30, 40, 17 17, 30, 40

DESCRIPTIVE
Page 2 of 4
Answer all the questions.

11) Suppose a quick sort algorithm is applied for sorting n elements, and at level, the pivot element (2)
divides the array of size n into two subarrays of size (n/4) and (3n/4). Analyze the given scenario
and write the recurrence relation. Also, solve the framed recurrence relation using the substitution
method and identify which case (best/average/worst) this scenario belongs.

12) Prove or Disprove using formal definitions of asymptotic notations and limit theory (3)

is false

is true.

13) What does fun2() do in general? (3)

int fun(int x, int y){

if (y == 0) return 0;

return (x + fun(x, y-1));

int fun2(int a, int b){

if (b == 0) return 1;

return fun(a, fun2(a, b-1));

Also find its time complexity.


14) Consider a project with five tasks, namely A, B, C, D, and E. Task C should start only after the (3)
completion of both Task A and Task B, while Task D should start only after the completion of Task
C. Finally, Task E should start only after the completion of both Task C and Task D. create a
digraph representation of the scenario and apply topological sorting order to solve the problem.

15) Imagine your friend is trying to find a specific "key" among many keys with unique "patterns" on (3)
them. Develop an algorithm inspired by you to systematically search for the right key by comparing
its pattern and analyze the time complexity for the given problem.

16) The time required for dividing the main problem into sub-problems (Td ) and the time required for (3)
merging the solutions of the subproblems (Tm) are important in deciding the time complexity of an
algorithm that follows the divide-and-conquer approach. Apply your understanding from the divide-
and-conquer approach and establish the relation between Td and Tm (i.e., Td> Tm or Tm> Td or
Td=Tm) for the (i) Merge Sort (ii) Binary Search (iii) Matrix Multiplication.

17) The airline's flight operations department receives a daily list of upcoming flight departure times for (4)
various destinations. The flight operations department receives the following unsorted list of flight
departure times:

Flight 1: 04:00 AM to Paris

Flight 2: 10:00 AM to New York

Flight 3: 03:00 AM to London

Flight 4: 05:00 AM to Tokyo

Flight 5: 1:00 AM to Dubai

To enhance customer satisfaction, use the Balanced tree structure to get the sorted Departure
Page 3 of 4
Schedule. Further Discuss the time complexity of your solution.
18) Justify how the transform and conquer strategy helps to maintain the balance factor of either 0, -1, (4)
or 1 at every node during the insertion of the following elements: 3, 2, 1, 4, 5, 6, 7, 16, 15, 14 into a
binary tree.

-----End-----

Page 4 of 4

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