wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Advance data-structures

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Dynamic Programming is often used for (choose all that apply):

a)

Optimization problems that involve making a choice that leave one or more subproblems to be solved.

b)

Problems previously solved using divide and conquer that have over lapping subproblems

c)

Non polynomial solution problems

d)

Subproblems where resources are shared

2.

.................technique doesn't give guarantee that our solution is optimal

a)

greedy method

b)

dynamic programming approach

c)

backtracking

d)

branch and bound

3.

Which of the following problems is equivalent to the 0-1 Knapsack problem?

a)

You are given a bag that can carry a maximum weight of W. You are given N items which have a weight of {w1, w2, w3,…., wn} and a value of {v1, v2, v3,…., vn}. You can break the items into smaller pieces. Choose the items in such a way that you get the maximum value

b)

You are studying for an exam and you have to study N questions. The questions take {t1, t2, t3,…., tn} time(in hours) and carry {m1, m2, m3,…., mn} marks. You can study for a maximum of T hours. You can either study a question or leave it. Choose the questions in such a way that your score is maximized

c)

You are given infinite coins of denominations {v1, v2, v3,….., vn} and a sum S. You have to find the minimum number of coins required to get the sum S

d)

None of the mentioned

4.

If b is the source vertex, what is the minimum cost to reach f vertex?

a)

8

b)

9

c)

6

d)

4

5.
Which of the following is/are property/properties of a dynamic programming problem?
a)
Optimal substructure
b)
Overlapping subproblems
c)
Greedy approach
d)
Both optimal substructure and overlapping subproblems
6.

...........................technique is used by solving optimization problems

a)

divide and conquer

b)

greedy method

c)

dynamic programming

d)

both b and c

7.

Which of the following is/are property/properties of a dynamic programming problem?

a)

Optimal substructure

b)

Overlapping subproblems

c)

Greedy approach

d)

d) Both optimal substructure and overlapping subproblems

8.

In dynamic programming, the technique of storing the previously calculated values is called ___________

a)

Saving value property

b)

Storing value property

c)

Memorization

d)

Mapping

9.

You are given a knapsack that can carry a maximum weight of 60. There are 4 items with weights {20, 30, 40, 70} and values {70, 80, 90, 200}. What is the maximum value of the items you can carry using the knapsack?

a)

170

b)

200

c)

160

d)

90

10.

Time complexity of fractional knapsack problem is (a)  

11.
In the given graph, identify the shortest path having minimum cost to reach vertex E if A is the source vertex.
a)
a-b-e
b)
a-c-e
c)
a-c-d-e
d)
a-c-d-b-e
12.
a)

1

b)

2

c)

3

d)

all

13.

Fractional knapsack problem is solved most efficiently by which of the following algorithm?

(a)  

14.

The algorithms like merge sort, quick sort and binary search are based on

a)

Greedy algorithm

b)

Divide and Conquer algorithm

c)

Hash table

d)

Parsing

15.

In dynamic programming, the technique of storing the previously calculated values is called ___________

a)

Saving value property

b)

Storing value property

c)

Memorization

d)

Mapping

16.

What is the time complexity of the dynamic programming implementation of the longest common subsequence problem where length of one string is “m” and the length of the other string is “n”?

a)

O(n)

b)

O(m)

c)

O (m + n)

d)

O(mn)

17.

_________ approach is best to solve 0/1 Knapsack problem

a)

Greedy

b)

Divide and Conquer

c)

Dynamic Programming

d)

Iterative

18.
How many edges will a tree consisting of N nodes have?
a)
Log(N)
b)
N
c)
N-1
d)
N+1
19.

Consider a job scheduling problem with 4 jobs J1, J2, J3, J4 and with corresponding deadlines: ( d1, d2, d3, d4) = (4, 2, 4, 2). Which of the following is not a feasible schedule without violating any job schedule?

a)

J2, J4, J1, J3

b)

J4, J1, J2, J3

c)

J4, J2, J1, J3

d)

J4, J2, J3, J1

20.

Consider the following two sequences :

The length of longest common subsequence of X and Y is :Consider the following two sequences :

X = < B, C, D, C, A, B, C >, and Y = < C, A, D, B, C, B >

The length of longest common subsequence of X and Y is :

a)

5

b)

3

c)

4

d)

2