Professional Documents
Culture Documents
if(n==0)
return 1;
else
return n* fact(n-1);
n2, n, ln n, n3, 2n
46. Determine minimal spanning tree for given graph using Kruskal’s algorithm.
47. Use Dijkstra’s algorithm for solving single source shortest path problem on a given directed
graph.
48. Implement the fractional knapsack problem using C. Let us consider that the capacity of the
knapsack W = 60 and the list of provided items are shown in the following table −
Item A B C D
Profit 80 10 20 30
Weight 40 5 10 4
49. Write an algorithm for Huffman tree. Construct a Huffman tree for the given text and the
text is “DESIGN AND ANALYSIS OF ALGORITHM”. Show binary encoding of each character.
50. Write an algorithm for Huffman tree. The frequency with which each character occurs in a
file is shown in the given table. Construct a Huffman tree corresponding to these frequencies
and show binary encoding of each character.
Character a b c d e f g h
Frequency 1 8 7 10 12 5 4 2
51. Write an algorithm Fractional Knapsack. Suppose the capacity of the knapsack is 30.
The Profit array is {25, 30, 40} and the corresponding Weight array is {10, 15,
18}.Find profit based on minimum weight.
52. What is the difference between fixed length codeword and variable length code word.
Explain with an example.
53. For the following graph having four nodes represented by the matrix given below
determine the all pairs source shortest path.
54. Discuss the classes P, NP, NP complete, and NP hard with examples. How can we
show that a problem is NP complete?
55. What do you understand by Polynomial time reducibility?
56. Use Floyd’s-Warshall’s algorithm to find the shortest paths for all pairs of vertices in
the given graph.
57. Write an algorithm for Selection Sort and sort the following elements: 7, 5, 4, 8, 12, 10, 9, 6,
2, 4
58. Write an algorithm for Bubble Sort and sort the following elements: 7, 5, 4, 8, 12, 10, 9, 6, 2,
4
59. Write an algorithm for Sequential search and search element from the following given
elements: 7, 5, 4, 8, 12, 10, 9, 6, 2, 4
60. Write an algorithm for Depth-First Search (DFS) and find its time complexity.
61. Write an algorithm for Breadth-First Search (BFS) and find its time complexity.
62. Show that the worst case running time of Quick sort algorithm is n2.
63. Define asymptotic notations. Write its type.
64. Write the master method of recurrence equation.
65. What do you mean by time complexity and space complexity of an algorithm?
66. Construct a Huffman tree for the given text and the text is “REPETITIVE
SENTENCE EXAMPLE”. Show binary encoding of each character.
67. Write short notes on Lower bounds for sorting
68. What are the different ways to traverse the binary tree?
69. Explain about the optimal binary search tree.
70. Write an algorithm of Brute Force search and find its time complexity.
71. Match the pattern P= ABB from the given text T = AAAAABBABBABBBACBBCAABCCCACCC by
using Brute Force search.
72. Differentiate between brute force search
73. and exhaustive search approach.