Question Bank 1to11
Question Bank 1to11
Sr.
Questions
No.
3 What is an algorithm?
Sr.
Questions
No.
What is the smallest value of n such that an algorithm whose running time is 100n2 runs faster than an algorithm whose running
1
time is 2n on the same machine?
2 What do you mean by asymptotic notation? Describe in brief any three asymptotic notations used for algorithm analysis.
Let f(n) and g(n) be asymptotically nonnegative functions. Using the basic definition of Θ-notation, prove that
3
max(f(n), g(n)) = Θ (f(n) + g(n)).
6 Write down the Best case, Worst Case and Average case Complexity for selection sort.
7 Write down the Best case, Worst Case and Average case Complexity for Heap sort.
10 Why do we use asymptotic notations in the study of algorithms? Briefly describe the commonly used asymptotic notations.
11 What is an amortized analysis? Explain aggregate method of amortized analysis using suitable example
12 Sort the letters of word “EDUCATION” in alphabetical order using insertion sort.
Define Following:
13
(I) Big ‘Oh’ Notation
(II) Big ‘Omega’ Notation
14 Sort the given elements with Heap Sort Method: 20, 50, 30, 75, 90, 60, 25, 10, 40.
15 Which are the basic steps of counting sort? Write counting sort algorithm.
Sr.
Questions
No.
1 What do you mean by Divide & Conquer approach?List advantages and disadvantages of it.
2 Solve the following recurrence relation using iteration method. T(n) = 8T(n/2)+n2 Here T(1) = 1.
3 Solve the following recurrence relation using substitution method. T(n) =2T(n/2) + n. Here T(1) = 1.
Write Merge sort algorithm and compute its worst case and best-case time complexity. Sort the List G,U,J,A,R,A,T in
5
alphabetical order using merge sort.
6 Demonstrate Binary Search method to search Key = 14, form the array A=<2,4,7,8,10,13,14,60> .
7 Explain Tower of Hanoi Problem, Derive its recursion equation and computer it’s time complexity.
8 Write down the Best case, Worst Case and Average case Complexity for merge sort.
Explain the use of Divide and Conque Technique for Binary Search Method.What is Complexity of Binary Search
13
Method?Explain it with Example.
What is recurrence? Solve recurrence equation T (n) =T (n-1) + n using forward substitution and backward substitution
16
method.
Write an algorithm for quick sort and derive best case, worst case using divide and conquer technique also trace given data
17
(3,1,4,5,9,2,6,5)
18 Solve following recurrence using recursion tree method: T(n) = 3T(n/3) +n^3
Write standard(conventional) algorithm and Strassen's algorithm for matrix algorithm for matrix multiplication problem. What
19
is the recurrence for Strassen's algorithm?Solve it using master method to derive time complexity of Strassen's algorithm
20 Discuss best case, average case and worst case time complexity of quick sort.
UNIT:4 DYNAMIC PROGRAMMING
Sr.
Questions
No.
Find optimal sequence of multiplication using dynamic programming of following matrices: A1[10x100], A2[100x5], A3[5x50]
2
and A4[50x1]. List optimal number of multiplication and parenthesization of matrices.
Describe longest common subsequence problem. Find longest common subsequence of following two strings X and Y using
3
dynamic programming. X=abbacdcba, Y=bcdbbcaac.
4 Discuss and derive an equation for solving the 0/1 Knapsack problem using dynamic programming method.
5 Consider Knapsack capacity W=9, w = (3,4,5,7) and v=(12,40,25,42).find the maximum profit using dynamic method.
6 Solve Making change problem using dynamic technique. d1 = 1, d2=2,d3=4, d4=6, Calculate for making change of Rs. 10.
8 For the following chain of matrices find the order of parenthesization for the optimal chain multiplication (13,5,89,3,34).
11 Solve Making change problem using dynamic technique. D1 = 1, d2=3, d3=5, d4=6. Calculate for making change of Rs. 8.
12 Given two sequence of characters, X={G,U,J,A,R,A,T}, Y = {J,R,A,T} obtain the longest common subsequence.
13 For the following chain of matrices find the order of parenthesization for the optimal chain multiplication (15,5,10,20,25)
14 Discuss Assembly Line Scheduling problem using dynamic programming with example.
Write equation for Chained matrix multiplication using Dynamic programming. Find out optimal sequence for multiplication:
16
A1 [5 × 4], A2 [4 × 6], A3 [6 × 2], and A4 [2 × 7]. Also give the optimal parenthesization of matrices.
Explain how to find out Longest Common Subsequence of two strings using Dynamic Programming method. Find any one
17 Longest Common Subsequence of given two strings using Dynamic Programming.
X=abbacdcba
Y=bcdbbcaac
Solve Making Change problem using Dynamic Programming. (Denominations: d1=1, d2=4, d3=6). Give your answer for
18
making change of Rs. 9.
19 What are the advantages of dynamic programming method over devide conquer method?
Which are the three basic steps of the development of the dynamic programming algorithm? Mention any two examples of
20
dynamic programming that we are using in real life.
Solve the following making change problem using dynamic programming method: Amount = Rs. 7 and Denominations: (Rs. 1,
21
Rs. 2 and Rs. 4)
UNIT:5 GREEDY ALGORITHM
Sr.
Questions
No.
2 Prove that the fractional knapsack problem has the greedy-choice property.
Suppose that we have a set of activities to schedule among a large number of lecture halls, where any activity can take place in any lecture hall.
4 We wish to schedule all the activities using as few lecture halls as possible. Give an efficient greedy algorithm to determine which activity should
use which lecture hall.
Find out the Minimum Spanning Tree using Kruskal Algorithm for given Graph.
Find all pair of shortest path using Floyd’s Algorithm for given graph
9 Find an optimal Huffman code for the following set of frequency. a : 50, b: 20, c: 15, d: 30.
10 Consider Kanpsack capacity W=50, w=(10,20,40) and v=(60,80,100) find the maximum profit using greedy approach.
12 Define MST. Explain Kruskal’s algorithm with example for construction of MST.
13 Explain in brief characteristics of greedy algorithms. Compare Greedy Method with Dynamic Programming Method.
Write the Prim’s Algorithm to find out Minimum Spanning Tree. Apply the same and find MST for the graph given below.
14
Write Huffman code algorithm and Generate Huffman code for following
15 Letters A B C D E
Frequency 24 12 10 8 8
Using greedy algorithm find an optimal schedule for following jobs with n=6.
16
Profits: (P1,P2,P3,P4,P5,P6) = (20, 15, 10, 7, 5, 3)
Deadline: (d1,d2,d3,d4,d5,d6) =(3, 1, 1, 3, 1, 3)
17 Justify with example that shortest path problem satisfies the principle of optimality.
18 Discuss general characteristics of greedy method. Mention any two examples of greedy method that we are using in real life.
19 Solve all pair shortest path problem for the following graph using Floyd's algorithm.
20 What are the disadvantages of greedy method over dynamic programming Method?
Solve the following Knapsack Problem using greedy method. Number of items = 5, knapsack capacity W = 100, weight vector = {50, 40, 30, 20,
21
10} and profit vector = {1, 2, 3, 4, 5}.
Find minimum spanning tree for the following undirected weighted graph using Kruskal’s algorithm.
23
UNIT:6 EXPLORING GRAPHS
Sr.
Questions
No.
List applications of a minimum spanning tree. Find minimum spanning tree using Krushkal’s algorithm of the following graph.
Given an adjacency-list representation of a directed graph, how long does it take to compute the out-degree of every vertex?
4
How long does it take to compute the in-degrees?
Define minimum spanning tree. Find minimum spanning tree using Prim’s algorithm of the following graph.
14 Explain Depth First Traversal Method for Graph with algorithm with example.
15 Explain Breath First Traversal Method for Graph with algorithm with example.
16 Justify with example that longest path problem does not satisfy the principle of optimality.
What is DFS? Explain with example. Show the ordering of vertices produced by Topological sort for the following graph.
17
Sr.
Questions
No.
Solve the following instance of knapsack problem using Backtracking Technique. The Capacity of the Knapsack W = 8 and w = (2,3,4,5)
3
and value v = (3,5,6,10)
7 Explain Backtracking Method. What is N-Queens Problem? Give solution of 4 Queens Problem using Backtracking Method.
8 Explain use of branch and bound technique for solving assignment problem.
UNIT:8 STRING MATCHING
Sr.
Questions
No.
1 Show the comparisons the naive string matcher makes for the pattern P=0001 in the text T=000010001010001.
Working modulo q=11, how many spurious hits does the Rabin-Karp matcher encounter in the text T=3141592653589793 when
2
looking for the pattern P=26?
5 What is Finite Automata? Explain use of finite automata for string matching with suitable example.
6 What is Rabin Karp algorithm? Where it is used? Explain the concept behind this algorithm and calculate its time complexity
What is the basic idea behind Rabin – Karp algorithm? What is expected running time of this algorithm ? Explain it with
7
example.
9 Write Naive string matching algorithm. Explain notations used in the algorithm.
UNIT:9 INTRODUCTION TO NP-COMPLETENESS
Sr.
Questions
No.
1 State whether travelling salesman problem is a NP-Complete problem? Justify your answer.
2 Prove that if G is an undirected bipartite graph with an odd number of vertices, then G is nonhamiltonian.
9 Which are the three major concepts used to show that a problem is an NP Complete problem?
QUESTION BANK
UNIT:1 INTRODUCTION
Sr.
Questions
No.
1 Define an algorithm. List various criteria used for analyzing an algorithm.
2 Define Algorithm, Time Complexity and Space Complexity
3 What is an algorithm?
4 What is worst case time complexity ?
5 Define space complexity.
6 Define Big Omega Asymptotic Notation.
7 Define Feasible Solution.
8 What is vector? Which operations are performed on vector?
9 List types of algorithms
10 Define Following: Quantifier, Algorithm
11 Define Algorithm. Discuss key characteristics of algorithm.
12 Prove or disprove that f(n) = 1 + 2 + 3 + .... + n Θ (n^2
Write Huffman code algorithm and Generate Huffman code for following
Letters A B C D E
15
Frequenc
y 24 12 10 8 8
16 Using greedy algorithm find an optimal schedule for following jobs with n=6.
17 Justify with example that shortest path problem satisfies the principle of optimality.
18 Discuss general characteristics of greedy method. Mention any two examples of greedy method that we
19 Solve all pair shortest path problem for the following graph using Floyd's algorithm.
20 What are the disadvantages of greedy method over dynamic programming Method?
21 Solve the following Knapsack Problem using greedy method. Number of items = 5, knapsack capacity
22 Write an algorithm for Huffman code.
Find minimum spanning tree for the following undirected weighted graph using Kruskal’s algorithm.
23
election sort.
eap sort.
10, 40.
LGORITHM
sadvantages of it.
n/2)+n2 Here T(1) = 1.
T(n/2) + n. Here T(1) = 1.
MMING
THM
of lecture halls, where any activity can take place in
Graph.
f MST.
hod with Dynamic Programming Method.
e same and find MST for the graph given below.
=6.
ptimality.
es of greedy method that we are using in real life.
lgorithm.
Method?
ems = 5, knapsack capacity W = 100, weight vector
PHS
CH & BOUND
NG
ithm.
leteness
h.
ximation algorithm.
Complete problem?