0% found this document useful (0 votes)
54 views15 pages

Algorithm Basics and Analysis Techniques

The document outlines various units covering fundamental concepts of algorithms, including definitions, properties, and analysis techniques. It discusses sorting algorithms, dynamic programming, greedy algorithms, graph theory, backtracking, string matching, and NP-completeness. Each unit contains specific problems and examples to illustrate the application of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views15 pages

Algorithm Basics and Analysis Techniques

The document outlines various units covering fundamental concepts of algorithms, including definitions, properties, and analysis techniques. It discusses sorting algorithms, dynamic programming, greedy algorithms, graph theory, backtracking, string matching, and NP-completeness. Each unit contains specific problems and examples to illustrate the application of the concepts discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit – 1 – Basics of Algorithm and Mathematics

1. What is an algorithm? Explain various properties of an algorithm.


2. Define Algorithms and characteristics of algorithms.
Unit – 2 – Analysis of Algorithm

1. Find Omega (Ω) notation of function f(n)=2n² + n * log n + 6n


2. Define Big-oh and Theta notations with graph.
3. Write and analyze an insertion sort algorithm to sort n items into ascending order.
4. Solve following recurrence using Master Theorem:
T(n) = 3T(n/3) + n³
5. What is recurrence? Explain recursion-tree method with suitable example.
6. Solve the following using Master’s theorem:
A. T(n) = 2T(n/4) + 1
B . T(n)=3T(n/4) + n * log n
7. Write selection sort algorithm and compute running time of algorithm.
8. What is asymptotic notation? Find out big-oh notation of the f(n) = 3n²+5n+10
9. Explain Tower of Hanoi Problem, Derive its recursion equation and compute it’s time
complexity.
10. Give the properties of Heap Tree. Sort the following data using Heap Sort Method:
20, 50, 30, 75, 90, 60, 80, 25, 10, 40.
11. Apply counting sort for the following numbers to sort in ascending order.
3, 1, 2, 3, 3, 1
12. Define following terms: (i) Big O Notation, (ii) Big Theta Notation, (iii) Big Omega
Notation.
13. Perform Bucket sort for following sequence: 30, 12, 22, 66, 48, 27, 35, 43, 47, 41.
14. Explain the bubble sort algorithm and derive its best case, worst case, And average
case time complexity.
15. What is a recurrence? Solve recurrence equation for T (n) =T (n-1) + 1 using
substitution method.
16. State whether the statements are correct or incorrect with reasons.
1. O(f(n)) + O(f(n)) = O (2f(n))
2. If 3n + 5 = O(n²) then 3n + 5 = o(n²)
17. Explain asymptotic analysis with all the notations and its mathematical Inequalities.
18. What is the use of Loop Invariant? What should be shown to prove that an algorithm
is correct?
19. Perform the analysis of a recurrence relation T(n)= 2𝑇 (n/2) + 𝜃(𝑛²) Drawing its
recurrence tree.
20. Define Algorithm, Time Complexity and Space Complexity.
21. Explain: Worst Case, Best Case and Average Case Complexity With suitable
example.
22. Write an algorithm of Selection Sort Method.
23. Write the Master theorem. Solve following recurrence using it.
(i)T(n)= T(n/2) + 1
(ii) T(n)=2T(n/2) + n log n
24. 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
Unit – 3 – Divide and conquer technique

1. Illustrate the working of the quick sort on input instance: 25, 29, 30, 35, 42, 47, 50,
52, 60. Comment on the nature of input i.e. best case, average case or worst case.
2. Illustrate the working of the quick sort on input instance: 25, 29, 30, 35, 42, 47, 50,
52, 60. Comment on the nature of input i.e. best case, average case or worst case.
Also discuss worst and best case of quick sort algorithm.
3. Demonstrate Binary Search method to search Key = 14, form the array
A=<2,4,7,8,9,10,12,14,18>
4. Demonstrate Binary Search method to search Key = 14, form the array A =
<2,4,7,8,10,13,14,60>. / Demonstrate Binary Search method to search Key = 14,
form the array A=<2,4,7,8,10,13,14,60>
5. Sort the List “G,U,J,A,R,A,T,S,A,R,K,A,R” in alphabetical order using merge Sort.
6. Discuss Binary search algorithm, also write and solve its recurrence Relation.
7. Explain Merge Sort algorithm with suitable example.
8. Sort the best case running times of all these algorithms in a non-decreasing Order.
LCS, Quick-Sort, Merge-Sort, Counting-Sort, Heap-Sort, Selection-Sort, Insertion-
Sort, Bucket-Sort, Strassen’s Algorithm.
9. Write and explain the recurrence relation of Merge Sort.
10. 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.
11. 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.
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.
Unit – 4 – Dynamic programming

