You are on page 1of 4

NATIONAL INSTITUTE OF TECHNOLOGY

TIRUCHIRAPPALLI - 620 015, TAMIL NADU, INDIA

DEPT. OF COMPUTER SCIENCE AND ENGINEERING

Time: 9:30 AM to 2:00 PM


CT – 2

1) Create the binary search tree with following nodes as data.


(read the data from left to right)
7, 8, 2, 5, 11, 19, 4, 10, 6, 13, 9, 12, 14, 3.
1) Insert 15
2) Search 13
3) Delete 9
4) Delete 2

2) Answer the following questions?


a) Write the adjacency matrix and adjacency list representations of the given graph. How much
space is required?

b) Given adjacency matrix, draw the graph.


3) Execute the Breadth First Search algorithm on given graph.

a) Show the order of vertices in BFS (Assume starting node as A).


b) Show the shortest distance of vertices of the graph from source. Discuss the time complexity of
the algorithm.

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?

8) Find an optimal parameterization of a matrix-chain product whose sequence of dimensions is


< 5, 4, 6, 2, 7 > using DP. Write recursive equation, M table and S table

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.

You might also like