Professional Documents
Culture Documents
4) Execute the Depth First Search algorithm on given graph. (Assume starting node as H).
Show the result step by step and then write the final answer.
5) Execute Kruskal’s algorithms in the following graph? Explain each step clearly.
6) Execute Prim’s algorithm in the following graph? (Choose starting vertex as D)
7) Knapsack (0-1) problem: The Integer Knapsack Problem (Duplicate Items Permitted). You have n types
of items, where the ith item type has a weight si and a benefit vi. Here items are indivisible, you either
take an item(1) or not(0). You can add multiple items of the same type to the knapsack.
Suppose there are three items and Knapsack has capacity 50. Item 1 has weight 10, benefit 60. Item 2
has weight 20, benefit 100. Item 3 has weight 30, benefit 120.
Using Greedy algorithm, find the maximum amount the knapsack can contain?
9) Apply Floyd-Warshall algorithm for the following graph? Explain space complexity also.
10) Apply quick sort algorithm to sort the following list of elements. Find its complexity also?
9, 5, 8, 7, 4, 2, 6, 11, 21, 13, 19, 12
11. LCS. Find the LCS of < 1; 0; 1; 1; 0; 1; 1; 1 > and < 0; 1; 0; 1; 1; 0; 1; 1; 0 > using DP.
Write recursive equation and required table.
12. What is Heap? Write the heap (Build heap) of the following numbers. (direct write the
heap) 25; 37; 48; 37; 12; 92; 86; 103
After building the heap, show first four steps of the heap sort. (show the heap after one
element, second element , third element and fourth element is sorted)
Discuss the running time of heap sort.