WorksheetsTRACTABILITY & SOLVABILITY
Total questions: 50
Worksheet time: 34mins
Which of the following is false about NP-Complete and NP-Hard problems.
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
The first problem that was proved as NP-complete was the circuit satisfiability problem.
NP-complete is a subset of NP Hard
None of the above
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.
1 and 3
2 and 3
1 and 2
All the three
Let X be a problem that belongs to the class NP. Then which one of the following is TRUE?
There is no polynomial time algorithm for X.
If X can be solved deterministically in polynomial time, then P = NP.
If X is NP-hard, then it is NP-complete.
X may be undecidable.
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?
R is NP-complete
R is NP-hard
Q is NP-complete
Q is NP-Hard
To which class does the Euler’s circuit problem belong?
P
NP
NP Hard
NP Complete
How many stages of procedure does a non-deterministic algorithm consist of?
1
2
3
4
A non-deterministic algorithm is said to be non-deterministic polynomial if the time-efficiency of its verification stage is polynomial.
True
False
Problems that can be solved in polynomial time are known as traceable problems
True
False
CNF-satisfiability problem belongs to
P
NP
NP HARD
NP COMPLETE
Approximation algorithms are used for finding exact solution for optimisation problems
True
False
can approximation algorithm be used for solving decision problem
Yes
No
Which among the followings are polynomial time
en
2n
n2
n log n
Which of the following problems has the algorithm that solves by polynomial time
Shortest path problem
0/1 Knapsack problem
Graph Coloring
Hamiltonian Cycle
Which of the following algorithm produces the same output for given the same input every time
Deterministic algorithm
Non Deterministic algorithm
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));
}
O(n)
O(log n)
O(n2)
O(2n)
Which of the following algorithm has the running time of Θ(n3)
Floyds warshall algorithm
Dijikstra's Algorithm
Prim's Algorithm
Kruskal's Algorithm
Running time of any approximation algorithms is
Polynomial Time
Exponential Time
at most the Polynomial time
at most the exponential time
What does approximation ratio means
(a)
The problem is said to be NP complete if and only if
it is NP
it is NP Hard
Both 1 & 2
None of the above
The set of problems that can be solved in polynomial time is ------------------------
P Problems
NP-Complete Problems
NP Problems
NP Hard Problems
The set of decision problems that can be verified in polynomial time but necessarily solvable in polynomial time is ------------ Problems
P
NP
NP-Hard
NP-Complete
------------------------ problems have exponential time solutions
P
NP
NP-Complete
NP-Hard
Graph Coloring Problem is an example of ------------------- problem
P
NP
NP-Complete
NP-Hard
Traveling Sales Man Problem is the best example of NP-Hard problem
True
False
Which is the hardest Problem ?
P
NP
NP Complete
NP Hard
Binary and Linear Search is the example of ----------- Problem
P
NP
NP Complete
NP Hard
Which is quicker to verify and slow to solve ?
P Problem
NP Problem
NP-Complete Problem
NP -Hard Problem
If any problem has Non-deterministic polynomial solution then it is both ____ and ___
NP- hard and NP- Complete
P and NP-Hard
Greedy and Dynamic
Exponential and SAT
________ 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.
Clique
Node Cover
Clause
SAT
Dijkstra’s Algorithm cannot be applied on
Graphs having negative weight function
Directed and weighted graphs
Unweighted graphs
Undirected and unweighted graph
Time complexity of fractional knapsack problem is (a)
Fractional knapsack problem is solved most efficiently by which of the following algorithm?
(a)
_________ is the class of decision problems that can be solved by non-deterministic polynomial algorithms?
NP
Hard
P
Graph
What is the time complexity of this code
int a = 0, i = N;
while (i > 0)
{
a += i;
i /= 2;
}
O(N)
O(Sqrt(N))
O(N / 2)
O(log N)
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;
O(n)
O(m)
O(n+m)
O(n*m)
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;
}
}
O(N)
O(N*log(N))
O(N * Sqrt(N))
O(N*N)
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;
}
}
O(n)
O(nLogn)
O(n^2)
O(n^2Logn)
Let f(n) and g(n) be two non-negative functions,f(n)=O(g(n)) if and only if..........................
f(n)<=c*g(n)
f(n)>=c*g(n)
f(n)<c*g(n)
f(n)<c*g(n)
Let f(n) and g(n) be two non-negative functions,f(n)= ω (g(n)) if and only if..........................
f(n)<=c*g(n)
f(n)>=c*g(n)
f(n)<c*g(n)
f(n)<c*g(n)
Let f(n) and g(n) be two non-negative functions,f(n)= θ (g(n)) if and only if..........................
c1*g(n)<=f(n)<=c2*g(n)
c1*g(n)>=f(n)>=c2*g(n)
c1*g(n)<f(n)<c2*g(n)
c1*g(n)>f(n)>c2*g(n)
...................................are the characteristics of an algorithm
Input
infiniteness
Effectiveness
output
finiteness
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];
}
}
2n+2 units
2n+1 units
n+1 units
n+2 units
Find the space complexity for the following algorithm
Algorithm sum(a,b,c)
{
a=10;
b=20;
c=30;
d=a+b+c;
}
3 units
4 units
5 units
6 units
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]);
}
}
}
Print the duplicate elements in the array
Print the element with maximum frequency
Print the unique elements in the array
Prints the element with minimum frequnecy
From the following given tree, what is the code word for the character ‘a’?
011
010
100
101
