NEW
Font size
WorksheetsDAA-UNIT III
Total questions: 10
Worksheet time: 4mins
Which of the following standard algorithms is not Dynamic Programming based.
Bellman–Ford Algorithm for single source shortest path
Floyd Warshall Algorithm for all pairs shortest paths
0-1 Knapsack problem
Prim's Minimum Spanning Tree
An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array A[0 :n-1] is given below. Let Li denote the length of the longest monotonically increasing sequence starting at index i in the array.
Which of the following statements is TRUE?
The algorithm uses dynamic programming paradigm
The algorithm has a linear complexity and uses branch and bound paradigm
The algorithm has a non-linear polynomial complexity and uses branch and bound paradigm
The algorithm uses divide and conquer paradigm.
Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively can be multiplied is several ways with different number of total scalar multiplications. For example, when multiplied as ((M1 X M2) X (M3 X M4)), the total number of multiplications is pqr + rst + prt. When multiplied as (((M1 X M2) X M3) X M4), the total number of scalar multiplications is pqr + prs + pst. If p = 10, q = 100, r = 20, s = 5 and t = 80, then the number of scalar multiplications needed is
248000
44000
19000
25000
Which of the following algorithms is NOT a divide & conquer algorithm by nature?
Euclidean algorithm to compute the greatest common divisor
Heap Sort
Cooley-Tukey fast Fourier transform
Quick Sort
Maximum Subarray Sum problem is to find the subarray with maximum sum. For example, given an array {12, -13, -5, 25, -20, 30, 10}, the maximum subarray sum is 45.
The naive solution for this problem is to calculate sum of all subarrays starting with every element and return the maximum of all. We can solve this using Divide and Conquer, what will be the worst case time complexity using Divide and Conquer.
O(n)
O(nLogn)
O(Logn)
O(n^2)
What is the shortest path from node A to node F?
A -> B -> D -> F
A -> C -> B -> E -> F
A -> F
A -> C -> E -> F
Dijkstra's algorithm is based on which paradigm?
Greedy paradigm
Backtracking paradigm
Dynamic Programming paradigm
Divide and Conquer paradigm
Suppose you have coins of denominations 1, 3 and 4. You use a greedy algorithm, in which you choose the largest denomination coin which is not greater than the remaining sum. For which of the following sums, will the algorithm NOT produce an optimal answer?
20
12
6
5
You are given infinite coins of N denominations v1, v2, v3, ....., vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the time complexity of a dynamic programming implementation used to solve the coin change problem?
O(N)
O(S)
O(N2)
O(S*N)
For merging two sorted lists of size m and n into sorted list of size m+n, we require comparisons of
O(m)
O(n)
O(m+n)
O(logm + logn)
