Dsa 1
Dsa 1
Q.2. Illustrate the performance of the merge sort algorithm on the input sequence:
2,5,16,4,10,23,39,18. [10]
Q.3. Illustrate the operation of the dynamic programming algorithm to solve the longest
common subsequence problem on the sequences 1, 0, 0, 1, 0, 1, 0, 1 and 0, 1, 0, 1,
1, 0, 1, 1, 0. [10]
Q.4. Let A[1…n] be an array of n distinct numbers. If i < j and A[i] > A[j], then the
pair (i, j) is called an inversion of A.
(a). Which array with elements from the set {1,2,…n} has the most inversions?
How many does it have?
(b). Describe an algorithm that determines the number of inversions in any
permutation on n elements in Θ(n logn) worst case time. [4 + 6 = 10]
Q.5. Suppose we are given a set of tasks specified by pairs of the start times and finish
times as T = {(1,2), (1,3), (1,4), (2,5), (3,7), (4,9), (5,6), (6,8), (7,9)}. Solve the
task scheduling (activity selection) problem for this set of tasks. [10]
Q.6. Find the minimum cost spanning tree for the following graph using Kruskal’s
algorithm? [10]
B
10 28
A E
14 8
25 D
24
G
C 11
22
15
F