Professional Documents
Culture Documents
QB MPS
QB MPS
if(n==0)
return 1;
else
return n* fact(n-1);
n2, n, ln n, n3, 2n
37. Determine minimal spanning tree for given graph using Kruskal’s algorithm.
38. Use Dijkstra’s algorithm for solving single source shortest path problem on a given directed
graph.
39. 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
40. 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.
41. 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
42. 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.
43. What is the difference between fixed length codeword and variable length code word.
Explain with an example.
44. For the following graph having four nodes represented by the matrix given below
determine the all pairs source shortest path.
45. Discuss the classes P, NP, NP complete, and NP hard with examples. How can we
show that a problem is NP complete?
46. What do you understand by Polynomial time reducibility?
47. Use Floyd’s-Warshall’s algorithm to find the shortest paths for all pairs of vertices in
the given graph.
48. Write an algorithm for Selection Sort and sort the following elements: 7, 5, 4, 8, 12, 10, 9, 6,
2, 4
49. Write an algorithm for Bubble Sort and sort the following elements: 7, 5, 4, 8, 12, 10, 9, 6, 2,
4
50. Write an algorithm for Sequential Sort and sort the following elements: 7, 5, 4, 8, 12, 10, 9,
6, 2, 4
51. Write an algorithm for Depth-First Search (DFS) and find its time complexity.
52. Write an algorithm for Breadth-First Search (BFS) and find its time complexity.