1. What is Principle of Optimality? Explain its use in Dynamic Programming Method. /


What is Principle of Optimality? Explain its use in Dynamic Programming Method.
2. Explain Binomial Coefficient algorithm using dynamic programming.
3. Obtain longest common subsequence using dynamic programming. Given A =
“acabaca” and B = “bacac”.
4. Consider a Knapsack with the maximum weight capacity M is 7, for the objects With
value [12,10,20,15] with weights [2,1,3,2] solve using dynamic programming the
maximum value the knapsack can have.
5. Find all pair of shortest path using Floyd’s Algorithm for following graph.

6. Using algorithm find an optimal parenthesization of a matrix chain product Whose


sequence of dimension is (5,10,3,12,5,50,6) (use dynamic programming).
7. 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)
8. Given coins of denominations 2, 3 and 4 with amount to be pay is 5. Find optimal
No. of coins and sequence of coins used to pay given amount using dynamic
Method.
9. Find out the NCR (5 3) Using Dynamic Method.
10. Explain principle of optimality with suitable example.
11. Explain advantages and disadvantages of dynamic programming.
12. Given the denominations: d1=1, d2=4, d3=6. Calculate for making Change of Rs. 8
using dynamic programming.
13. 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.
14. Apply LCS on sequence <A,B,A,C,B,C> for pattern <A,B,C>
15. 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

16. 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.
17. Explain Over-lapping Sub-problem with respect to dynamic Programming.
18. Find out LCS of A={K,A,N,D,L,A,P} and B = {A,N,D,L}
19. Discuss Assembly Line Scheduling problem using dynamic programming with
example.
Unit – 5 – Greedy Algorithm

1. Explain the steps of greedy strategy for solving a problem. / Explain the steps of
greedy strategy for solving a problem.
2. What is a minimum spanning tree? Draw the minimum spanning tree correspond to
following graph using Prim’s algorithm.

3. 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)
4. Solve the following Knapsack Problem using greedy method. Number of items = 5,
knapsack capacity W = 100, weight vector = {50, 40, 30, 20, 10} and profit vector =
{1, 2, 3, 4, 5}. / Solve the following knapsack problem using greedy method. Number
of items = 5, knapsack capacity W = 100, weight vector = {50,40,30,20,10} and profit
vector = {1,2,3,4,5}.
5. What are the disadvantages of greedy method over dynamic programming method?
6. Find an optimal Huffman code for the following set of frequency. A : 50, b: 20, c: 15,
d: 30
7. Explain general characteristics of greedy algorithms. / Give the characteristics of
Greedy Algorithms.
8. Following are the details of various jobs to be scheduled on multiple processors
Such that no two processes execute at the same on the same processor. Show
Schedule of these jobs on minimum number of processors using greedy approach.
Jobs. J1 J2 J3 J4 J5 J6 J7
Start time 0 3 4 9 7 1 6
Finish time 2 7 7 11 10 5 8
9. Find the Optimal Huffman code for each symbol in following text
ABCCDEBABFFBACBEBDFAAAABCDEEDCCBFEBFCAE
10. Write the Kruskal’s Algorithm to find out Minimum Spanning Tree. Apply the Same
and find MST for the graph given below.

11. Discuss advantages and disadvantages of greedy algorithm.


