Uploaded by Hussain Electricwala

Question Bank ADA

advertisement
SAL College of Engineering
GTU Question Bank
Sem 5 IT & CE
3150703 ANALYSIS AND DESIGN OF ALGORITHMS
Regular Exam: Winter 2020 (56 Marks), Winter 2021, Winter 2021 & Winter 2022
Remedial Exam: Summer 2022 & Summer 2023
Chapter 1
1. What is an algorithm? Why analysis of algorithm is required? - W20 (3 Marks)
2. Define algorithm. Discuss key characteristics of algorithms. W21, S22 (3 Marks)
3. Define Algorithm, Time Complexity and Space Complexity S22 (3 Marks)
Chapter 2
1. Explain: Worst Case, Best Case and Average Case Complexity with suitable example.
S22 (4 Marks)
2. Define following terms: S23 (3 Marks)
(i) Big O Notation,
(ii) Big Theta Notation,
(iii) Big Omega Notation.
3. Explain why analysis of algorithms is important? Explain: Worst Case, Best Case and
Average Case Complexity with suitable example. W21 (4 Marks)
4. What is asymptotic notation? Find out big-oh notation of the f(n) = 3n2+5n+10 - W20
(4 Marks)
5. Explain asymptotic analysis with all the notations and its mathematical inequalities.
W22 (7 Marks)
6. Sort the Best Case running times of all these algorithms in a non-decreasing order. W22
(3 Marks)
 LCS,
 Quick-Sort,
 Merge-Sort,
 Counting-Sort,
 Heap-Sort,
 Selection-Sort,
 Insertion-Sort,
 Bucket-Sort,
 Strassen’s Algorithm.
