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

JNTUH DAA Question Paper 2023

This document provides instructions for an examination in Design and Analysis of Algorithms. It includes 10 questions in Part A worth a total of 25 marks, and 6 questions in Part B worth a total of 50 marks. Students must answer all of Part A and choose one question from each unit in Part B. The questions cover topics like asymptotic notation, sorting algorithms, graph algorithms, dynamic programming, NP-completeness, and more. Students are asked to define terms, analyze algorithms, provide examples, derive complexity results, and solve algorithmic problems.

Uploaded by

rajsing00004444
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)
234 views2 pages

JNTUH DAA Question Paper 2023

This document provides instructions for an examination in Design and Analysis of Algorithms. It includes 10 questions in Part A worth a total of 25 marks, and 6 questions in Part B worth a total of 50 marks. Students must answer all of Part A and choose one question from each unit in Part B. The questions cover topics like asymptotic notation, sorting algorithms, graph algorithms, dynamic programming, NP-completeness, and more. Students are asked to define terms, analyze algorithms, provide examples, derive complexity results, and solve algorithmic problems.

Uploaded by

rajsing00004444
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

Code No: 135AF R16

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD


B. Tech III Year I Semester Examinations, January/February - 2023
DESIGN AND ANALYSIS OF ALGORITHMS
JN
(Common to CSE, IT)
Time: 3 Hours Max. Marks: 75

Note: i) Question paper consists of Part A, Part B.


TU
ii) Part A is compulsory, which carries 25 marks. In Part A, Answer all questions.
iii) In Part B, Answer any one question from each unit. Each question carries 10 marks
and may have a, b as sub questions.
H
PART – A
(25 Marks)
U
1.a) Define Big ‘Oh’ notation. [2]
b) Compare Quick Sort and Merge Sort. [3]
se
c) What is an articulation point in a graph? Give an example. [2]
d) Construct the state space tree for 4-Queens problem with bounding function. [3]
e) Write an algorithm for simple Union operation. [2]
d
f) What is Minimum Spanning Tree? Give an example. [3]
g) Write the difference between the Dynamic programming and the Greedy method. [2]
h) What is mean by state space tree? Give an example. [3]
pa
i) Define cook’s theorem. [2]
j) Draw the relation of P, NP, NP-Hard and NP-Complete. [3]

PART – B
pe
(50 Marks)

2.a) Sort the following data using Quick Sort and illustrate each step with appropriate figure
rs
for each iteration. [ 20, 12, 35, 15, 11, 19, 35 ]
b) Write the Recurrence relation and derive the best case complexity for the Quick Sort.
[5+5]
20
OR
3.a) Describe asymptotic notations Big Oh (O), Omega (Ω) and Theta (Ɵ) notations and show
their behavior using graphical representation.
b) Give the asymptotic bounds for the equation f(n)=2n3-6n+30 and represent in terms of Ɵ
23
notation. [5+5]

4. Generate the state space tree and find the solutions for the subset sum for N=7, m=35,
w={5,7,10,12,15,18,20} using back tracking approach. [10]
OR
5. Write an algorithm for Graph Coloring problem and explain with an example. [10]
6. Explain the concept of minimum cost spanning tree? What are the different algorithms
exist for obtaining minimum cost spanning tree. Compute the minimum cost spanning
tree using Prim’s algorithm for the given graph. Draw the spanning tree generated at each
step. [10]
JN
TU
H
OR
7. Write greedy algorithm for knapsack problem. Find the solution for the following
U
Knapsack problem using greedy method.
(p1,p2,p3,p4)=(2,5,8,1), (w1,w2,w3,w4)=(10,15,6,9) and m=30. [10]
se
8.a) Write an algorithm for all pairs shortest path. Define its complexity.
b) Compute the shortest distance between each pair of nodes for the following graph using
d
all pair shortest path algorithm. [5+5]
pa
pe
OR
Use the function OBST to compute w(i, j), r(i, j) and c(i, j), 0≤i≤j≤4 for the identifier set
rs
9.
(a1,a2,a3,a4)=(do, if, int, while) with p(1:4)=(3,3,1,1) and q(0:4)=(2,3,1,1,1) using
r(i,j)’s construct optimal binary search tree. [10]
20
10. Generate the state space tree using FIFO Branch and Bound and find the shortest path
followed by the travelling salesperson instance defined by the cost matrix given below.
[10]
23
∞ 7 3 12 8
3 ∞ 6 14 9
5 8 ∞ 6 18
9 3 5 ∞ 11
[ 18 14 9 8 ∞ ]

OR
11. Explain circuit satisfiability problem with a circuit diagram. Show that circuit
satisfiability problem is NP- hard. [10]

---ooOoo---

Common questions

Powered by AI

