wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DAA-UNIT III

Total questions: 10

Worksheet time: 4mins

Name
Class
Date
1.

Which of the following standard algorithms is not Dynamic Programming based.

a)

Bellman–Ford Algorithm for single source shortest path

b)

Floyd Warshall Algorithm for all pairs shortest paths

c)

0-1 Knapsack problem

d)

Prim's Minimum Spanning Tree

2.

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?

a)

The algorithm uses dynamic programming paradigm

b)

The algorithm has a linear complexity and uses branch and bound paradigm

c)

The algorithm has a non-linear polynomial complexity and uses branch and bound paradigm

d)

The algorithm uses divide and conquer paradigm.

3.

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

a)

248000

b)

44000

c)

19000

d)

25000

4.

Which of the following algorithms is NOT a divide & conquer algorithm by nature?

a)

Euclidean algorithm to compute the greatest common divisor

b)

Heap Sort

c)

Cooley-Tukey fast Fourier transform

d)

Quick Sort

5.

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.

a)

O(n)

b)

O(nLogn)

c)

O(Logn)

d)

O(n^2)

6.

What is the shortest path from node A to node F?

a)

A -> B -> D -> F

b)

A -> C -> B -> E -> F

c)

A -> F

d)

A -> C -> E -> F

7.

Dijkstra's algorithm is based on which paradigm?

a)

Greedy paradigm

b)

Backtracking paradigm

c)

Dynamic Programming paradigm

d)

Divide and Conquer paradigm

8.

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?

a)

20

b)

12

c)

6

d)

5

9.

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?

a)

O(N)

b)

O(S)

c)

O(N2)

d)

O(S*N)

10.

For merging two sorted lists of size m and n into sorted list of size m+n, we require comparisons of

a)

O(m)

b)

O(n)

c)

O(m+n)

d)

O(logm + logn)