0% found this document useful (0 votes)
51 views8 pages

DAA Unit-Wise Question Bank

Uploaded by

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

DAA Unit-Wise Question Bank

Uploaded by

dharnakarthik160
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Design And Analysis of Algorithms

Unit Wise Questions from Previous Question Papers

Unit-I

Short Answer Questions:

1. What are the properties of an algorithm?


2. If f(n)=5n2+6n+4 then prove that f(n) is O(n2).
3. Define any three asymptotic notations.
4. Arrange the following functions in increasing order?
n, log n, n2, n3, nlog n, 2n
5. Explain about recursive algorithms?
6. How can we measure an algorithm’s running time?
7. What is amortized complexity?
8. Define order of growth.
9. What is randomized algorithm.
[Link] about different types of randomized algorithms?
[Link] about Divide and Conquer general method.
[Link] the worst-case, best-case, and average-case time complexities of
binary search algorithm.
[Link] is time complexity of Strassen’s matrix multiplication?
[Link] is the time complexity of MergeSort and QuickSort algorithms?
[Link] the asymptotic notations.
[Link] the time complexity of merge sort.

Long Answer Questions:

1. What are the features of an efficient algorithm? Explain with an example.


2. Discuss in detail various notations used for expressing the time
complexity of algorithms, with examples.
3. What is Performance Analysis? Explain Space Complexity and Time
Complexity with examples.
4. Write control abstraction algorithm for Divide and Conquer technique?
5. Analyze the computing time complexity of binary search algorithm.
6. Explain the process of merge sort by a list of any 11 integers (distributed
randomly). Write the algorithm and analyze its time complexity.
7. Using Merge sort, sort the following elements:
310, 285, 179, 652, 351, 423, 861, 254, 450, 520
8. Write the QuickSort algorithm? Analyze the time complexity in the
worst case and average case.
9. Write and explain randomized quick sort algorithm.
[Link] the following recurrence relations :
a) T(n) = 4T(n/2) + n2, where n ≥ 1 and is a power of 2.
b) T(n) = 2T(n/2) + nlog n
c) T(n) = 3T(n/2) + n
[Link] an algorithm to find matrix multiplication using Strassen’s and
analyze its time complexity?
[Link] between Merge Sort and Quick Sort .
[Link] the following recurrence equation:

Unit-II

Short Answer Questions:

1. Explain Disjoint set union and find operations.


2. Explain union algorithm with weighting rule.
3. Explain find algorithm with collapsing rule.
4. Write about n-queen’s problem.
5. Write about sum-of-subsets problem.
6. Describe the m-coloring graph problem.
7. What are applications of backtracking technique?
8. How sets are represented in memory?
9. What is a disjoint set?
[Link] the fixed and variable method in sum of subsets?
[Link] are implicit and explicit constraints?
[Link] the sum of subsets of the following set of integers by using the fixed
tuple method. (5,10,25,50,100) for w=75.

Long Answer Questions:

1. Write an algorithm of weighted union and also compute the time


complexity of the same.
2. Explain the Find algorithm with collapsing rule.
3. What is weighting rule for Union(i,j)? How it improves the performance
of union operation?
4. Write an algorithm of n-queen’s problem and explain.
5. Describe the Backtracking technique to the m-coloring graph. Explain
with an example its time complexity.
6. Draw the state space tree for m’ coloring hen n=3 and m=3.
7. Write an algorithm for the 8-queens problem using backtracking.
8. What is sum-of-subsets problem? Write a recursive backtracking
algorithm for sum of subsets problem?
9. Write the backtracking algorithm for the sum of subsets problem using
the state space tree corresponding to m=35, w=(20,18,15,12,10,7,5). Also
draw the state space tree.
[Link] backtracking to solve the following instance of the subset sum
problem S={1,3,4,5) and d=11.
[Link] and contrast BFS and DFS.
[Link] is graph coloring problem? Describe the back tracking technique to
m-coloring with following planar graph shown in figure:

[Link] we start with n sets, each containing a distinct element.


a) Show that if u unions are performed, then no set contains more than
u+1 elements.
b) Show that at most n – 1 unions can be performed before the number of
sets becomes 1.
c) Show that if fewer than (n/2) unions are performed, then at least one
set with a single element in it remains.

Unit-III (Greedy Method)

Short Answer Questions:

1. Write the applications of Greedy method.


2. Write any two characteristics of Greedy algorithm.
3. Define a spanning tree and minimum spanning tree.
4. What is Feasible solution?
5. Can we solve 0/1knapsack problem with greedy method ? Commenton
your answer.
6. What is the importance of knapsack algorithm in our daily life?
7. State the Job – Sequencing Deadline Problem.
8. Find an optimal solution to the knapsack instance n=4 objects and the
capacity of knapsack m=15, profits (10, 5, 7, 11) and weight = (3, 4, 3,5).

Long Answer Questions:

1. Explain the problem of job sequencing with deadlines by taking an


