Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TRACTABILITY & SOLVABILITY

Total questions: 50

Worksheet time: 34mins

Name
Class
Date
1.

Which of the following is false about NP-Complete and NP-Hard problems.

a)

If we want to prove that a problem X is NP-Hard, we take a known NP-Hard problem Y and reduce Y to X

b)

The first problem that was proved as NP-complete was the circuit satisfiability problem.

c)

NP-complete is a subset of NP Hard

d)

None of the above

2.

Which of the following statements are TRUE?

(1) The problem of determining whether there exists a cycle in an undirected graph is in P.

(2) The problem of determining whether there exists a cycle in an undirected graph is in NP.

(3) If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.

a)

1 and 3

b)

2 and 3

c)

1 and 2

d)

All the three

3.

Let X be a problem that belongs to the class NP. Then which one of the following is TRUE?

a)

There is no polynomial time algorithm for X.

b)

If X can be solved deterministically in polynomial time, then P = NP.

c)

If X is NP-hard, then it is NP-complete.

d)

X may be undecidable.

4.

Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial-time reducible to R. Which one of the following statements is true?

a)

R is NP-complete

b)

R is NP-hard

c)

Q is NP-complete

d)

Q is NP-Hard

5.

To which class does the Euler’s circuit problem belong?

a)

P

b)

NP

c)

NP Hard

d)

NP Complete

6.

How many stages of procedure does a non-deterministic algorithm consist of?

a)

1

b)

2

c)

3

d)

4

7.

A non-deterministic algorithm is said to be non-deterministic polynomial if the time-efficiency of its verification stage is polynomial.

a)

True

b)

False

8.

Problems that can be solved in polynomial time are known as traceable problems

a)

True

b)

False

9.

CNF-satisfiability problem belongs to

a)

P

b)

NP

c)

NP HARD

d)

NP COMPLETE

10.

Approximation algorithms are used for finding exact solution for optimisation problems

a)

True

b)

False

11.

can approximation algorithm be used for solving decision problem

a)

Yes

b)

No

12.

Which among the followings are polynomial time

a)

ene^n  

b)

2n2^n  

c)

n2n^2  

d)

n log n

13.

Which of the following problems has the algorithm that solves by polynomial time

a)

Shortest path problem

b)

0/1 Knapsack problem

c)

Graph Coloring

d)

Hamiltonian Cycle

14.

Which of the following algorithm produces the same output for given the same input every time

a)

Deterministic algorithm

b)

Non Deterministic algorithm

15.

The time complexity of the following C function is

int recursive (mt n)

{

if (n == 1)

return (1);

else

return (recursive (n-1) + recursive (n-1));

}

a)

O(n)

b)

O(log n)

c)

O(n2)O\left(n^2\right)

d)

O(2n)O\left(2^n\right)

16.

Which of the following algorithm has the running time of Θ(n3)\Theta\left(n^3\right)  

a)

Floyds warshall algorithm

b)

Dijikstra's Algorithm

c)

Prim's Algorithm

d)

Kruskal's Algorithm

17.

Running time of any approximation algorithms is

a)

Polynomial Time

b)

Exponential Time

c)

at most the Polynomial time

d)

at most the exponential time

18.

What does approximation ratio means

(a)  

19.

The problem is said to be NP complete if and only if

a)

it is NP

b)

it is NP Hard

c)

Both 1 & 2

d)

None of the above

20.

The set of problems that can be solved in polynomial time is ------------------------

a)

P Problems

b)

NP-Complete Problems

c)

NP Problems

d)

NP Hard Problems

21.

The set of decision problems that can be verified in polynomial time but necessarily solvable in polynomial time is ------------ Problems

a)

P

b)

NP

c)

NP-Hard

d)

NP-Complete

22.

------------------------ problems have exponential time solutions

a)

P

b)

NP

c)

NP-Complete

d)

NP-Hard

23.

Graph Coloring Problem is an example of ------------------- problem

a)

P

b)

NP

c)

NP-Complete

d)

NP-Hard

24.

Traveling Sales Man Problem is the best example of NP-Hard problem

a)

True

b)

False

25.

Which is the hardest Problem ?

a)

P

b)

NP

c)

NP Complete

d)

NP Hard

26.

Binary and Linear Search is the example of ----------- Problem

a)

P

b)

NP

c)

NP Complete

d)

NP Hard

27.

Which is quicker to verify and slow to solve ?

a)

P Problem

b)

NP Problem

c)

NP-Complete Problem

d)

NP -Hard Problem

28.

If any problem has Non-deterministic polynomial solution then it is both ____ and ___

a)

NP- hard and NP- Complete

b)

P and NP-Hard

c)

Greedy and Dynamic

d)

Exponential and SAT

29.

________ is a subgraph of a graph such that all the vertices in this subgraph are connected with each other that is the subgraph is a complete graph.

a)

Clique

b)

Node Cover

c)

Clause

d)

SAT

30.

