• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Divide and Conquer Algrithm with Answers

Question 11

Let G be the directed, weighted graph shown in below figure gra We are interested in the shortest paths from A. (a) Output the sequence of vertices identified by the Dijkstra’s algorithm for single source shortest path when the algorithm is started at node A. (b) Write down sequence of vertices in the shortest path from A to E. (c) What is the cost of the shortest path from A to E?

    Question 12

    Consider the following C program C
    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)
    • x + y using repeated subtraction
    • x mod y using repeated subtraction
    • the greatest common divisor of x and y
    • the least common multiple of x and y

    Question 13

    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?

    • O(n)

    • O(nLogn)

    • O(Logn)

    • O(n^2)

    There are 13 questions to complete.

    Last Updated :
    Take a part in the ongoing discussion