example. Write the algorithm to solve the problem using the Greedy
Method. Show how the algorithm solves the following job sequencing
with deadlines problem. n = 4, (p1, p2, p3, p4) = (100, 10, 15, 27) and
(d1, d2, d3, d4) = (2, 1, 2, 1).
2.
a. Explain the general method of Greedy method.
b. Write and explain the Kruskal’s algorithm with an illustrative
example.
3. Write a greedy algorithm for sequencing unit time jobs with deadlines
and profits.
4. Describe the greedy method control abstraction for the subset paradigm.
5. Write an algorithm for Greedy Knapsack.
6. Write an algorithm of Prim’s minimum cost spanning tree.
7. Discuss briefly about the minimum cost spanning tree.
8. Discuss about fractional knap sack problem. Consider the following
instance of knapsack problem n=3, m=20, profits (p1, p2, p3)=(25, 24,15)
and weights(w1, w2, w3)=(18,15,10). Obtain the optimal solution using
greedy approach.
9. Write the pseudo code for Dijkstra’s algorithm for single source shortest
path problem.

Unit-IV ( Dynamic Programming)

Short Answer Questions:

1. State the principle of optimality


2. What is traveling salesperson problem?
3. What you mean by dynamic programming.
4. Define optimal binary search tree with an example
5. Give the statement of Reliability design problem.

Long Answer Questions:

1. Discuss about all pairs shortest path problem with suitable example.
2. Compute all pair shortest path for following graph shown in figure 1.

3. Describe travelling sales person problem. Find the minimum cost tour for
the following graph using dynamic programming. Costs of the edges are
given by matrix shown in figure 2.

4. Obtain all pairs shortest paths for the following:

5. Solve the following 0/1 Knapsack Problem using dynamic programming


n=4, m=30, (w1,w2,w3,w4) = (10,15,6,9) and (p1, …, p4) = (2,5,8,1).
6. 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.
7.
a. Solve the solution for 0/1 knapsack problem using dynamic
programming: (p1,p2,p3, p4) = (11, 21, 31, 33), (w1, w2, w3, w4)
= (2, 11, 22, 15), M=40, n=4.
b. State the principle of optimality in dynamic programming. How to
apply this to the shortest path problem?
8. Consider 4 elements al < a2 < a3 < a4 with q(0) = 1/8, q(1) = 1/16,
q(2) = q(3) = q(4) =1/16, p(1) = 1/4, p(2) =1/8, p(3) = p(4) =1/16.
Construct the table of values of W (i, j), R (i. j) and C(i, j) computed by
the algorithm to compute the roots of optimal sub trees.
9. Find an optimal solution to the 0/1 knapsack instance n=7,m=15
(p1,…p7)= (10,5,15,7,6,18,3) and (w1,…w7)= (2,3,5,7,1,4,1).

Unit-V

Short Answer Questions:

1. Write the applications of Branch and Bound problem


2. Define E-node
3. What do you mean by bounding?
4. What is meant by non-deterministic algorithm?
5. Define class P.
6. What is NP-hard problem.
7. Explain briefly about optimization problem
8. State the difference between FIFO and LC Branch and Bound algorithms.
9. Write the Control Abstraction of Least – Cost Branch and Bound.
[Link] the statement of 0/1 Knapsack FIFO BB.
[Link] P,NP,NP-Hard,NP-Complete.

Long Answer Questions:

1.
a. Explain the classes of P and NP.
b. Differentiate between NP – complete and NP-Hard.
2. a)Discuss about cook’s theorem. b) What is the satisfiability problem?
3. Draw the portion of the state space tree generated by LCBB for the
knapsack instances: n=5, (P1,P2,…,P5) = (12,10,5,9,3),
(w1,w2,...,w5)=(3,5,2,5,3) and m=12.
4.
a. Write short notes on 3-SAT problem.
b. Briefly explain deterministic and non deterministic algorithms with
example.
5. Give the relation between NP Hard and NP Complete.
6. Draw the portion of the state space tree generated by LCBB for the
following instances: n=5, m=12, (P1…..P5) = (10, 15, 6, 8, 4) (w1…w5)
= (4, 6, 3, 4, 2)
7. Draw the portion of the state space tree generated by LC branch and
bound for an instance n=4, (P1, P2, P3, P4)= (10,10,12,18), (w1, w2, w3,
w4)=(2, 4, 6, 9), and m=15
8. Explain the FIFO BB 0/1 Knapsack problem procedure with the knapsack
instance for n=4, m=15,(p1,p2,p3,p4)=(10,10,12,18), (w1,w2,w3,w4)
=(2, 4, 6, 9). Draw the portion of the state space tree and find optimal
solution.
9. Draw the portion of state space tree for the knapsack problem: N=5,
(P1,P2,…,P5)= (w1,w2,...,w5)=(4,4,5,8,9) and m=15.
[Link] the traveling salesperson instance defined by the cost matrix and
generate the state space tree using LCBB and also use dynamic
programming design strategy.