12. Find an optimal Huffman code for the following set of frequency. a : 40, b: 20, c: 15,
d: 30, e: 10.
13. Draw the minimum spanning tree correspond to following graph using Prim’s
algorithm and find the MST weight:

14. Differentiate between Kruskal’s algorithm and Prim’s algorithm for finding MST.
15. Draw the minimum spanning tree correspond to following graph using Kruskal’s
algorithm and find weight of MST:

16. "A greedy strategy will work for fractional Knapsack problem but not for 0/1", is this
true or false? Explain.
17. Apply Kruskal’s algorithm on the given graph and step by step generate the MST.

18. Apply Prim’s algorithm on the given graph in Q.3 (C) FIG:1 Graph G(V,E) and step by
step generate the MST.
19. When can we say that a problem exhibits the property of Optimal Sub-Structure?
20. Give difference between greedy approach and dynamic Programming.
21. Consider Knapsack capacity W=15, w = (4, 5, 6, 3) and v=(10, 15, 12, 8) find the
maximum profit using greedy method.
22. Find Minimum Spanning Tree for the given graph using Prim’s Algorithm.

23. Explain Huffman code with Example.


24. Write the Kruskal’s Algorithm to find out Minimum Spanning Tree. Apply the same
and find MST for the graph given below.

25. Explain fractional knapsack problem with example.


Unit – 6 – Exploring graphs

1. Explain: Articulation Point, Graph, Tree / Explain: Articulation Point, Graph, Tree
2. Define BFS. How it is differ from DFS.
3. Write an algorithm to find out the articulation points of an undirected graph. Find out
articulation points for the following graph. Consider vertex 0 as the starting point.

4. Traverse the following graph using Breadth First Search Technique. Also draw BFS
Tree for a given graph.

5. Explain Weighted Graph, Undirected Graph, Directed Graph.


6. Explain depth first traversal using suitable example.
7. Explain the need of topological Sort with example.
8. Apply the algorithm to find strongly connected components from the Given graph.

9. Given is the DAG, apply the algorithm to perform topological sort and show the
sorted graph.

10. Explain Breath First Traversal Method for Graph with algorithm with example.
Unit – 7 – Backtracking and branch and bound

1. Draw the state space tree Diagram for 4 Queens problem.


2. Solve the following Task Assignment problem for minimization using following Cost
matrix. (Cost matrix represents cost of Task T performed by Person P).
T1 T2 T3
P1 10 20 25
P2 20 23 26
P3 12 16 25
3. Explain Backtracking Method. What is N-Queens Problem? Give solution of 4
Queens Problem using Backtracking Method.
4. What is state space tree. How do you solve the Eight queens problem Using
backtracking with the help of state space tree.
5. Differentiate between Backtracking and Branch-and-Bound Algorithms.
6. Explain states, constraints types of nodes and bounding function used by
Backtracking and branch and bound methods.
7. Explain the Minimax principle and show its working for simple tic-tac-toe game
Playing.
8. Explain Backtracking Method. What is N-Queens Problem? Give Solution of 4-
Queens Problem using Backtracking Method.
9. Explain Minimax principal.
Unit – 8 – String matching

1. Explain the naive string matching algorithm.


2. 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?
3. 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 =
26739?
4. Explain Spurious hits with an example.
5. Write the pseudocode for Naïve String-Matching Algorithm.
6. 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
7. 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).
8. What is string-matching problem? Define valid shift and invalid shift.
9. What is Finite Automata? Explain use of finite automata for string Matching with
suitable example.
Unit – 9 – Introduction to NP-completeness

1. Define NP-Complete and NP-Hard problems.


2. Define P, NP, NP-complete, NP-Hard problems. Give examples of each.
3. Explain in Brief: Polynomial reduction.
4. Explain polynomial time reduction.
5. Define P, NP, NP complete and NP-Hard problems. Give examples of Each.
6. Explain the 3SAT problem and show that it is NP Complete.
7. Explain with example, how the Hamiltonian Cycle problem can be used to solve The
Travelling Salesman problem.
8. Define P, NP, NP-Hard and NP-Complete Problem.
9. Explain “P = NP ?” problem.

You might also like