Daa Assignment
Daa Assignment
ASSIGNMENT-1
ROLL NO.1.Show how Merge sort sorts the following sequences of keys in ascending order.
12, 22, 33, 44, 48, 56, 57, 65, 76, 84. Discuss the time complexity of Merge sort?
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE WELCOME TO THE CLASS
PATTERN: CLASS
ROLL NO 2. Show how quick sort sorts the following sequences of keys in ascending order.
112, 250, 350, 143, 148, 519, 177, 85,66, 94?
Discuss the time complexity of the quick sort algorithm for the above case?
Show that f(n)= 12n2+6n=O(n3)
ROLL NO.3.
Solve the all pair shortest path problem for the graph given below using floyds algorithm and find its
complexity.
Show how Merge sort sorts the following sequences of keys in ascending order.
112, 250, 350, 143, 148, 519, 177, 85,66, 94?
ROLL NO .4. Apply kruskal’s algorithm for the following graph. Write the kruskal’s algorithm to find the
minimum spanning tree.
ROLL NO .6. Explain the Knapsack problem using Greedy Method. Find an optimal solution to the
Knapsack instance with maximum capacity W=15, (P1, P2, P3…. P7)= (10,5,15,7,6,18,3)and
(w1,w2,w3….w7)= (2,3,5,7,1,4,1).
Show that f(n)= 4n2+7n+12=O(n2)
ROLL NO.7. Solve the given list using binary search.10,15,40,50,55,65,75,90,95 with key value=65 and
analyse the same.
Show that f(n)= 2n+10=ϴ(n)
ROLL NO .8. Solve the given list using Merge sort.75,40,10,90,50,95,55,15,65 and analyse the same.
Show the following equalities are correct:
i)2n2+6n+5=Օ(n3)
ROLL NO .9. Show how quick sort sorts the following sequences of keys in ascending order.
65,35,15,90,75,45,40,60,95,25,85,55. Discuss the time complexity of the quick sort algorithm for the above
case?
Show that f(n)= 3n3+20n2+5=O(n3)
ROLL NO.10.Solve the following problem using strassen’s matrix multiplication and find its time
complexity.
2345 6789
6382 and 2045
3806 7380
5432 9276
Show the following equalities are correct:
i)2n2+5= Ω(7n)
ROLL NO.11. Show how merge sort sorts the following sequences of keys in ascending order.
65,35,15,90,75,45,40,60,95,25,85,55. Discuss the time complexity of the merge sort algorithm for the above
case?
Show that f(n)= 8n3+27n2+10=O(n3)
ROLL NO .12. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to
the Knapsack instance with maximum capacity W=7, (P1, P2,P3,P4)= (1,4,5,7)and (w1,w2,w3,w4)=
(1,3,4,5).Find its time complexity.
Solve the problem using KNUTHMORRIS PRATT Algorithm:
TEXT: ALL ARE WELCOME TO THE CLASS
PATTERN: CLASS
ROLL NO .13. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to
the Knapsack instance with maximum capacity W=5, (P1, P2,P3,P4)= (12,10,20,15)and (w1,w2,w3,w4)=
(2,1,3,2).Find its time complexity.
Show that f(n)= 2n+10=O(n)
ROLL NO .14. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to
the Knapsack instance with maximum capacity W=4, (P1, P2,P3)= (18,16,6)and (w1,w2,w3)= (1,2,2).Find
its time complexity.
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE WELCOME TO THE CLASS
PATTER: WELCOME
ROLL NO .15. Explain the different methods used to find the GCD of two numbers with appropriate
examples.write the algorithm for the same.
Solve the all pair shortest path problem for the graph given below using floyds algorithm and find its
complexity.
ROLL NO.16.Explain selection sort with an example.write its algorithm and analyse its time complexity.
Solve the problem using KMP Algorithm:
TEXT: ALL ARE WELCOME TO THE CLASS
PATTER: WELCOME
ROLL NO.17.Explain Bitonic sort with an example.write its algorithm and analyse its time complexity.
Solve the problem using BOYER MOORE Algorithm:
TEXT: DESIGN AND ANALYSIS OF ALGORITHMS
PATTER: ALGORITHMS
ROLL NO .18.Explain bubble sort with an example.write its algorithm and analyse its time complexity.
Apply Dijkstra’s algorithm to find the shortest path for the problem given below.
ROLL NO.19.Explain brute force string matching algorithm with suitable example.write its algorithm and
analyse its complexity.
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE WELCOME TO THE COLLEGE
PATTERN: COLLEGE
ROLL NO .20. Explain the recursive algorithm for computing the fibonacci of some number
‘n’ and analyze the time complexity for the same.
Solve the problem using KMP Algorithm:
TEXT: ALL ARE WELCOME TO THE COLLEGE
PATTERN: COLLEGE
Solve the all pair shortest path problem for the graph given below using floyds algorithm and find its
complexity.
ROLL NO.23.Apply warshall,s algorithm to find the transitive closure of the digraph defined by the
following adjacency matrix.write its algorithm and find its complexity.
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0
Show that f(n)=4n2-64n+288=Ω(n2)
ROLL NO.24.Solve the all pair shortest path problem for given adjacency matrix graph using floyds
algorithm and find its complexity.
0 2 ∞ 1 8
6 0 3 2 ∞
∞ ∞ 0 4 ∞
∞ ∞ 2 0 3
3 ∞ ∞ ∞ 0
Sort the following lists by heap sort using array representation of heaps. a)QUICKSORT(in increasing order)
ROLL NO.25. Solve the all pair shortest path problem for given adjacency matrix graph using floyds
algorithm and find its complexity.
0 3 ∞ 1 7
6 0 2 3 ∞
∞ ∞ 0 4 ∞
∞ ∞ 3 0 2
5 ∞ ∞ ∞ 0
Construct a heap for the list 20,14,25,30,80,45,7,55 by the topdown algorithm. and insert the element 63,27
in the heap.
ROLL NO.26..Apply Dijkstra’s algorithm to find the shortest path for the problem given below.
ROLL NO.27.Explain the general framework for analysing the efficiency of an algorithm.
Explain the Knapsack problem using Dynamic programming. Find an optimal solution to the Knapsack
instance with maximum capacity W=10, (P1, P2,P3,P4)= (40,42,25,12)and (w1,w2,w3,w4)=
(4,7,5,3).Find its time complexity.
ROLL NO.28. Solve the problem using KNUTH MORRIS PRATTAlgorithm:
TEXT: DESIGN AND ANALYSIS OF ALGORITHMS
PATTERN: ALGORITHMS
Show How Binary Search Algorithm Using Divide And Conquer Techniques Work For The Following
Sequences Of Input. Key=44
12, 20, 30, 41, 63, 16, 87, 50, 66, 44 . Discuss the time complexity of Binary search?
ROLL NO.30.Solve the following sequences of input using KNUTH MORRIS PRATT algorithm.
TEXT: BEST OF LUCK.
PATTERN: LUCK
Discuss briefly the sequence of steps in designing and analysing an algorithm.
ROLL NO.31.Apply kruskal’s algorithm for the following graph. Write the kruskal’s algorithm to find the
minimum spanning tree.
ROLL NO 32.Apply Prim's algorithm for the following graph. Write the Prim's algorithm to find the
minimum spanning tree.
ROLL NO 34. Explain INSERTION sort with an example.write its algorithm and analyse its time
complexity.
Solve the following problem using Karatsuba’s algorithm (multiplication of large integers) and
analyse the same.
213561 x 123456
ROLL NO 35.Show how QUICK sort sorts the following sequences of keys in ascending
order. 12, 22, 33, 44, 48, 56, 57, 65, 76, 84. Discuss the time complexity of QUICK sort?
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE INVITED TO THE COLLEGE
PATTERN:COLLEGE
ROLL NO 36.Show how MERGE sort sorts the following sequences of keys in ascending order. 12,
25, 35, 43, 48, 59, 77, 85, 86, 94?
Discuss the time complexity of the MERGE sort algorithm for the above case?
Show that f(n)= 9n2+2n=O(n3)
ROLL NO 37.Solve the given list using binary search.30,15,85,60,95,25,35,90,52 with key value=52 and
analyse the same. Write an algorithm for recursive binary search?
Solve the all pair shortest path problem for the graph given below using floyds algorithm and find its
complexity.
ROLL NO 38.Apply PRIMS’s algorithm for the following graph. Write the PRIM’s algorithm to find the
minimum spanning tree.
Show that f(n)=20n+120=O(n2)
ROLL NO 39.Apply KRUSKAL's algorithm for the given graph. Write the KRUSKAL's algorithm to find
the minimum spanning tree.
ROLL NO 40. Explain the Knapsack problem using Greedy Method. Find an optimal solution to the
Knapsack instance with maximum capacity W=20, (P1, P2, P3…. P7)= (10,5,15,7,6,18,3)and
(w1,w2,w3….w7)= (2,3,5,7,1,4,1).
Show that f(n)= 7n2+5n+10=O(n2)
ROLL NO 41. Solve the given list using binary search.10,15,40,50,55,65,75,90,95 with key value=95 and
analyse the same.
Show that f(n)= 15n+10=ϴ(n)
ROLL NO 42. Solve the given list using QUICK sort.75,40,10,90,50,95,55,15,65 and analyse the same.
Show the following equalities are correct: i)100n+54=Օ(n2)
ROLL NO 43. Show how MERGE sort sorts the following sequences of keys in ascending order.
65,35,15,90,75,45,40,60,95,25,85,55. Discuss the time complexity of the MERGE sort algorithm for the
above case?
Show that f(n)= 6n3+80n2+7=O(n3)
ROLL NO 44. Solve the following problem using strassen’s matrix multiplication and find its time
complexity.
2345 6709
6382 and 2075
3506 7320
57 3 2 9276
Show the following equalities are correct:
i)12n2+4= Ω(8n)
ROLL NO 46. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to the
Knapsack instance with maximum capacity W=9, (P1, P2,P3,P4)= (1,4,5,7)and (w1,w2,w3,w4)=
(1,3,4,5).Find its time complexity.
Solve the list 25,18,26,60,12,27,47,62 using bitonic sort.
ROLL NO 47. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to the
Knapsack instance with maximum capacity W=7, (P1, P2,P3,P4)= (12,10,20,15)and (w1,w2,w3,w4)=
(2,1,3,2).Find its time complexity.
Show that f(n)= 12n+10=O(n)
ROLL NO 48. Explain the Knapsack problem using Dynamic programming. Find an optimal solution to the
Knapsack instance with maximum capacity W=3, (P1, P2,P3)= (18,16,6)and (w1,w2,w3)= (1,2,2).Find its
time complexity.
Find the maximum and minimum element for the list 200,140,250,300,80,45,70,58 using divide and conquer
techniques and analyze the same.
ROLL NO 49. Explain the different methods used to find the GCD of two numbers with appropriate
examples. write the algorithm for the same.
Solve All pair shortest path problem for the graph given below using Floyds algorithm and find its
complexity.
ROLL NO 50.
Solve the all pair shortest path problem for given adjacency matrix graph using floyds algorithm and find
its complexity.
0 5 ∞ 1 7
6 0 3 2 ∞
∞ ∞ 0 2 ∞
∞ ∞ 2 0 3
6 ∞ ∞ ∞ 0
Sort the following lists by heap sort using array representation of heaps. a)SELECTIONSORT (MAXHEAP)
ROLL NO 51. Show how QUICK sort sorts the following sequences of keys in ascending
order. 122, 223, 133, 404, 418, 256, 157, 165, 276, 184. Discuss the time complexity of
QUICK sort?
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE INVITED TO THE CLASS
PATTERN:CLASS
ROLL NO.52.Show how Merge sort sorts the following sequences of keys in ascending
order. 112, 422, 233, 44, 408, 516, 357, 165, 176, 824. Discuss the time complexity of Merge
sort?
Solve the problem using Boyer Moyer Algorithm:
TEXT: ALL ARE WELCOME TO THESE COURSE
PATTERN: COURSE
ROLL NO 53. Show how quick sort sorts the following sequences of keys in ascending order.
2,5, 3, 4, 8, 9, 7, 6, 16, 14?
Discuss the time complexity of the quick sort algorithm for the above case?
Show that f(n)= 12n3+6n=O(n3)
ROLL NO.54.
Solve the problem for the graph given below using DIJKSTRA’S algorithm and find its complexity.
Show how merge sort sorts the following sequences of keys in ascending order. 2,5, 3, 4, 8, 9, 7, 6, 16,
14?
ROLL NO .55. Apply PRIMS algorithm for the following graph. Write the PRIMS algorithm to find the
minimum spanning tree.
ROLL NO.56. Apply KRUSKALS algorithm for the given graph. Write the KRUSKALS algorithm to find
the minimum spanning tree.
ROLL NO .57 Explain the Knapsack problem using Greedy Method. Find an optimal solution to the
Knapsack instance with maximum capacity W=12, (P1, P2, P3…. P7)= (10,5,15,7,6,18,3)and
(w1,w2,w3….w7)= (2,3,5,7,1,4,1).
Show that f(n)= 4n2+10n+22=O(n3)
ROLL NO.58. Solve the given list using binary search. 110,125,240,510,55,605,715,190,95 with key
value=95 and analyse the same.
Show that f(n)= 2n3+3n2+2n+10=ϴ(10n4)
ROLL NO .59. Solve the given list using Merge sort. 275,140,210,590,350,195,155,215,165 and analyse
the same. Show the following equalities are correct:
i)12n+18=Օ(n3)
ROLL NO 301. Explain the recursive algorithm for computing the fibonacci of some number
‘n’ and analyze the time complexity for the same.
Sort the following lists by heap sort using array representation of heaps. 1,19,8,74,60,57,45,30,21,11
(MIN HEAP)
ROLL NO 302. Explain INSERTION sort with an example. write its algorithm and analyse its time
complexity.
Apply PRIMS algorithm to find the MINIMUM SPANNING TREE for the problem given below.
ROLL NO 303. Explain SELECTION sort with an example. write its algorithm and analyse its time
complexity.
Apply Dijkstra’s algorithm to find the shortest path for the problem given below.