Dynamic programming and the greedy method are both algorithmic paradigms used for optimization problems but they differ in approach. Dynamic programming solves problems by breaking them into overlapping subproblems and storing solutions to subproblems to avoid redundant computations, which is applicable in problems like the Knapsack problem or Fibonacci sequence. Greedy algorithms, on the other hand, make locally optimal choices at each step with the hope of finding a global optimum, suitable for problems such as Prim's or Kruskal's algorithm for MST. Unlike dynamic programming, the greedy method does not guarantee optimal solutions for all problems, but it is more efficient and simpler if applicable .

Cook's Theorem asserts that the Boolean satisfiability problem (SAT) is NP-complete, meaning it is both in NP and any problem in NP can be reduced to it in polynomial time. This theorem was groundbreaking as it provided the first known NP-complete problem, establishing a cornerstone for studying the class NP-complete. Its significance lies in the fact that solving or optimizing a solution for any NP-complete problem efficiently may lead to a solution for all problems within NP, thus influencing numerous fields from cryptology to optimization .

The graph coloring problem is challenging due to its NP-completeness, where the task is to assign colors to the vertices of a graph so that no two adjacent vertices share the same color, using the minimum number of colors. This complexity arises from the expansive number of possible color assignments to check for validity. A widely used algorithm is the backtracking approach, starting with an initial color assignment and using recursion to assign colors, backtracking whenever a color conflict arises. Although not polynomial, backtracking is practical for small graphs or when used with heuristics for color ordering .

Asymptotic notations provide a means to describe the running time or space requirement in terms of the input size, helping to evaluate an algorithm's efficiency when scaled. Big Oh (O) describes an upper bound on time; Omega (Ω) describes a lower bound; and Theta (Ɵ) gives a tight bound (both upper and lower). Graphically, these notations illustrate these bounds against input sizes on the x-axis and time/space amount on the y-axis. Big Oh is commonly used to describe worst-case scenarios, whereas Omega and Theta describe best-case and average-case scenarios respectively. This facilitates comparing different algorithms and making informed choices .

Quick Sort generally performs better on average with a time complexity of O(n log n), although its worst-case time complexity is O(n^2). However, with a proper choice of pivot, the worst-case is rare, and it typically handles in-place sorting without additional storage, making it space-efficient. Merge Sort, on the other hand, has a guaranteed time complexity of O(n log n) regardless of data input but requires additional space of O(n). Hence, Quick Sort can be more efficient in terms of runtime and space usage if the input is large and the pivot is chosen wisely, while Merge Sort offers stability and predictable performance .

The Branch and Bound method iteratively partitions the problem space into smaller subproblems using upper and lower cost bounds to prune suboptimal paths, thus systematically narrowing the search space for the optimal tour in the Travelling Salesperson Problem (TSP). By keeping track of the least bound cumulative cost routes, it can discard paths that will not yield minimal costs. Branch and Bound, although computationally intensive, effectively finds the exact solution to the TSP as it explores all potential tours while minimizing unnecessary computations by using bounds carefully .

The state space tree represents all possible placements of queens in the 4-Queens problem, where each node at the k-th level in the tree corresponds to a placement of k queens on the board. The bounding function is used to prune branches, eliminating suboptimal solutions (i.e., states where queens threaten each other) to efficiently find valid setups. Backtracking is employed to explore possible placements systematically, abandoning solutions that violate constraints early, which greatly reduces computational efforts by not visiting the entire solution space exhaustively .

Recurrence relations in Quick Sort are used to express its divide-and-conquer strategy: dividing the array and solving each partition. The recurrence relation T(n) = 2T(n/2) + Θ(n) describes Quick Sort when the pivot minimizes divisions, capturing the sum of two subproblem recursions and a linear scan for partitioning. In the best-case scenario, this relation simplifies, reflecting equal-size partitions resulting in a balanced tree of recursions yielding a best-case complexity of O(n log n) by solving the recurrence via the Master Theorem .

The FIFO Branch and Bound method constructs a state space tree breadth-first for the Traveling Salesperson Problem (TSP), sequentially exploring each level of decision nodes. Each node represents a city and an edge represents the cost of the route. The algorithm maintains a queue of nodes, expanding the current node by generating all possible successors, evaluating each's bound. Unproductive nodes (those exceeding a known solution or potential lower bound) are pruned. This systematic expansion using cost bounds ensures a thorough yet efficient search for the shortest possible tour solution .

A Minimum Spanning Tree (MST) of a connected, undirected graph is a tree that connects all the vertices together, without any cycles, and with the minimum possible total edge weight. Prim's algorithm is a popular method to find an MST. It starts from an arbitrary node and grows the spanning tree by adding the lowest weight edge from the tree to a vertex outside of it. This process continues until all vertices are included. Prim's algorithm efficiently finds the MST with a time complexity of O(V^2) using simple array data structures, which can be reduced to O(E log V) using priority queues .

You might also like