SRM- 1904402-design-and-analysis-of-algorithms-1
SRM- 1904402-design-and-analysis-of-algorithms-1
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? Remember BTL-1
4. List the steps to write an Algorithm. Remember BTL-1
5. Prove that if f(n)=O(g(n)) ad g(n) = O(f(n)), then f(n)=ϴ g(n). Apply BTL-3
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
2
(i).F(n) = 2n + 5 and g(n) = 7n. Use the Ω (g(n)) notation.
18. Differentiate Algorithm VS Program. Evaluate BTL-5
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)
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 C
1. Evaluate the following equalities are correct: Evaluate BTL-5
2 2
i)5n -6n=ϴ(n ) (4)
n
ii)n!=O(n ) (4)
3 6 2 3
iii)n +10 n =ϴ(n ) (4)
2 n 2 n
iv)2n 2 +n logn=ϴ(n 2 ) (3)
2. Evaluate the following recurrences completely Evaluate BTL-5
i ) T(n) = T(n/2) +1, where n=2k for all k≥0 (4)
ii) T(n) = T(n/3) + T(2n/3) + cn, where ‘c’ is a
constant and ‘n’ is the input size. (4)
iii) Explain the steps involved in problem solving (7)
3. Design a consecutive integer checking algorithm and middle- Create BTL-6
school procedure algorithm. (15)
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.
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
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)
Can you design a more efficient algorithm than the one based on the
brute-force strategy to solve the closest-pair problem for n points x1,
2. x2,...,xn on the real line? (13) Understand BTL-2
. Apply BTL-3
Explain the memory function method for the knapsack problem and
10. give the algorithm. (13) Understand BTL-2
(i)List out the procedures to solve travelling salesman problem. (6)
11. (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
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)
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. Analyze the Run Time of Merge Sort . Analyze BTL-4
18. Evaluate the Time Complexity of binary search tree. Evaluate BTL-5
19. 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
20. 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 1BTL -4 Analyze
scenario. 3
3 What is divide and conquer strategy and explain the binary 1
BTL -4 Analyze
search with suitable example problem. 3
i. Differentiate sequential search from binary search technique.
4 1BTL -3 Apply
ii. Illustrate an algorithm for Quicksort and write its time
3
complexity with example list are 5,3,1,9,8,2,4,7.
5 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.
6 Analyze the pros and cons of convex hull problem and the BTL -4 Analyze
solution involved in detail.
7 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.
8 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.
9 Describe in details about the three processing steps in Quick sort. 13 BTL -1 Remember
10 Write the algorithm to perform the working of multiplication of 13 BTL -1 Remember
large numbers with an example.
11 (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
12 Write a program implementing the divide-conquer algorithm 13
BTL -1 Remember
for the closest pair and convex-hull problem.
13 Write the mergeort algorithm and explain it with an
3
example. Derive the worst case and average case time BTL -2 Understand
13
complexity.
14 5
(i) Multiply 23 * 14 using divide and conquer strategy
7 BTL -6 Create
(ii)Compute the complexity for multiplication of large numbers.
6
PART – C
1. (i)Solve 2138 × 4967 by applying the Divide and Conquer Evaluate BTL-5
method. (8)
(ii)Analyze the time and space complexity of Divide and conquer
methodology. (7)
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)
2.
(i) Design a Quick sort algorithm (7) Create BTL-6
(ii) Develop Best, worst and Average case analysis for Quicksort
method. (8)
4. 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)
4. What is the constraint for binary search tree insertion? Remember BTL-1
14. Estimate the space and time complexity of a prim’s algorithm. Understand BTL-2
15. Analyze the time complexity of optimal Binary search Tree algorithm. Analyze BTL-4
17. Distinguish prim’s and Kruskal’s algorithm. Understand BTL-2
18. Summarize Huffman trees and its applications Evaluate BTL-5
19. Integrate Minimum spanning tree concepts and Prim’s algorithm. Create BTL-6
20. Develop an algorithm for memory function knapsack problem. Create BTL-6
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 Create BTL-6
the 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
UNIT V - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
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 complete 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.
PART-B
1. Explain in detail about the Backtracking 13 Remember BTL-1
2. (i) Evaluate the subset sum problem with set as {3, 5, 6, 7, 2}and the
sum =15.Derive all the subsets. 7
(ii) Evaluate the following instance of the knapsack problem using the
Evaluate BTL-5
branch and bound algorithm. 6
Knapsack capacity W=10.
Item Weight Value
1 4 $40
2 7 $42
3 5 $25
4 3 $12
3. (i) Identify an example for the best-case input for the branch
and bound algorithm for the assignment problem. 7 Remember BTL-1
(ii) Describe NP-hard and NP-completeness. 6
4. Using Back-Tracking enumerate how can you solve the
following problems.
7 Apply BTL-3
(i)4-queens problem.
(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
problem for
13 Create BTL-6
13. With an example, summarize how the branch and bound 13 Evaluate BTL-5
technique is used to solve 0/1 knapsack problem.
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 Remember BTL-1
backtracking model to arrive at the solution.
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