7. State whether the statements are correct or incorrect with reasons. W22 (4 Marks)
1. O(f(n)) + O(f(n)) = O (2f(n))
2. If 3n + 5 = O(n2) , then 3n + 5 = O(n2)
8. What is the use of Loop Invariant? What should be shown to prove that an algorithm is
correct? W22 (3 Marks)
9. Write an algorithm for Insertion sort. Analyze Insertion sort algorithm for Best Case
and Worst Case. W20 (7 Marks)
10. Write and analyze an Insertion sort algorithm to arrange n items into ascending order.
W21 (7 Marks)
11. What is the difference between Selection sort and Bubble sort? W20 (3 Marks)
12. Write an algorithm of Selection Sort Method. W21, S22 (3 Marks)
13. Sort the following numbers using Heap sort. 20, 10, 50, 40, 30 W21 (4 Marks)
14. Perform Bucket sort for following sequence: 30, 12, 22, 66, 48, 27, 35, 43, 47, 41. S23
(4 Marks)
15. Explain the bubble sort algorithm and derive its best case, worst case, and average case
time complexity. S23 (7 Marks)
Chapter 3
1. Write iterative and recursive algorithm for finding the factorial of N. Derive the time
complexity of both algorithms. W20 (4 Marks)
2. Solve following Recurrence relation using iterative method T(n)=2T(n / 2) + n
W20 (7 Marks)
3. Write and explain the Recurrence relation of Merge Sort. W22 (7 Marks)
4. Perform the analysis of a Recurrence relation T(n)= 2𝑇 (𝑛/2) + 𝜃(𝑛2) by drawing its
Recurrence tree. W22 (7 Marks)
5. Solve following Recurrence relation using iterative method T(n) = T(n - 1) + 1 with
T(0) = 0 as initial condition. Also find big oh notation. S22 (7 Marks)
6. What is a Recurrence? Solve recurrence equation for T (n) = T(n - 1) + 1 using
substitution method. S23 (4 Marks)
7. Explain Master theorem and solve the recurrence T(n) = 9T (n/2) + n with Master
method W20 (7 Marks)
8. Write the Master theorem. Solve following recurrence using it. S22 (7 Marks)
i. T(n)= T(n/2) + 1
ii. T(n)=2T(n/2) + n log n
9. How Divide and Conquer approach work? W20 (3 Marks)
10. Trace the Quick sort for data A = {6,5,3,11,10,4,7,9} W20 (4 Marks)
11. Sort the following list using Quick sort algorithm: <50, 40, 20, 60, 80, 100, 45, 70, 105,
30, 90, 75> Also discuss worst and best case of Quick sort algorithm. W21 (7 Marks)
12. Sort the following list using Quick sort algorithm: < 5, 3, 8, 1, 4, 6, 2, 7 > Also write
Worst and Best case and Average case of Quick sort algorithm. S22 (7 Marks)
13. Consider the array 2,4,6,7,8,9,10,12,14,15,17,19,20. Show (without actually sorting),
how the Quick sort performance will be affected with such input. W22 (3 Marks)
14. Trace the Merge sort for data A = {6, 5, 3, 11, 10, 4, 7, 9} W20 (4 Marks)
15. Apply Merge sort algorithm on array A = {2, 7, 3, 5, 1, 9, 4, 8}. What is time complexity
of Merge sort in worst case? W21 (7 Marks)
16. Explain Merge Sort algorithm with suitable example. S23 (7 Marks)
17. Consider an array of size 2048 elements sorted in non-decreasing order. Show how the
Binary Search will perform on this size by analysis of its recurrence relation. Derive
the running time. W22 (3 Marks)
18. Demonstrate Binary Search method to search Key = 14, form the array A = < 2, 4, 7, 8,
10, 13, 14, 60 > S22 (4 Marks)
19. Discuss Binary search algorithm, also write and solve its recurrence relation. S23 (7
Marks)
Chapter 4
1. Explain advantages and disadvantages of dynamic programming. S23 (4 Marks)
2. Give difference between Greedy Approach and Dynamic Programming. W20, W21,
S22 (3-4 Marks)
3. What is principal of optimality? Explain its use in Dynamic Programming Method.
W20, W21, S22 (3 Marks)
4. Explain principle of optimality with suitable example. S23 (3 Marks)
5. When can we say that a problem exhibits the property of Optimal Substructure? W22
(3 Marks)
6. Given the denominations: d1=1, d2=4, d3=6. Calculate for making change of Rs. 8
using dynamic programming. S23 (7 Marks)
7. Find out minimum number of multiplications required for multiplying:
A[1 × 5], B[5 × 4], C[4 × 3], D[3 × 2], and E[2 × 1]. W20 (7 Marks)
8. Solve following Knapsack problem using dynamic programming algorithm with given
capacity W=5, Weight and Value are as follows :
(2,12),(1,10),(3,20),(2,15) W20 (4 Marks)
9. Solve the following 0/1 Knapsack Problem using Dynamic Programming. There are
five items whose weights and values are given in following arrays.
Weight w [ ] = {1,2,5,6,7} Value v [ ] = {1, 6, 18, 22, 28}
Show your equation and find out the optimal Knapsack items for weight capacity of 11
units. W21 (7 Marks)
10. Consider a Knapsack with maximum weight capacity M is 7, for the three objects with
value <3, 4, 5> with weights <2, 3, 4> solve using Dynamic Programming the
maximum value the Knapsack can have. W22 (3 Marks)
11. Consider weights w = (3, 4, 6, 5) and profit v = (2, 3, 1, 4) and Knapsack capacity W=8.
Find the maximum profit using dynamic approach. S23 (7 Marks)
12. Explain Binomial Coefficient algorithm using dynamic programming. W21 (4 Marks)
13. Obtain Longest Common Subsequence (LCS) using dynamic programming. Given A
= “acabaca” and B = “bacac”. W21 (7 Marks)
14. Apply LCS on sequence <A,B,A,C,B,C> for pattern <A,B,C> W22 (4 Marks)
15. Find out LCS of A={K,A,N,D,L,A,P} and B = {A,N,D,L} S22 (4 Marks)
16. Explain Over-lapping Sub-problem with respect to Dynamic Programming. W22 (3
Marks)
17. Discuss Assembly Line Scheduling problem using dynamic programming with
example. S22 (7 Marks)
18. Given is the S-table after running Chain Matrix Multiplication algorithm. Calculate the
parenthesized output based on PRINT_OPTIMAL_PARENTHESIS algorithm.
Assume the matrix are names from A1, A2, ….,An W22 (3 Marks)
Chapter 5
1.
2.
3.
4.
Discuss advantages and disadvantages of Greedy Algorithm. S23 (4 Marks)
Give the characteristics of Greedy Algorithm. W20, W21, S22 (3-4 Marks)
Explain the steps of Greedy strategy for solving a problem. W22 (4 Marks)
Using Greedy Algorithm find an optimal schedule for following jobs with n=7 profits:
(P1, P2, P3, P4, P5, P6, P7) = (3, 5, 18, 20, 6, 1, 38) and deadline (d1, d2, d3, d4, d5,
d6, d7) = (1, 3, 3, 4, 1, 2, 1) W21 (3 Marks)
5. "A Greedy strategy will work for fractional Knapsack problem but not for 0/1",
Is this True or False? Explain W22 (4 Marks)
6. Consider Knapsack capacity W = 15, w = (4, 5, 6, 3) and v = (10, 15, 12, 8) find the
maximum profit using Greedy method. S22 (7 Marks)
7. How Huffman code is memory efficient compare to fixed length code? W20 (3 Marks)
8. Find
the
Huffman
code
for
each
symbol
in
following
text
ABCCDEBABFFBACBEBDFAAAABCDEEDCCBFEBFCAE W20 (7 Marks)
9. Find an optimal Huffman code for the following set of frequency. A : 50, b: 20, c: 15,
d: 30 W21 (3 Marks)
10. Find an optimal Huffman code for the following set of frequency. a : 40, b: 20, c: 15,
d: 30, e: 10. S23 (3 Marks)
11. Explain Huffman code with Example. S22 (3 Marks)
12. Differentiate between Kruskal’s algorithm and Prim’s algorithm for finding MST. S23
(3 Marks)
13. Find Minimum Spanning Tree for the given graph in Fig. 1 using prim’s algorithm
W20, W21 (4-7 Marks)
Fig. 1
14. Find Minimum Spanning Tree for the given graph (Fig. 2) using Kruskal Algo.
W21 (4 Marks)
Fig. 2
15. Find Minimum Spanning Tree for the given graph (Fig. 2) using Prim’s Algorithm.
S22 (4 Marks)
16. Apply Kruskal’s algorithm on the given graph (Fig. 3) and step by step generate the
MST.
Fig. 3: Graph G(V,E)
17. Apply Prim’s algorithm on the given graph in (Fig.3) Graph G(V,E) and step by step
generate the MST. W22 (7 Marks)
18. Write the Kruskal’s Algorithm to find out Minimum Spanning Tree. Apply the same
and find MST for the graph given below S22 (4 Marks)
19. Draw the minimum spanning tree correspond to following graph using Prim’s
algorithm and find the MST weight: S23 (7 Marks)
20. Draw the minimum spanning tree correspond to following graph using Kruskal’s
algorithm and find weight of MST: S23 (7 Marks)
21. Explain fractional Knapsack problem with example. S22 (7 Marks)
Chapter 6
1. Explain Weighted Graph, Undirected Graph, Directed Graph. S23 (3 Marks)
2. Differentiate BFS and DFS. W20 (4 Marks)
3. Explain in brief Breadth First Search and Depth First Search Traversal techniques of a
Graph with Example. W21 (7 Marks)
4. Explain Breath First Traversal Method for Graph with algorithm with example. S22 (7
Marks)
5. Explain Depth First Traversal using suitable example. S23 (4 Marks)
6. Define Articulation point, Acyclic Directed Graph, Back Edge. W21 (3 Marks)
7. Explain: Articulation Point, Graph, Tree S22 (3 Marks)
8. Apply the algorithm to find strongly connected components from the given graph. W22
(7 Marks)
9. Explain the need of topological Sort with example. S23 (4 Marks)
10. Given is the DAG, apply the algorithm to perform topological sort and show the sorted
graph. W22 (7 Marks)
Chapter 7
1. Explain Backtracking Method. What is N-Queens Problem? Give solution of 4-Queens
Problem using Backtracking Method. W20, W21, S22 (7 Marks)
2. What is State Space Tree? How do you solve the Eight queens problem using
backtracking with the help of state space tree. S23 (7 Marks)
3. Explain Minimax Principal. W20, S22 (3-4 Marks)
4. Explain the Minimax Principle and show its working for simple tic-tac-toe game
playing. W22 (4 Marks)
5. Differentiate branch and bound and back tracking algorithm. W21 (4 Marks)
6. Differentiate between Backtracking and Branch-and-Bound algorithms. S23 (4 Marks)
7. Explain states, constraints types of nodes and bounding function used by backtracking
and branch and bound methods. W22 (4 Marks)
Chapter 8
1. What is Finite Automata? How it can be used in string matching? W20 (3 Marks)
2. What is Finite Automata? Explain use of finite automata for string matching with
suitable example. S22 (7 Marks)
3. What is string-matching problem? Define valid shift and invalid shift. S22 (3 Marks)
4. Explain Rabin-Karp string matching algorithm. W20 (7 Marks)
5. Explain spurious hits in Rabin-Karp string matching algorithm with example. Working
modulo q=13, how many spurious hits does the Rabin-Karp matcher encounter in the
text T = 2359023141526739921 when looking for the pattern P = 31415? W21 (7
Marks)
6. Show the comparisons that naïve string matcher makes for the pattern p=0001 in the
text T=000010001010001 W21 (4 Marks)
7. Write the pseudocode for Naïve String-Matching Algorithm. S23 (4 Marks)
8. Show that if all the characters of pattern P of size m are different, the naïve string
matching algorithm can perform better with modification. Write the modified algorithm
that performs better than O(n.m). W22 (4 Marks)
9. Create an example of string P of length 7 such that, the prefix function of KMP string
matcher returns π[5] = 3, π[3] = 1 and π[1] = 0 W22 (4 Marks)
Chapter 9
1. Explain P, NP, NP complete and NP-Hard problems. Give examples of each. W20,
W21, S22, S23 (4-7 Marks)
2. Explain “P = NP ?” problem. S22 (3 Marks)
3. Explain polynomial reduction. W21 (3 Marks)
4. Explain polynomial time reduction. S23 (3 Marks)
5. Explain the 3SAT problem and show that it is NP Complete. W22 (7 Marks)
6. Explain with example, how the Hamiltonian Cycle problem can be used to solve the
Travelling Salesman problem. W22 (7 Marks)
Download