Can’t find an answer?

Can’t find an answer?

Ask us to get the answer

  • This forum is empty.

Predict output of following program




#include <stdio.h>
int fun(int n)
{
if (n == 4)
return n;
else return 2*fun(n+1);
}
int main()
{
printf("%d ", fun(2));
return 0;
}

(A) 4
(B) 8
(C) 16
(D) Runtime Error

Assuming P != NP, which of the following is true ?

(A) NP-complete = NP

(B) NP-complete \cap P = \Phi

(C) NP-hard = NP

(D) P = NP-complete
(A) A
(B) B
(C) C
(D) D

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, 2 and 3
(B) 1 and 3
(C) 2 and 3
(D) 1 and 2

Which of the following is true 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) All of the above
(E) None of the above

The problem 3-SAT and 2-SAT are

(A) both in P
(B) both NP complete
(C) NP-complete and in P respectively
(D) undecidable and NP-complete respectively

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.

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? (GATE CS 2006)
(A) R is NP-complete
(B) R is NP-hard
(C) Q is NP-complete
(D) Q is NP-hard

A set X can be represented by an array x[n] as follows:

gate_2006_50

Consider the following algorithm in which x,y and z are Boolean arrays of size n:




algorithm zzz(x[] , y[], z [])
{
int i;
for (i=O; i<n; ++i)
z[i] = (x[i] ^ ~y[i]) V (~x[i] ^ y[i])
}

The set Z computed by the algorithm is:
(A) (X Intersection Y)
(B) (X Union Y)
(C) (X-Y) Intersection (Y-X)
(D) (X-Y) Union (Y-X)

An element in an array X is called a leader if it is greater than all elements to the right of it in X. The best algorithm to find all leaders in an array (GATE CS 2006)

(A) Solves it in linear time using a left to right pass of the array
(B) Solves it in linear time using a right to left pass of the array
(C) Solves it using divide and conquer in time 8(nlogn)
(D) Solves it in time 8(n2)

The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is
(A) \theta(n)
(B) \theta(logn)
(C) \theta(log*n)
(D) \theta(n)

(A) A
(B) B
(C) C
(D) D

Viewing 15 topics - 31 through 45 (of 95 total)

1 2 3 4 5 6 7
  • You must be logged in to create new topics.