0% found this document useful (0 votes)
3 views5 pages

2024 June Design and Analysis of Algorithms

This document is a question paper for the Design and Analysis of Algorithms course for B.Sc. (H) Computer Science, Semester IV. It consists of two sections, with Section A being compulsory and Section B allowing students to choose four questions. The paper covers various topics including sorting techniques, dynamic programming, graph algorithms, and complexity analysis.

Uploaded by

Vipul Rathore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

2024 June Design and Analysis of Algorithms

This document is a question paper for the Design and Analysis of Algorithms course for B.Sc. (H) Computer Science, Semester IV. It consists of two sections, with Section A being compulsory and Section B allowing students to choose four questions. The paper covers various topics including sorting techniques, dynamic programming, graph algorithms, and complexity analysis.

Uploaded by

Vipul Rathore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
[This question paper contains 8 printed pages. ] Your Roll No.............+ Sr. No. of Question Paper: 4057 H Unique Paper Code : 2342012401 Name of the Paper : Design and Analysis of Algorithms Name of the Course : B.Se. (H) Computer Science Semester : IV Duration : 3 Hours Maximum Marks : 90 Instructions for Candidates 1. Write your Roll No. on the top immediately on receipt of this question paper. to The paper has two sections. Section A is compulsory. Each question is of 5 marks. 3. Attempt any four questions from Section B. Each question is of 15 marks. E:T, 4057 2 Section — A 1. (a) Arrange the following sorting techniques in the increasing order of the number of comparisons that they would do in order to sort the data: fi die9y 12, 11} Justify your answer Insertion sort, Merge sort. Improved Bubble Sort (5) (b) What is G) (i) greedy-choice property? (ii) optimal substructure property? (c) Write the recurrence equation for solying 0-1 knapsack problem using dynamic programming. How is memoization technique used in solving the problem? (5) (d) Consider a directed graph G with one component. Can a vertex u of G end up ina depth-first tree containing only u, even though u has both incoming and out-going edges in G? Justify your answer with an example. (5) 4057 3 (e) Use Strassen’s algorithm to compute the product of the following matrices : (5) Ee a oo aes ua] — Ae (f) A sequence of n operations is performed on a data structure. The i operation costs i if i is an exact power of 2, and 1 otherwise. Use aggregate analysis to determine the amortized cost per operation. (5) Section — B 2. (a) Can 0-1 knapsack problem be solved optimally using greedy strategy? Justify your answer. (7) (b) “Suppose Y s, X. If X can be solved in polynomial time, then Y¥ can be solved in polynomial time.” Based on the above statement, which of the following statements are correct? If any statement is incorrect, write its correct version. (8) PUTO: 4057 4 () If Y cannot be solved in polynomial time, then X cannot be solved in polynomial time. (ii) Y is at least as hard as X. (ii) If X belongs to NP, then X is NP-complete problem, (8) 3. (a) What is an in-place sorting algorithm? Is heap sort an in-place sorting algo-rithm? Sort the following data using heap sort. 4,3; 7, 1, 8, 5, 9 (7) (b) Suppose there exists an O(n) time algorithm to find the S" smallest element in an array of size n. Sort the following data using quick sort assuming Sth smallest element as the pivot T, 3; 5; 1,2) 4, 6 Also, determine the time complexity of the algorithm. (8) 4. (a) Consider the following algorithm for finding an element t in a sorted array A of size n: (7) 4057 (b) 5 (a) 5 ternary_search(Array A, Index first, Index last, Element t) Array A is divided into 3 equal parts Let p and q be the index of the elements that divide A such that p < q if t = A[p] return p else if t < A[p] then ternary_search(A, first, p-1, 0). else if t = A[q] return q else if t < A[q] then temary search(A, p+l, q-l, 1). else ternary_search(A, qt], last, t) Write a recurrence equation for computing the time complexity of the above algorithm and Justify the equation obtained by you and also solve it. An implementation of radix sort uses heap sort instead of count sort as the intermediate sorting technique. Is radix sort still stable? Justify your answer with an example. (8) For the given directed acyclic graph, determine the topological ordering. (7) 4057 6 (b) Write an efficient algorithm to check if a given undirected graph has a cycle. Discuss the time complexity of your algorithm. (8) 6. (a) Solve the subset sum problem using dynamic programming for the set {4, 2, 9, 6} and intended sum 17. (7) (b) Let T be the Minimum Spanning Tree (MST) with cost C corresponding to a graph G(V, E). Suppose c(e) denotes the non-negative edge cost for an edge ¢ in E. In cach of the following cases, indicate whether T and C will change if the edge costs are replaced with: (8) 4057 7 (i) e(ey? (ii) 1 - c(e) Justify your answer. (a) Given a set of n numbers. write an algorithm to find the maximum and minimum element using divide and conquer strategy. Also, determine the time complexity. ) (b) Consider a department of the university with 60 teachers and 20 courses, The 8 administration department maintains the records such that each record contains the name of a teacher and the course he/she is teaching. A teacher name can be maximum 32 characters long and courses are coded as BCS101, MCS101, MCA101, etc. Each teacher may be teaching more than one course and one course may be taught by more than one teacher. Give a linear time algorithm to sort the teachers course wise, in alphabetical order Courses should also be reported in chronological order. For example, the sorted records must look like the following : (8) 4057 8 BCSI01 SNEHA BCSIO1 SWAPNIL BCS102 ANIL BCS102 BEENA BCS102 SNEHA MCAI01 AJAY MCAIOL AMARJEET and, so on (1500)

You might also like