11.
[Link] the articulation points and draw the biconnected components.

13.
14.

1. A feasible solution that maximizes or minimizes a given objective function


is called an ……………………
2. A ………………………cycle is a path along n edges of G that visits every
vertex once and returns to its starting position.
3. Any subset that satisfies specific constraints is called ……………………
solution.
4. In …………………… method, an algorithm is devised that works in stages
considering one input at a time.
5.

Common questions

Powered by AI

The Traveling Salesperson Problem (TSP) asks for the shortest possible route that visits a set of cities, each exactly once, and returns to the original city. It is challenging due to its combinatorial nature, as the number of possible paths increases factorially with the number of cities, resulting in a vast solution space that must be evaluated to determine the optimal path. Solving TSP optimally in reasonable time for large sets is particularly difficult due to its NP-hard classification, meaning no polynomial-time algorithm is known to address all instances of TSP optimally .

The collapsing rule in the Find algorithm is used to optimize the disjoint set union operations. It involves making all nodes point directly to the root of the set, thereby flattening the structure of the tree whenever Find is called. This optimization significantly reduces the path length from each node to the root, resulting in nearly constant time complexity for subsequent Find operations after an initial sequence of union operations. This improves the overall efficiency of union-find operations, especially when dealing with many elements and operations .

Dynamic programming solves the 0/1 Knapsack Problem by breaking it down into simpler subproblems and solving each once, storing the results in a table to avoid redundant calculations. It systematically considers each possible weight and profit combination, providing a globally optimal solution. Conversely, the greedy method doesn't guarantee an optimal solution for the 0/1 knapsack because it makes decisions at each step based solely on current data—such as the highest profit or the smallest weight—without considering future consequences. This local optimum strategy might fail to identify the best overall outcome .

The principle of optimality in dynamic programming states that an optimal solution can be constructed efficiently using optimal solutions of its subproblems. In the context of the shortest path problem, this principle implies that to find the shortest path from a starting node to a destination node, one can break the journey into smaller segments where each segment itself leads to the optimal path. By ensuring that the shortest path from any intermediate node to the destination node is already computed, dynamic programming can build the complete shortest path efficiently .

The core properties of an algorithm include definiteness, finiteness, input, output, and effectiveness. These properties ensure that an algorithm is well-defined and reliable. Definiteness ensures that each step is clearly defined, finiteness guarantees that an algorithm will terminate, input specifies the presence of an initial set of data, output ensures that results are produced, and effectiveness denotes that operations can be performed with basic resources. Understanding these properties is crucial for algorithm designers to ensure their algorithms are optimal and executable .

Branch and bound solves optimization problems by systematically enumerating candidate solutions, dividing the space into smaller subproblems (branching) and using bounds to dismiss sections of the space incapable of containing an optimal solution. This method is particularly useful for integer linear programming and combinatorial problems like the knapsack problem. Unlike dynamic programming, which solves subproblems to reuse solutions (ensuring optimal substructure), branch and bound operates on exploring feasible solutions and pruning. Branch and bound is inherently non-polynomial and might not compute in polynomial time, unlike dynamic programming, which can be more efficient if overlapping subproblems exist .

Merge Sort has a worst-case time complexity of O(n log n) and is stable, meaning it does not change the relative order of elements with equal keys. It is suitable for large datasets and linked lists since it does not require additional storage for sorting. Quick Sort, on the other hand, has a worst-case time complexity of O(n²), although its average and best-case complexities are O(n log n). Quick Sort is not stable but is in-place, meaning it requires minimal additional space. It is often used for internal sorting of large arrays when memory space is at a premium due to its good cache performance .

Backtracking is useful for the m-coloring graph problem as it explores all possible colorings by making choices and systematically retracting them when they lead to a conflict, effectively performing a depth-first search of the coloring space. If a solution is found during the exploration, the search can terminate early. However, backtracking can be inefficient for large graphs due to the exponential growth of possibilities, leading to high computational costs in terms of time, especially if heuristics or improvements like forward checking are not implemented .

Asymptotic notations (such as O, Θ, and Ω) are fundamental in evaluating the performance of algorithms, providing a high-level understanding of an algorithm's efficiency in terms of time and space as input size grows. They allow comparisons across different algorithms and predict scalability and growth rates. However, they can be misleading for real-world applications because they ignore constant factors and lower-order terms that may be significant in practice, especially for small input sizes or when these constants are large .

To prove that f(n)=5n²+6n+4 is O(n²), we need to show that there exist constants c > 0 and n₀ such that f(n) ≤ c*n² for all n ≥ n₀. Here, f(n) = 5n² + 6n + 4. We can factor out the n² term: f(n) ≤ 5n² + 6n²/2 + 4n²/10, giving us f(n) ≤ (5 + 0.5 + 0.4)n² = 5.9n². Hence, by choosing c = 6 and n₀ = 1, f(n) is O(n²).

You might also like