Can’t find an answer?

Can’t find an answer?

Ask us to get the answer

  • This forum is empty.

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

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

Consider a situation where you don’t have function to calculate power (pow() function in C) and you need to calculate x^n where x can be any number and n is a positive integer. What can be the best possible time complexity of your power function?
(A) O(n)
(B) O(nLogn)
(C) O(LogLogn)
(D) O(Logn)

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)

Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The minimum number of multiplications needed to evaluate p on an input x is:
(A) 3
(B) 4
(C) 6
(D) 9

Consider the following C program




int main()
{
int x, y, m, n;
scanf ("%d %d", &x, &y);
/* x > 0 and y > 0 */
m = x; n = y;
while (m != n)
{
if(m>n)
m = m - n;
else
n = n - m;
}
printf("%d", n);
}

What does the program compute? (GATE CS 2004)
(A) x + y using repeated subtraction
(B) x mod y using repeated subtraction
(C) the greatest common divisor of x and y
(D) the least common multiple of x and y

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

What does the following C expression do?

 x = x & (x-1) 

(A) Sets all bits as 1
(B) Makes x equals to 0
(C) Turns of the rightmost set bit
(D) Turns of the leftmost set bit

What is the return value of following function for arr[] = {9, 12, 2, 11, 2, 2, 10, 9, 12, 10, 9, 11, 2} and n is size of this array.




int fun(int arr[], int n)
{
int x = arr[0];
for (int i = 1; i < n; i++)
x = x ^ arr[i];
return x;
}

(A) 0
(B) 9
(C) 12
(D) 2

What does the following C expression do?

x = (x<<1) + x + (x>>1);
(A) Multiplies an integer with 7
(B) Multiplies an integer with 3.5
(C) Multiplies an integer with 3
(D) Multiplies an integer with 8

Viewing 5 topics - 91 through 95 (of 95 total)

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