ANNA UNIVERSITY · REGULATION 2021
Important Questions
CS 3401 — ALGORITHMS
Fourth Semester · Computer Science and Engineering
Prepared from 4 previous year question papers (Nov/Dec 2024, Apr/May 2024, Nov/Dec 2023, Apr/May 2023). Every question was compared with the others of its unit; the ones asked more than once come first. "Most asked topics" shows in how many different exams a syllabus topic had a question.
UNIT 1Introduction
Most asked topics: Worst case and average case analysis (3/4) · Best case (2/4) · searching: linear search (2/4) · Algorithm analysis: Time and space complexity (1/4) · Asymptotic Notations and its properties (1/4) · binary search and Interpolation Search (1/4)
Part A · 2 marks
- 1.Define Time Complexity of an algorithm.(2)
Asked 2 times: Nov/Dec 2024, Apr/May 2023
- 2.What is recurrence relation?(2)
Asked in Nov/Dec 2024
- 3.State how the running time of an algorithm is measured.(2)
Asked in Apr/May 2024
- 4.Outline the significance of performing worst case analysis of an algorithm.(2)
Asked in Apr/May 2024
- 5.Define recursion relation.(2)
Asked in Nov/Dec 2023
- 6.Discuss the time and space complexity of insertion sort.(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Explain various complexity measures and the role of asymptotic notations towards algorithm analysis.(13)
Asked in Nov/Dec 2024
- 2.Describe Binary search and Interpolation search algorithm with an example. Give its respective complexity measures.(13)
Asked in Nov/Dec 2024
- 3.(i) Explain in detail about various asymptotic notations and it's properties. (ii) Use substitution method to show that T(n) = 2T(n/2) + n is O(n log(n)).(13)
Asked in Apr/May 2024
- 4.(i) With a suitable example, illustrate the time and space complexity analysis of binary search and linear search. (ii) Explain the working of naive string matching algorithm with ABCCDDAEFG as the text input and CDD as the search string.(13)
Asked in Apr/May 2024
UNIT 2Graph Algorithms
Most asked topics: Minimum spanning tree: Kruskal's and Prim's algorithm (2/4) · Dijkstra's algorithm (2/4) · Graph traversal: DFS (1/4) · Shortest path: Bellman-Ford algorithm (1/4) · Floyd-Warshall algorithm (1/4) · Network flow: Flow networks (1/4)
Part A · 2 marks
- 1.What is minimum spanning tree?(2)
Asked 2 times: Nov/Dec 2023, Apr/May 2023
- 2.Name the graph traversal techniques.(2)
Asked in Nov/Dec 2024
- 3.Differentiate indegree and outdegree.(2)
Asked in Nov/Dec 2024
- 4.List the data structures that are used for representing graphs.(2)
Asked in Apr/May 2024
- 5.What is a strongly connected graph? Give an example.(2)
Asked in Apr/May 2024
- 6.What is bipartite graph?(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.Write Kruskal's algorithm and to find the Minimum Spanning tree for the following graph [Figure: undirected weighted graph with vertices A to J; edges A-F 2, A-B 3, F-G 7, F-E 1, G-E 6, G-H 15, B-D 16, B-C 17, C-D 8, D-E 11, D-I 4, E-I 10, E-H 5, C-I 18, I-H 12, I-J 9, H-J 13](13)
Asked in Nov/Dec 2024
- 2.In the given graph, the vertex represents the city and edge represents the cost between the two vertices. Apply Dijkstra's shortest algorithm and find the Optimal cost to reach the destination. Also determine the Worst case time complexity of the algorithm. [Figure: directed graph with source s (0) and vertices t, x, y, z (each infinity); edges s->t 10, s->y 5, t->x 1, t->y 2, y->t 3, y->x 9, y->z 2, x->z 4, z->x 6, z->s 7](13)
Asked in Nov/Dec 2024
- 3.(i) Write the pseudocode for BFS and DFS traversals on the graph given below in fig. 12 (a) (i) and compare the time and space complexity of the two traversals. [Fig. 12 (a) (i): undirected graph with vertices 0 to 4; edges 0-1, 0-2, 1-2, 1-3, 2-4, 3-4] (ii) Find the Minimum Spanning Tree of the following graph in fig. 12 (a) (ii) using Kruskal's algorithm. [Fig. 12 (a) (ii): undirected weighted graph; edges a-b 4, a-h 8, b-c 8, b-h 11, c-d 7, d-e 9, d-f 14, e-f 10, h-i 7, i-g 6, h-g 1, g-f 2](13)
Asked in Apr/May 2024
- 4.(i) Given a graph and a source vertex in the graph, find the shortest paths from the source vertex 0 to all vertices in the given graph 12 (b) (i). [Fig. 12 (b) (i): undirected weighted graph with vertices 0 to 8; edges 0-1 4, 0-7 8, 1-2 8, 1-7 11, 2-3 7, 2-8 2, 2-5 4, 3-4 9, 3-5 14, 4-5 10, 5-6 2, 6-7 1, 6-8 6, 7-8 7] (ii) Using Ford-Fulkerson algorithm find the maximum possible flow in the network given below Fig 12 (b) (ii). [Fig. …(13)
Asked in Apr/May 2024
UNIT 3Algorithm Design Techniques
Most asked topics: Merge sort (3/4) · Quick sort (1/4) · Matrix-chain multiplication (1/4) · Greedy Technique: Elements of the greedy strategy (1/4)
Part A · 2 marks
- 1.Define Divide and Conquer approach.(2)
Asked in Nov/Dec 2024
- 2.List the elements of Greedy strategy.(2)
Asked in Nov/Dec 2024
- 3.What kinds of problems are solved using divide and conquer approach?(2)
Asked in Apr/May 2024
- 4.State the elements of greedy approach.(2)
Asked in Apr/May 2024
- 5.What is meant by principle of optimality?(2)
Asked in Nov/Dec 2023
- 6.Write down the steps to build Huffman free.(2)
Asked in Nov/Dec 2023
Part B · 13 marks
- 1.(i) Demonstrate divide and conquer approach by Performing quick sort on the following values. 44, 33, 11, 55, 77, 90, 40, 60, 99, 22, 88 (ii) Using Dynamic programming, Solve matrix chain multiplication problem.(13)
Asked 2 times: Apr/May 2024, Nov/Dec 2023
- 2.Apply Merge sort algorithm to sort the given set of numbers (40, 25, 69, 65, 31, 53, 86, 24, 55, 57, 19, 21, 16) and compute the Worst-case, Average-case and Best-case time complexity of the algorithm.(13)
Asked in Nov/Dec 2024
- 3.Produce Huffman tree for the following data and encode the data abbcddeef. [Table: Character - Frequency: a 5, b 9, c 12, d 13, e 16, f 45](13)
Asked in Nov/Dec 2024
- 4.(i) Solve the following problem using Greedy algorithm. Given activities with their start and finish times, select the maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity at a time. (ii) A character-coding problem. …(13)
Asked in Apr/May 2024
UNIT 4State Space Search Algorithms
Most asked topics: Travelling Salesman Problem (3/4) · Subset Sum Problem (2/4) · Knapsack Problem (2/4) · Backtracking: n-Queens problem (1/4) · Hamiltonian Circuit Problem (1/4)
Part A · 2 marks
- 1.Why is branch and bound approach found to be appropriate for solving travelling salesman problem?(2)
Asked 3 times: Apr/May 2024, Nov/Dec 2023, Apr/May 2023
- 2.Write the time complexity for solving n-Queens problem.(2)
Asked in Nov/Dec 2024
- 3.Define Optimal Binary search.(2)
Asked in Nov/Dec 2024
- 4.With an example, define Hamiltonian circuit.(2)
Asked in Apr/May 2024
- 5.Write short notes on graph colouring.(2)
Asked in Nov/Dec 2023
- 6.What is backtracking?(2)
Asked in Apr/May 2023
Part B · 13 marks
- 1.(i) Explain the steps in solving n-queens problem using backtracking approach. (ii) Solve the following subset sum problem using back tracking. Let S = {3,7,9,13,26,41}; d(sum) = 51.(13)
Asked 2 times: Apr/May 2024, Nov/Dec 2023
- 2.Apply Backtracking approach and determine whether the given graph can be colored using 4 colors with graph colouring techniques. [Figure: undirected graph with 12 vertices numbered 1 to 12](13)
Asked in Nov/Dec 2024
- 3.Consider the following graph. The vertex represents the city and edge represents the cost between the two vertices. A salesman starts from node 1, visit all the cities exactly once and return to the starting node. Justify that the algorithm that uses optimality principle produces an optimal tour cost to visit all cities. …(13)
Asked in Nov/Dec 2024
- 4.(i) Discuss briefly about the general method of branch and Bound approach and state how it differs from backtracking. (ii) Explain the branching mechanism in the Branch and Bound Strategy to solve 0/1 Knapsack problem.(13)
Asked in Apr/May 2024
UNIT 5NP-Complete and Approximation Algorithm
Most asked topics: NP-algorithms (2/4) · primality testing (2/4) · NP-hardness and NP-completeness (1/4) · Bin Packing problem (1/4) · Randomized Algorithms: concept and application (1/4) · randomized quick sort (1/4)
Part A · 2 marks
- 1.Give example for NP hard and NP complete problem.(2)
Asked 2 times: Nov/Dec 2024, Apr/May 2024
- 2.State the difference between tractable and non-tractable problems.(2)
Asked 2 times: Apr/May 2024, Apr/May 2023
- 3.List some applications of using Randomized algorithms.(2)
Asked in Nov/Dec 2024
- 4.Differentiate tractable and intractable problems.(2)
Asked in Nov/Dec 2023
- 5.Write an algorithm to find the kth smallest number.(2)
Asked in Nov/Dec 2023
- 6.State the bin packing problem.(2)
Asked in Apr/May 2023
Part B · 13 marks
- 1.Explain Polynomial time algorithms problems with an example.(13)
Asked in Nov/Dec 2024
- 2.Apply approximation algorithm for Travelling salesmen problem with suitable example.(13)
Asked in Nov/Dec 2024
- 3.(i) Show that if an algorithm makes atmost a constant number of calls to polynomial time subroutines and performs an additional amount of work that also takes polynomial time, then it runs in polynomial time. (ii) Show that the satisfiability of Boolean formulas in 3-conjunctive normal form (3- CNF) is NP-complete.(13)
Asked in Apr/May 2024
- 4.(i) Illustrate polynomial-time approximation scheme for the sum of subsets problem. (ii) Illustrate the working of Miller-Rabin randomized primality test.(13)
Asked in Apr/May 2024
PART CAny unit
Part C · 15 marks
- 1.Apply Ford Fulkerson algorithm for the following graph and determine the maximum flow in the graph. [Figure: flow network with source s, sink t and vertices v1, v2, v3, v4; edges s->v1 16, s->v2 13, v1->v2 10, v2->v1 4, v1->v3 12, v3->v2 9, v2->v4 14, v4->v3 7, v3->t 20, v4->t 4](15)
Asked in Nov/Dec 2024
- 2.Consider the given set of numbers (65, 70, 75, 80, 85, 60, 55, 40, 45). Apply Quicksort by using (i) First element as Pivot element (ii) Middle element as Pivot element.(15)
Asked in Nov/Dec 2024
- 3.(i) How many spurious hits does the Rabin-Karp matcher encounter in the text T = 3141592653589793 when Working modulo q = 11 and looking for the pattern P = 26. Briefly write about the processing time, worst-case running time and average-case running time of Rabin-Karp algorithm. (ii) With an example to show the best-case, worst-case and average case analysis of heap sort.(15)
Asked in Apr/May 2024
- 4.(i) Run the Bellman-Ford algorithm on the directed graph of figure 16 (b) (i) below using vertex s as the source and show the results after each pass of an algorithm. [Fig. 16 (b) (i): directed graph with s = 0 and t, x, y, z = infinity; edges s->t 6, s->y 7, t->x 5, x->t -2, t->y 8, t->z -4, y->x -3, y->z 9, z->x 7, z->s 2] (ii) With an example, Show that the cardinality of a maximum matching M in a bipartite graph G equals the value of a maximum flow f in its corresponding flow network G'.(15)
Asked in Apr/May 2024
- 5.Write and explain the Dijikstra's algorithm. Find the shortest path the following graph using Dijikstra's algorithm. [Figure: directed weighted graph; edges s->a 1, s->b 5, a->b 2, a->c 2, a->d 1, b->d 2, c->d 3, c->e 1, d->e 2](15)
Asked in Nov/Dec 2023
- 6.Solve the following instance of Knapsack problem by branch and bound algorithm. [Table: Item - Weight - Profit: 1 - 5 - $40; 2 - 7 - $35; 3 - 2 - $18; 4 - 4 - $4; 5 - 5 - $10; 6 - 1 - $2](15)
Asked in Nov/Dec 2023