CS8451-Design and Analysis of Algorithms PDF
CS8451-Design and Analysis of Algorithms PDF
com
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
QUESTION BANK
IV SEMESTER
Prepared by
QUESTION BANK
SUBJECT CODE/NAME: CS8451 DESIGN AND ANALYSIS OF ALGORITHMS
UNIT I - INTRODUCTION
Notion of an Algorithm – Fundamentals of Algorithmic Problem Solving – Important Problem Types –
Fundamentals of the Analysis of Algorithmic Efficiency –Asymptotic Notations and their properties. Analysis
Framework – Empirical analysis - Mathematical analysis for Recursive and Non-recursive algorithms -
Visualization
PART - A
Q.
No Questions BT Level Competence
9. Explain how many algorithms can you write for solving find Analyze BTL-4
the prime numbers. Compare which is the simplest and the
most efficient.
10. Explain the various types of problems that can be solved using Analyze BTL-4
algorithm.
11. Apply the common technique for proving the correctness of an Apply BTL-3
algorithm.
14. Formulate the order of growth. Compare the order of growth n! Create BTL-6
n
and 2 .
15. Differentiate between Best, average and worst case efficiency. Understand BTL-2
16. Discuss the concepts of asymptotic notations and its properties. Understand BTL-2
17. Analyze the order of growth. Analyze BTL-4
(i).F(n) = 2n2 + 5 and g(n) = 7n. Use the Ω (g(n)) notation.
18. Evaluate the recurrence relations. Evaluate BTL-5
(i). x (n) = x (n-1) + 5 for n>1.
(ii). X (n) = x(n/3) +1 for n >1,x(1) =1. (Solve for n = 3k)
19. Discuss the General plan for analyzing efficiency of Non Understand BTL-2
recursive & Recursive algorithms
20. Discuss the following questions by consider the definition based Understand BTL-2
algorithm for adding two n by n matrices.
1. What is basic operation?
2. How many times it is performed as a function of the matrix order
n?
3. How many times it is performed as a function of the total number
of elements in the input matrices?
PART - B
1. Give the General Plan for Analyzing the Time Efficiency of
Recursive Algorithms and use recurrence to find number of moves Understand BTL-2
for Towers of Hanoi problem n (13)
2. (i) Consider the following algorithm for the searching problem. (8)
ALGORITHM Linear search (A[0,……….n-1],key)
// Searches an array for a key value by Linear search.
//Input: Array A [0…..n-1] of values and a key value to
search.
//Output: Returns index if search is successful.
For i← 0 to n-1 do
If [key== A[i])
Return i. Apply BTL-3
a) Apply this algorithm to search the list 10,
92,38,74,56,19,82,37 for a key value 74.
b) Is this algorithm efficient?
c) When can this algorithm be used?
(ii) What are the most important problem types are used to illustrate
different algorithm design techniques and methods of algorithm
analysis. (5)
5. (i)Discuss in detail about the worst case, best case and Understand BTL-2
Average case efficiencies of sequential search function. (7)
(ii)Discuss how much the function value will change if the
sequential search function’s argument is increased. (6)
6. (i).Compare the worst and Average case analysis of binary Analyze BTL-4
search using suitable illustrations. (8)
(ii). Explain the drawbacks in using the standard unit of time,
to measure the runtime of an algorithm(5)
7. Illustrate briefly on Big oh Notation ,Omega Notation and Evaluate BTL-3
Theta Notations .Give Examples. (13)
8. (i)Define a Mathematical analysis of recursive algorithms. (4) Remember BTL-1
(ii)Examine the efficiency of factorial of some number n with
the help of General plan. (9)
9. (i)Define a Mathematical analysis of Non-recursive algorithms. (5) Remember BTL-1
(ii) Tell about the efficiency of finding the element with
maximum value in a given Array with the help of General plan.(8)
10. (i)Define Towers of Hanoi problem. (3) Remember BTL-1
(ii)Describe the time complexity of Towers of Hanoi problem.(10)
11. Explain in detail about Analysis Framework with a suitable Analyze BTL-4
example (13)
12. Analyze the recursive and non-recursive versions of the factorial Analyze BTL-4
function.
i)Examine how much each function requires as ‘n’becomes large.
(7)
ii) Find the time complexity and space complexity (6)
13. (i) Label the algorithm of fundamental problem solving. (7) Apply BTL-1
(ii) Show the useful property involving the asymptotic notations.
(6)
14. Discuss in detail about the fundamentals of algorithmic problem Understand BTL-2
solving. (13)
PART C
1. Evaluate the following equalities are correct: Evaluate BTL-5
i)5n2-6n=ϴ(n2) (4)
ii)n!=O(nn) (4)
iii)n3+106n2=ϴ(n3) (4)
iv)2n22n+n logn=ϴ(n22n) (3)
2. Evaluate the following recurrences completely Evaluate BTL-5
i ) T( ) = ∑ =1−1 (i) + 1≥ 2Given T(n) = 1 if n = 1 (5)
ii) T(n) = 5T(n-2) – 6T (n – 2) (5)
iii)T(n)=2T(n/2) + nlogn (5)
3. Design a consecutive integer checking algorithm and middle- Create BTL-6
school procedure algorithm.
4. Consider the problem of finding the smallest and largest elements Create BTL-6
in an array of n numbers.
i) Design a presorting-based algorithm for solving this problem and
determine its efficiency class (7)
ii) Compare the efficiency of the three algorithms: (8)
a)The Brute-force algorithm
b)This presorting –based algorithm and
c) The divide-and conquer algorithm.
2. Examine a brute force algorithm for string matching problem. Apply BTL-3
5. Examine a brute force algorithm for counting the number of Apply BTL-3
vowels in a given text.
6. Define convex hull problem. Remember BTL-1
7. Find the number of comparisons required to search for ‘6’ in the Analyze BTL-4
given Sequence of numbers: 10, 19, 7, 9, 6, 15.
11. Analyze the time efficiency and drawbacks of merge sort Analyze BTL-4
algorithm.
12. Explain the advantages and disadvantages of binary search Analyze BTL-4
algorithm.
13. Differentiate Sequential technique from binary search Understand BTL-2
technique.
14. Is merge sort stable sorting algorithm? Justify your answer. Apply BTL-3
15. Describe brute force approach. What are the advantages and Understand BTL-2
disadvantages of this approach?
16. Discuss the three processing steps in Quick sort. Understand BTL-2
17. Multiply the numbers 54 and 45. Evaluate by using Evaluate BTL-5
multiplication of Large integer concepts.
18. Give an example problem that cannot be solved by a Brute force Evaluate BTL-5
approach and also how to decide?
19. Define and design the Convex set. Invent the sets such are Create BTL-6
convex. a) Star b) Cone C) Pentagon D) Semicircle.
20. Discuss the recurrence equation for the worst case behavior of Understand BTL-2
merge sort.
PART – B
1. Explain the concepts of the following. Evaluate BTL-5
(i)Brute force string matching Algorithm. (7)
(ii)Closest pair and convex hull problems by brute force. (6)
2. (i)List out the procedures to solve travelling salesman problem. Remember BTL-1
(7)
(ii)Describe the Knapsack problem by using Exhaustive search.
(6)
3. Find and Analyze the optimal solution for the assignment Analyze BTL-4
problem given below. (13)
Job Job 1 Job 2 Job 3 Job 4
Person
Person 4 3 8 6
Person 5 7 2 4
Person 16 9 3 1
Person 2 5 3 7
4. (i) Discuss the topic on merge sort. Illustrate the algorithm with Understand BTL-2
numeric Example. Predict the complete analysis for the same.
(8)
(ii)Write the algorithm to perform Binary search and compute its
run time complexity. (5)
5. (i)Define Assignment problem .Examine the optimal solution Remember BTL-1
(ii) How to show the average time complexity for merge sort
algorithm. (6)
10. (i) Discuss in detail about the closest pair and convex hull Understand BTL-2
problems by using Divide and conquer method. (7)
(ii)Write the KMP string matching algorithm for finding a
pattern on a text, and analyze the algorithm. (6)
11. (i)Describe in detail about divide and conquer strategy. (6) Understand BTL-2
(ii)Explain the binary search with suitable example problem. (7)
12. Analyze and Write an algorithm to sort a given list of elements Analyze BTL-4
using merge sort .Show the operation of the algorithm, on the list
38,27,43,3,9,82,10. (13)
13. i)Differentiate sequential search from binary search technique. Analyze BTL-4
(7)
ii)Write an algorithm for Quicksort and write its time complexity
with example list are 5,3,1,9,8,2,4,7. (6)
14. Examine in detail about Exhaustive search techniques. (13) Remember BTL-1
PART – C
1. How exhaustive search method uses Brute force approach to Evaluate BTL-5
evaluate various problems and find whether the given string
follows the specified pattern and return 0 or 1 accordingly.
Examples:
1)Pattern “abba” input: “redblueredblue” should return 1
2)Pattern “aaaa” input: ”asdasdasdasd” should return 1
3)Pattern “aabb” input: “xyzabcxyzabc” ” should return 0
3. Compose and give an example of an algorithm that should not Create BTL-6
be considered an application of the brute-force approach.
4. Formulate and give an example of a text of length n and a pattern Create BTL-6
of length m that constitutes a worst-case input for the brute-force
string-matching algorithm. Exactly how many character
comparisons will be made for such input?
2. Describe the method to construct an optimal binary search tree Remember BTL-1
14. Estimate the space and time complexity of a prim’s algorithm. Understand BTL-2
PART - B
1. Consider the following distance network. Analyze BTL-4
a) Write the floyd’s algorithm and generate the final distance
matrix. (7)
b) Analyze the shortest path and the corresponding
distance from the source node to the destination node
as indicated in each of the cases 1-6, 5-1 and 5-2 (6)
a b c d
a 0 α 3 α
b 2 0 α α
c Α 7 0 1
d 6 α α 0
3. (i)Describe in detail about the Warshall’s algorithm. (7) Understand BTL-2
(ii)Discuss topic on Knapsack problem with memory functions.
(6)
4. Describe and compute binomial coefficient by the formula Understand BTL-2
C(n, k) = C(n − 1, k − 1) +C(n − 1, k). (13)
5. Analyze the algorithm by applying the following keys and Analyze BTL-4
Key A B C D
Probability 0.1 0.2 0.4 0.3
6. a) Consider 4 elements a1< a2< a3< a4with q0=0.25, q1=3/16, Evaluate BTL-5
q2=q3=q4=1/16, P1=1/4, P2=1/8,P3=P4=1/16.
b) Construct the optimal binary search tree as a minimum cost
tree.
(7
)
c) Construct the table of values Wij, Cij, Vij computed by the
algorithm to compute the roots of optimal sub trees. (6)
7. Plan the following instance of the 0/1, knapsack problem given Create BTL-6
the knapsack capacity in W=5 using dynamic programming and
explain it.
(13)
Character A B C D E
- (underscore)
Probability 0.5 0.35 0.5 0.1 0.4 0.2
11. (i)List out the short notes on optimal binary search tree. Remember BTL-1
(7)
(ii)Let A= {l/119,m/96,c/247,g/283,h/72,f/77,k/92,j/19} be
the letters and its frequency of distribution in a text file.
Analyze a suitable Huffman coding to compress the data. (8)
13. (i) Examine Dijkstra’s algorithm with a suitable example (9) Apply BTL-3
(ii)Illustrate how the minimum-sum descent problem can be
solved by Dijkstra’s algorithm. (4)
14. Summarize Knapsack and memory functions problem in detail. Understand BTL-2
(13)
PART – C
1. Asses and solve all-pair shortest path problem for the digraph Evaluate BTL-5
with the weight matrix given below:
A B C D
A 0 ∞ ∞ 3
B 2 0 ∞ ∞
C ∞ 7 0 1
D 6 ∞ ∞ 0
3. Apply Warshall’s algorithm to find the transitive closure of the Create BTL-6
digraph defined by the following adjacency matrix
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0
i) Prove that the time efficiency of Warshall’s algorithm is cubic
(7)
ii) Explain why the time efficiency of Warshall’s algorithm is
inferior to that of the traversal-based algorithm for sparse graphs
represented by their adjacency lists. (8)
4. Develop and give an example of a graph or a digraph with Create BTL-6
negative weights for which Floyd’s algorithm does not yield the
correct result. (13)
12. Show the Mathematical formulation to solve a max flow Apply BTL-3
problem.
13. Summarize the steps to print all edges of minimum cut. Understand BTL-2
14. Generalize about the perfect matching in bipartite graphs. Create BTL-6
16. What if the blocking pair concepts for marriage problem are Create BTL-6
chosen?
17. Show the requirements of a standard form to solve a Simplex Apply BTL-3
method problem
18. Apply Augmenting path concepts in Maximum flow problem. Apply BTL-3
19. Assess the properties of stable marriage problem (Gale shapley Evaluate BTL-5
algorithm).
20. Explain about the articulation point in a graph. Evaluate BTL-5
PART - B
(ii) Analyze all edges that form the minimum cut, And also
analyze the maximum flow problem. (6)
A B C
α 1,3 2,2 3,1
β 3,1 1,3 2,2
γ 2,2 3,1 1,3
11. Analyze and apply the maximum matching algorithm for the Analyze BTL-4
bi-partite graph. (13)
1->{5,6} 2->{5} 3 ->{4,5}
12. Examine in detail about Iterative Improvement with an Remember BTL-1
example. (13)
13. (i)Discuss about the graphical method in detail. (7) Understand BTL-2
(ii)Summarize in detail about the simplex algorithm methods.
(6)
14. Analyze and Solve the following linear programming Analyze BTL-4
problems geometrically. (7)
a. maximize 3x+y
subject to
−x + y ≤ 1
2x + y ≤ 4
x ≥ 0, y ≥ 0
b. maximize x+ 2y (6)
subject to 4x ≥ y
y≤3+x
PART – C
1. How do you compute a maximum flow for the following graph Evaluate BTL-5
using Ford-Fulkerson method?
2. Evaluate and solve the following problem using simplex method: Evaluate BTL-5
Maximize p= 2x+3y+z
Subject to
x+y+z<=40
2x+y-z>=10
-y+z>=10
where x>=0,y>=0,z>=0
7. What are the additional items required for branch and bound? Analyze BTL-4
compare backtracking technique.
8. Point out some examples of lower bound. Analyze BTL-4
11. Discuss the term best first branch bound. Understand BTL-2
13. Decide the termination point of the search path in a state Evaluate BTL-5
space tree of branch and bound algorithm.
14. Show formal definition of the n-queens problem. Apply BTL-3
16. What is Hamiltonian path? Generalize that Hamiltonian cycle Create BTL-6
is an undirected graph.
17. What does NP-hard mean? Demonstrate approximation Apply BTL-3
algorithm for NP hard problem.
PART - B
What is Class NP? Discuss about any five problems for which Understand BTL-2
1. no polynomial-time algorithm has been found (13)
2. (i) Evaluate the subset sum problem with set as {3, 5, 6, 7, Evaluate BTL-5
2}and the sum =15.Derive all the subsets. (6)
(ii) Evaluate the following instance of the knapsack problem y
the branch and bound algorithm.
Knapsack capacity W=10. (7)
3. (i)Identify an example for the best case input for the branch Remember BTL-1
and bound algorithm for the assignment problem (6)
(ii)Describe NP-hard and NP-completeness. (7)
4. Using Back-Tracking enumerate how can you solve the Apply BTL-3
following problems.
(i)8-queens problem. (7)
(ii)Hamiltonian circuit problem. (6)
5. (i)Discuss in detail about decision tree algorithms. (6) Understand BTL-2
(ii)Elaborate on the nearest-neighbor algorithm and
multifragment-heuristic algorithm for TSP problem (7)
14. Estimate the following instance of the knapsack by branch and Apply BTL-2
bound algorithm. (13)
Item Weight Values
1 10 $100
2 7 $63
3 8 $56
4 4 $12
PART – C
1. Let w={5,7,10,12,15,18,20} and m=35.Compute all possible Evaluate BTL-5
subset of w whose sum is equivalent to m. Draw the portion of
state space tree for this problem.
2. With an example, summarize how the branch and bound Evaluate BTL-5
technique is used to solve 0/1 knapsack problem.
3. Design Branch and Bound algorithm to solve the Travelling Create BTL-6
Salesman problem for the following graph.