Question Set Unit5 and Unit6
Question Set Unit5 and Unit6
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.
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.