Design and Analysis of Algorithms
Design and Analysis of Algorithms
Design and Analysis of Algorithms
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
QUESTION BANK
IV SEMESTER
Prepared by
QUESTION BANK
SUBJECT CODE/NAME: 1904402 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
1. Define algorithm and list the desirable properties of an algorithm. Remember BTL-1
2. Define best, worst and average time complexity. Remember BTL-1
3. How to measure the algorithm running time? BTL-2 Under
Understand
4. List the steps to write an Algorithm. Analyze BTL-4
5. Prove that if f(n)=O(g(n)) ad g(n) = O(f(n)), then f(n)=ϴ g(n). Apply BTL-6
PART - B
1. Give the General Plan for Analyzing the Time Efficiency of
Recursive Algorithms and use recurrence to find number of moves Remember BTL-1
for Towers of Hanoi problem n
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)
Write the asymptotic notations used for best case, worst case and
average case of algorithms. (7)
Create an algorithm to find the maximum element in an array. Give
3. best, worst and average case complexities. (6) Create BTL-6
4. For each of the following algorithms, Analyze BTL-5
i) Compute n! (7)
ii)Asses & find the largest element in a list of n numbers with
respect to the following conditions: (6)
(a). A natural size metric for its inputs.
(b). Its basic operation.
(c). Whether the basic operation count can be different for inputs of
the same sizes.
PART – A
Q.No Questions BT Level Competence
1. State Brute force approach. Remember BTL-1
2. Examine a brute force algorithm for string matching problem. Apply BTL-3
3. Give an example of a text of length n and a pattern of length m
that constitutes a worst case input for the brute force string
Create BTL-6
matching algorithm. Formulate and find how many character
comparisons will be made for such input.
4. Define the term exhaustive search. Remember BTL-1
Examine a brute force algorithm for counting the number of
5. Apply BTL-3
vowels in a given text.
Give an example problem that cannot be solved by a Brute force
6. approach and also how to decide? Remember BTL-1
7. Describe brute force approach. What are the advantages and Analyze BTL-4
disadvantages of this approach?
8. Define closest pair problem. Remember BTL-1
10. Formulate is the length of the step-in jump search? Create BTL-6
13. You are given a knapsack that can carry a maximum weight of 60. Understand BTL-2
There are 4 items with weights {20, 30, 40, 70} and values {70, 80,
90, 200}. What is the maximum value of the items you can carry
using the knapsack? of the following methods can be used to solve
the Knapsack problem?
14. What is the time complexity of the brute force algorithm used to Apply BTL-3
solve the Knapsack problem?
Define the Time complexity of knapsack 0/1 where n is the number
15. of items and W is the capacity of knapsack. Understand BTL-2
THERE_IS_MORE_TO_LIFE_THAN_INCREASING_ITS_SPEE
D
Assume that the length of the text—it is 47 characters long—is
7. known before the search starts (13) Create BTL-6
How many comparisons (both successful and unsuccessful) will be
made by the brute-force algorithm in searching for each of the
8. following patterns in the binary text of one thousand zeros? (13) Remember BTL-1
Explain the Bruteforce method to find the two closest points in a set
9. of n points in k-dimensional space. (13) Apply BTL-3
10. Solve travelling sales man problem using brute force technique. (13)
. Apply BTL-3
11. Solve shortest hamiltonian circuit problem using brute force
technique. (13)
Apply BTL-3
Explain the brute force method for the travelling sales man problem
12. and give the algorithm with your own example. Understand BTL-2
Explain the brute force method for the knapsack problem and give
13. the algorithm. (13) Understand BTL-2
(i)List out the procedures to solve travelling salesman problem. (6)
14. (ii)Describe the Knapsack problem by using Exhaustive search. (7) Understand BTL-2
Find and Analyze the optimal solution for the assignment
problem given below. (13)
Job 1 Job 2 Job 3 Job 4
4 3 8 6
5 7 2 4
16 9 3 1
15. 2 5 3 7 Analyze BTL-4
Define Assignment problem. Examine the optimal solution for the
16. assignment problem with one example (13) Remember BTL-1
Give an example of the assignment problem whose optimal solution
17. does not include the smallest element of its cost matrix. (13) Evaluate BTL-5
PART – C
1. Solve using Brute force approach to evaluate and find whether Evaluate BTL-5
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 (15)
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? (15)
Does a hamiltonian path or circuit exists on the graph below
problem using brute force technique. (15)
5. Create BTL-6
UNIT III - DIVIDE-AND-CONQUER TECHNIQUE
Divide and Conquer Methodology – Binary Search – Merge sort – Quick sort – Heap Sort -
Multiplication of Large Integers– Closest-Pair and Convex - Hull Problems.
PART – A
Q.
No Questions BT Level Competence
1. Define Divide and conquer methodology. Remember BTL-1
2. List the sorting methods would be most suitable for sorting a list. Remember BTL-1
3. Prove asymptotic complexity in terms of n. Apply BTL-3
4. Evaluate total number of comparisons made in quick sort for Evaluate BTL-5
sorting a file of size n.
5. Design the correct order of the efficiency of the following sorting Create BTL-6
algorithms according to their overall running time comparison.
6. How do you measure the efficiency of an algorithm for divide Remember BTL-1
and conquer method?
7. Examine an algorithm for binary search. Apply BTL-3
8. Identify The number of swapping’s needed to sort the numbers 8, Remember BTL-1
22, 7, 9, 31, 19, 5, 13 in ascending order, using bubble sort.
9. How many approaches can be applied to solve quick hull problem Analyze BTL-4
10. Explain the various types of problems does quick hull belong. Analyze BTL-4
11. Apply the common technique for proving to find the ‘n’ points Apply BTL-3
that lie in a convex quadrilateral.
12. Define space complexity of merge sort. Remember BTL-1
13. Define worst case time complexity of merge sort. Remember BTL-1
14. Formulate the Pattern of Problems in Divide and Conquer Create BTL-6
approach
15. Differentiate between Merge sort and Heap sort efficiency. Understand BTL-2
16. Discuss the concepts of Quick sort and its properties. Understand BTL-2
17. What is heap sort explain with example? Apply BTL-3
18. Examine an recurrence relation for multiplication of large numbers. Evaluate BTL-5
19. What is the first step of heap sort? Understand BTL-2
20. Analyze quick sort with example? Analyze BTL-4
Analyze the Run Time of Merge Sort . Analyze BTL-4
21.
22. Evaluate the Time Complexity of binary search tree. Evaluate BTL-5
23. A machine needs a minimum of 200 sec to sort 1000 elements by Understand BTL-2
Quick sort. What is the minimum time needed to sort 200
elements will be approximately
24. Apply Quick sort on a given sequence 7 11 14 6 9 4 3 12. What is Understand BTL-2
the sequence after first phase, pivot is first element?
PART-B
1 Explain in detail about the closest pair and convex hull problems Remember
13 BTL -1
by using Divide and conquer method.
2 Analyze in detail about divide and conquer strategy with a 13 BTL -3 Apply
scenario.
3 What is divide and conquer strategy and explain the binary
13 BTL -4 Analyze
search with suitable example problem.
4 What is divide and conquer strategy and explain the
13 BTL -4 Analyze
multiplication of large numbers with suitable example problem.
5 Illustrate an algorithm for Quicksort and write its time BTL -3 Apply
13
complexity with example list are 5,3,1,9,8,2,4,7.
6 Describe in detail about the operation of binary search algorithm BTL -2 Understand
for the input -15, -6 , 0, 7 , 9, 23, 54, 82, 101,112, 125,131,142,151 13
if you are searching for the element 9.
7 Analyze the pros and cons of convex hull problem and the BTL -4 Analyze
13
solution involved in detail.
8 Discuss in detail and write an algorithm to sort a given list BTL -2 Understand
of elements using heap sort. Show the operation of the 13
algorithm, on the list 14,12,9,8,7,10,8.
9 Write the algorithm for quicksort. Provide a complete Evaluate
analysis of quick sort for the given set of numbers 13 BTL -5
12,33,23,43,44,55,64,77 and 76.
10 Describe in details about the three processing steps in Quick sort. 13 BTL -1 Remember
11 Write the algorithm to perform the working of multiplication of 13 BTL -1 Remember
large numbers with an example.
12 (i)Find the number of comparisons required to search for ‘6’ 7 BTL -3 Apply
in the given Sequence of numbers: 10, 19, 7, 9, 6, 15.
(ii)Analyze the time efficiency and drawbacks of merge sort
algorithm. 6
13 Write a program implementing the divide-conquer algorithm 13
BTL -1 Remember
for the closest pair problem.
14 Write the mergesort algorithm and explain it with an
example. Derive the worst case and average case time 13 BTL -2 Understand
complexity.
15 (i) Multiply 23 * 14 using divide and conquer strategy 7
BTL -6 Create
(ii)Compute the complexity for multiplication of large numbers. 6
16 Write the max-heap algorithm and explain it with an
example. Derive the worst case and average case time BTL -6 Create
13
complexity.
17 Write a program implementing the divide-conquer 13
BTL -2 Understand
algorithm for the convex-hull problem.
PART – C
Solve heap-sort by applying the Divide and Conquer method and
1. Analyze the time and space complexity of Divide and conquer
methodology for the array having elements: 16, 10, 15, 9, 5, 12, Create BTL-6
14.
Solve 2138 × 4967 by applying the Divide and Conquer method
and Analyze the time and space complexity of Divide and conquer Evaluate BTL-5
2. methodology
Examine that the procedure SEARCH of binary search algorithm Evaluate BTL-5
gives the Smallest possible expected search time if all elements in
the universal set are equally likely to be sought. (15)
3.
(i) Design a Quick sort algorithm (7) Create BTL-6
(ii) Develop Best, worst and Average case analysis for Quicksort
4. method. (8)
5. Create BTL-6
Discuss the topic on merge sort. Illustrate the algorithm with
numeric Example. Predict the complete analysis for the same.
Is merge sort stable sorting algorithm? Justify your answer. (15)
7. What is the constraint for binary search tree insertion? Remember BTL-1
17. Estimate the space and time complexity of a prim’s algorithm. Understand BTL-2
18. Analyze the time complexity of optimal Binary search Tree algorithm. Analyze BTL-4
19. Distinguish prim’s and Kruskal’s algorithm. Understand BTL-2
20. Summarize Huffman trees and its applications Evaluate BTL-5
21. Integrate Minimum spanning tree concepts and Prim’s algorithm. Create BTL-6
22. Develop an algorithm for memory function knapsack problem. Create BTL-6
23. Analyze the time complexity for Binomial coefficient algorithm. Analyze BTL-4
24. Analyze the time complexity of multi stage graph algorithm Analyze BTL-4
6. i) 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.
Construct the optimal binary search tree as a minimum cost tree
(7)
ii) 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 the Create BTL-6
knapsack capacity in W=5 using dynamic programming and
explain it.
8. (i)Define Huffman tree. List the types of Encoding in Huffman tree. (8) Remember BTL-1
(ii)Write the Huffman’s algorithm. Construct the Huffman’s tree for the
following data and obtain its Huffman code. (5)
9. (i) Describe minimum spanning tree using Kruskal’s algorithm with an Remember BTL-1
example. (7)
(ii) Comparison between Prim’s and Kruskal’s algorithm and identify
the time complexity of those algorithms. (6)
10. (i)Write and analyze the prim’s algorithm. (5) Remember BTL-1
(ii)Describe minimum spanning tree using Prim’s algorithm. (8)
11. (i)List out the short notes on optimal binary search tree. (7) Remember BTL-1
(ii) Label the optimization technique used for optimal binary
search algorithm. (6)
PART – C
1. Asses and solve all-pair shortest path problem for the digraph Evaluate BTL-5
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)
Apply the greedy technique to find the minimum spanning tree
4. using Prim's algorithm for the given graph. (15) Create BTL-6
Apply the technique to reduce the size of the given message using huffman
coding technique. (Fized size & Variable Size)
5. Message : BCCABBDDAECCBBAEDDCC Create BTL-6
20. UNIT
Give some V - COPING
examples of P andWITH
NP problem.
THE LIMITATIONS OF ALGORITHM Understand
POWER BTL-2
Lower - Bound Arguments - P, NP NP- Complete and NP Hard Problems. Backtracking – n-Queen
problem - Hamiltonian Circuit Problem – Subset Sum Problem. Branch and Bound – LIFO Search and
FIFO search - Assignment problem – Knapsack Problem – Travelling Salesman Problem -
Approximation Algorithms for NP-Hard Problems – Travelling Salesman problem – Knapsack problem.
PART – A
Q.
Questions BT Level Competence
No
1. What are tractable and non-tractable problems? Remember BTL-1
2. Compare class P and class NP. Analyze BTL-4
3. Define NP hard problem. Remember BTL-1
4. Discuss the principle of backtracking. Understand BTL-2
5. How is the accuracy of approximation algorithm measured? Evaluate BTL-5
6. State Hamiltonian Circuit problem. Remember BTL-1
What are the additional items required for branch and bound?
7. Analyze BTL-4
compare backtracking technique.
8. Point out some examples of lower bound. Analyze BTL-4
9. Describe the term state space tree. Remember BTL-1
10. Define Knapsack problem. Remember BTL-1
11. Discuss the term best first branch bound. Understand BTL-2
12. State whether backtracking always produces optimal. Create BTL-6
Decide the termination point of the search path in a state space
13. Evaluate BTL-5
tree of branch and bound algorithm.
14. Show formal definition of the n-queens problem. Understand BTL-2
15. Describe the term state space tree. Understand BTL-2
What is Hamiltonian path? Generalize that Hamiltonian cycle
16.
is an undirected graph. Create BTL-6
What does NP-hard mean? Demonstrate approximation
17. Apply BTL-3
algorithm for NP hard problem.
3. (i) Identify an example for the best-case input for the branch
and bound algorithm for the assignment problem. 7 Apply BTL-3
(ii) Describe NP-hard and NP-completeness. 6
4. Using Back-Tracking enumerate how can you solve the
following problems.
(i)4-queens problem.
7 Apply BTL-3
(ii)Hamiltonian circuit problem. 6
5. Find the optimal solution using Branch and Bound for the
following assignment problem.
13 Apply BTL-3
13 Understand BTL-2
Draw the state space tree and show the reduced matrices
corresponding to each of the node.
7. (i)Explain how to implement an algorithm for Knapsack problem
7
using NP-Hard approach. Analyze BTL-4
(ii)Distinguish between the P and NP problems. 6
8. Describe about the following:
(i)Approximation algorithms for the knapsack problem. 6 Remember BTL-1
(ii) Approximation algorithms for Traveling sales man problem. 7
9. (i)Explain the backtracking problem.
7
(ii) Analyze and explain elaborately on backtracking Analyze BTL-4
algorithm. 6
10. Write an algorithm for subset sum and explain with an example. 13 Apply BTL-2
11. Explain in detail about assignment problem using branch and bound
13 Remember BTL-1
technique.
12. Apply Branch and Bound algorithm to solve the travelling salesman
13 Create BTL-6
problem for
13. With an example, summarize how the branch and bound
technique is used to solve 0/1 knapsack problem.
13 Evaluate BTL-5
14. There are 5 distinct numbers {1,2,5,6,8}. Identify the
combinations of these numbers such that the sum is 9. Use the 13 Understand BTL-2
backtracking model to arrive at the solution.
15. With an example, Exaplin how the backtracking approach
13 Analyze BTL-4
is used to solve Hamiltonian circuit problem.
16. Explain in detail about the LIFO and FIFO search. 13 Remember BTL-1
17. Write down the difference between Backtracking and Brach and
13 Understand BTL-2
Bound.
PART-C
1. Explain the 4-Queen's problem using backtracking. Write the
algorithms. Give the estimated cost for all possible solutions of 4- 15 Create BTL-6
Queen's problem. Specify the implicit and explicit constraints.
2. Find a Hamiltonian circuit or disprove its existence in the graph
given below.
15 Evaluate BTL-5
15 Create BTL-6