0% found this document useful (0 votes)
14 views2 pages

Question Set Unit5 and Unit6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Question Set Unit5 and Unit6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit5

1. Write a dynamic programming algorithm to compute f(n) based on the following


recurrence relation:

2. What would the time complexity be if the recursive computation of the nth Fibonacci
number was optimized using memorization?
3. Given an undirected graph with 5 nodes (A, B, C, D, and E) represented by a weighted
matrix (where a weight of 0 indicates no edge and any positive value indicates the cost
of moving between vertices), perform the following:
i. Draw the corresponding simple, weighted, undirected graph based on the given
weighted matrix.
ii. Determine the minimum spanning tree (MST) of the graph using Kruskal's
algorithm.

4. Given an undirected graph G = (V,E), where V = {a, b, c, d, e, f, g, h, i, j, k} and the set of


edges E = {(d,i), (f,k), (g,i), (b,g), (a,h), (i,j), (d,k), (b,j), (d,f), (g,j), (a,e)}. Find connected
components in the given graph. List the vertices in each connected component. (Hint:
use Union-Find data structure)
5. Would Breadth-First Search (BFS) be appropriate for finding the shortest path between
two nodes in a weighted graph with arbitrary edge weights? If your answer is yes, provide
justification. If no, provide a counter example.
6. Is it possible to use the Depth-First Search (DFS) algorithm to determine the shortest-
path distance from the source to a reachable vertex in an unweighted graph? If your
answer is yes, provide justification; if no, provide a counter example.
7. Both Dijkstra's and BFS algorithms are used to find the shortest path in a graph. Can
they be used interchangeably? Explain your reasoning briefly.
8. Can a graph with non-distinct edge weights have more than one Minimum Spanning Tree
(MST)? If yes, provide an example. If no, provide justification.
9. Given a weighted graph GGG where weights can be negative, find the shortest path from
a source vertex s to a target vertex t. Write a dynamic programming algorithm to solve
this problem. Additionally, provide an example to demonstrate that Dijkstra's algorithm
fails to compute the shortest path in such cases.
10. The number of sub problems in the DP solution provided by the Bellman-Ford algorithm
of the shortest path problem is ———-?
11. Use the Kruskal’s algorithm to find an MST in the following graph.
12. Apply the Bellman-Ford algorithm to find the shortest paths from node A to all other
nodes in the given graph. Also, determine the shortest path distance from A to node C.

13. Using the linked-list representation for Union-Find with the weighted-union heuristic, a
sequence of mmm operations (including make-set, union, and find), where nnn of these
are make-set operations, is executed.
Demonstrate that the total time complexity of these operations is O(m+n log n).

Unit6
1. What is the benefit of randomization in quicksort algorithm ?
2. Consider the following skip-list:

Delete 50 from the list. Show the resultant skip list. How many comparisons are done in
the process?
Search 77 in the new skip list. How many comparisons are done in the process?
3. Given the list of elements: 10, 20, 14, 5, 6, 8, 11, 19, 25, 42, 18, 96, 35, 44, 3, determine
the 6th smallest element using the Randomized-Select algorithm.
The pivot indexes for the recursive steps are as follows:
First step: index 5
Second step: index 2
Third step: index 2
Fourth step: index 3
Fifth step: index 2
Determine in which of these recursive steps the partition was nearly balanced.

You might also like