Dijkstra’s Algorithm cannot be applied on

a)

Graphs having negative weight function

b)

Directed and weighted graphs

c)

Unweighted graphs

d)

Undirected and unweighted graph

31.

Time complexity of fractional knapsack problem is (a)  

32.

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

(a)  

33.

_________ is the class of decision problems that can be solved by non-deterministic polynomial algorithms?

a)

NP

b)

Hard

c)

P

d)

Graph

34.

What is the time complexity of this code

int a = 0, i = N;

while (i > 0)

{

a += i;

i /= 2;

}

a)

O(N)

b)

O(Sqrt(N))

c)

O(N / 2)

d)

O(log N)

35.

Time Complexity of this program:

def f():

a = 0

for i = 1 to n:

a += i;

b = 0

for i = 1 to m:

b += i;

a)

O(n)

b)

O(m)

c)

O(n+m)

d)

O(n*m)

36.

What is the time complexity of following code:

int a = 0;

for (i = 0; i < N; i++) {

for (j = N; j > i; j--) {

a = a + i + j;

}

}

a)

O(N)

b)

O(N*log(N))

c)

O(N * Sqrt(N))

d)

O(N*N)

37.

What is the time complexity of following code:

int i, j, k = 0;

for (i = n / 2; i <= n; i++) {

for (j = 2; j <= n; j = j * 2) {

k = k + n / 2;

}

}

a)

O(n)

b)

O(nLogn)

c)

O(n^2)

d)

O(n^2Logn)

38.

Let f(n) and g(n) be two non-negative functions,f(n)=O(g(n)) if and only if..........................

a)

f(n)<=c*g(n)

b)

f(n)>=c*g(n)

c)

f(n)<c*g(n)

d)

f(n)<c*g(n)

39.

Let f(n) and g(n) be two non-negative functions,f(n)= ω\omega  (g(n)) if and only if..........................


a)

f(n)<=c*g(n)

b)

f(n)>=c*g(n)

c)

f(n)<c*g(n)

d)

f(n)<c*g(n)

40.

Let f(n) and g(n) be two non-negative functions,f(n)=  θ\theta  (g(n)) if and only if..........................

a)

c1*g(n)<=f(n)<=c2*g(n)

b)

c1*g(n)>=f(n)>=c2*g(n)

c)

c1*g(n)<f(n)<c2*g(n)

d)

c1*g(n)>f(n)>c2*g(n)

41.

...................................are the characteristics of an algorithm

a)

Input

b)

infiniteness

c)

Effectiveness

d)

output

e)

finiteness

42.

Find the time complexity for the following algorithm using step count method.

Algorithm sum(a,n)

{

nsum=0;

for(i=1;i<=n;i++)

{

nsum=nsum+a[i];

}

}

a)

2n+2 units

b)

2n+1 units

c)

n+1 units

d)

n+2 units

43.

Find the space complexity for the following algorithm

Algorithm sum(a,b,c)

{

a=10;

b=20;

c=30;

d=a+b+c;

}

a)

3 units

b)

4 units

c)

5 units

d)

6 units

44.

What does the following piece of code do?

for (int i = 0; i < arr.length-1; i++) {

for (int j = i+1; j < arr.length; j++) {

if( (arr[i].equals(arr[j])) && (i != j) ) {

System.out.println(arr[i]);

}

}

}

a)

Print the duplicate elements in the array

b)

Print the element with maximum frequency

c)

Print the unique elements in the array

d)

Prints the element with minimum frequnecy

45.
Consider the graph M with 3 vertices. Its adjacency matrix is shown below. Which of the following is true?
a)
Graph M has no minimum spanning tree
b)
Graph M has a unique minimum spanning trees of cost 2
c)
Graph M has 3 distinct minimum spanning trees, each of cost 2
d)
Graph M has 3 spanning trees of different costs
46.
Consider the graph shown below. Which of the following are the edges in the MST of the given graph?
a)
(a-c)(c-d)(d-b)(d-b)
b)
(c-a)(a-d)(d-b)(d-e)
c)
(a-d)(d-c)(d-b)(d-e)
d)
(c-a)(a-d)(d-c)(d-b)(d-e)
47.
Consider the following graph. Using Kruskal’s algorithm, which edge will be selected first?
a)
GF
b)
DE
c)
BE
d)
BG
48.
 Which of the following edges form minimum spanning tree on the graph using kruskals algorithm?
a)
(B-E)(G-E)(E-F)(D-F)
b)
(B-E)(G-E)(E-F)(B-G)(D-F)
c)
(B-E)(G-E)(E-F)(D-E)
d)
(B-E)(G-E)(E-F)(D-F)(D-G)
49.
Consider the given graph.What is the weight of the minimum spanning tree using the Prim’s algorithm,starting from vertex a?
a)
23
b)
28
c)
27
d)
11
50.

From the following given tree, what is the code word for the character ‘a’?

a)

011

b)

010

c)

100

d)

101