JNTU
JNTU B.Tech III DESIGN AND ANALYSIS OF ALGORITHMS Previous Question Paper (August/September - 2021 - R18)
Answer any five questions. All questions carry equal marks.
Main
Write and explain randomized quick sort algorithm.
Answer
Randomized Quick Sort is a variation of the standard Quick Sort algorithm where the pivot element is chosen randomly from the array instead of always picking the first or last element. This randomization ensures that the algorithm achieves an average-case time complexity of O(n log n) regardless of the input distribution, effectively preventing the worst-case O(n²) performance on already sorted or nearly sorted arrays.
The algorithm follows these steps:
- Select a random index between the current low and high bounds.
- Swap the element at the random index with the element at the high index to treat it as the pivot.
- Perform the standard partition procedure to place the pivot in its correct sorted position, such that all elements to the left are smaller and all elements to the right are larger.
- Recursively apply the same process to the left and right sub-arrays.
By picking a random pivot, the probability of consistently hitting the worst-case partition is extremely low, making the algorithm robust for practical applications.
Discuss about Big oh O, Omega Ω and Theta θ notations with examples.
Answer
Asymptotic notations are used to describe the growth rate of algorithms as the input size n approaches infinity.
Big-O Notation (O): Provides an asymptotic upper bound. A function f(n) is O(g(n)) if there exist positive constants c and n₀ such that 0 ≤ f(n) ≤ c·g(n) for all n ≥ n₀. It represents the worst-case complexity. Example: 3n + 2 is O(n).
Omega Notation (Ω): Provides an asymptotic lower bound. A function f(n) is Ω(g(n)) if there exist positive constants c and n₀ such that 0 ≤ c·g(n) ≤ f(n) for all n ≥ n₀. It represents the best-case complexity. Example: 3n + 2 is Ω(n).
Theta Notation (θ): Provides an asymptotic tight bound. A function f(n) is θ(g(n)) if there exist positive constants c₁, c₂, and n₀ such that c₁·g(n) ≤ f(n) ≤ c₂·g(n) for all n ≥ n₀. It occurs when the algorithm's upper and lower bounds are the same. Example: 3n + 2 is θ(n).
Using Merge sort, sort the following elements: 310, 285, 179, 652, 351, 423, 861, 254, 450, 520
Answer
Sign in to view the complete answer paper.
Analyze the computing time complexity of binary search algorithm.
Answer
Sign in to view the complete answer paper.
Show that depth first search can be used to find the connected components of an undirected graph.
Answer
Sign in to view the complete answer paper.
Write an algorithm of n-queen’s problem and explain.
Answer
Sign in to view the complete answer paper.
Suppose we start with n sets, each containing a distinct element.
Show that if u unions are performed, then no set contains more than u+1 elements.
Answer
Sign in to view the complete answer paper.
Show that at most n – 1 unions can be performed before the number of sets becomes 1.
Answer
Sign in to view the complete answer paper.
Show that if fewer than (n/2) unions are performed, then at least one set with a single element in it remains.
Answer
Sign in to view the complete answer paper.
Solve the following 0/1 Knapsack Problem using dynamic programming: n=4, m=30, (w1,w2,w3,w4) = (10,15,6,9) and (p1, p2, p3, p4) = (2,5,8,1).
Answer
Sign in to view the complete answer paper.
Explain the concept of the traveling salesperson problem.
Answer
Sign in to view the complete answer paper.
Use the function OBST to compute w(i,j), r(i,j), and c(i,j), 0 ≤ i < j ≤ 4, for the identifier set (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 the r(i,j)’s construct the optimal binary search tree.
Answer
Sign in to view the complete answer paper.
Explain the general method of Greedy method.
Answer
Sign in to view the complete answer paper.
Write and explain the Kruskal’s algorithm with an illustrative example.
Answer
Sign in to view the complete answer paper.
Explain with respect to branch and bound 0/1 knapsack problem.
Answer
Sign in to view the complete answer paper.
Discuss in detail about the classes of NP-hard and NP-complete.
Answer
Sign in to view the complete answer paper.