45 Lecture

CS301

Midterm & Final Term Short Notes

Divide and Conquer

Divide and Conquer is a problem-solving technique that involves breaking down a problem into smaller sub-problems that are easier to solve. These sub-problems are solved independently, and their solutions are combined to solve the original probl


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. Which of the following is not an example of Divide and Conquer algorithm? a) Binary Search b) QuickSort c) Bubble Sort d) MergeSort

Answer: c) Bubble Sort

  1. What is the time complexity of QuickSort algorithm? a) O(n) b) O(n^2) c) O(n log n) d) O(log n)

Answer: c) O(n log n)

  1. In MergeSort algorithm, what is the time complexity of merging two sorted arrays of size n? a) O(n) b) O(n^2) c) O(log n) d) O(1)

Answer: a) O(n)

  1. Which of the following is not a step in the Divide and Conquer algorithm? a) Divide b) Conquer c) Combine d) Increment

Answer: d) Increment

  1. Which of the following is an example of a problem that can be solved using Divide and Conquer algorithm? a) Finding the maximum value in an unsorted array b) Counting the number of occurrences of a given element in an unsorted array c) Sorting an array in ascending order d) Finding the shortest path between two nodes in a graph

Answer: c) Sorting an array in ascending order

  1. What is the space complexity of MergeSort algorithm? a) O(n) b) O(n^2) c) O(log n) d) O(1)

Answer: a) O(n)

  1. Which of the following algorithms uses Divide and Conquer approach to find the closest pair of points in a plane? a) Insertion Sort b) Selection Sort c) MergeSort d) Divide and Conquer algorithm for Closest Pair problem

Answer: d) Divide and Conquer algorithm for Closest Pair problem

  1. What is the worst case time complexity of Binary Search algorithm? a) O(1) b) O(log n) c) O(n) d) O(n^2)

Answer: b) O(log n)

  1. Which of the following is an advantage of using Divide and Conquer approach? a) It is easy to implement b) It always gives the optimal solution c) It reduces the time complexity of the algorithm d) It is not affected by the size of the input

Answer: c) It reduces the time complexity of the algorithm

  1. Which of the following is a disadvantage of using Divide and Conquer approach? a) It is not suitable for solving large problems b) It requires extra space for storing the intermediate results c) It is difficult to understand and implement d) It always gives the correct solution

Answer: b) It requires extra space for storing the intermediate results



Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is divide and conquer paradigm?
  • Divide and conquer is a problem-solving technique in computer science that involves breaking down a problem into subproblems, solving these subproblems independently, and then combining their solutions to solve the original problem.
  1. What are the steps involved in the divide and conquer algorithm?
  • The steps involved in the divide and conquer algorithm are:
    1. Divide the problem into smaller subproblems.
    2. Solve each subproblem independently.
    3. Combine the solutions of the subproblems to solve the original problem.
  1. How does merge sort work using the divide and conquer paradigm?
  • Merge sort works using the divide and conquer paradigm by:
    1. Dividing the array to be sorted into two halves.
    2. Sorting each half recursively using merge sort.
    3. Merging the sorted halves into a single sorted array.
  1. What is the time complexity of quicksort algorithm?
  • The time complexity of quicksort algorithm is O(n log n) on average, and O(n^2) in the worst case.
  1. What is the base case in the divide and conquer paradigm?
  • The base case in the divide and conquer paradigm is the smallest possible input that can be solved without further recursion.
  1. What is the difference between top-down and bottom-up approaches in the divide and conquer paradigm?
  • Top-down approach starts with the full problem and divides it into smaller subproblems, while bottom-up approach starts with the smallest subproblems and combines them into a solution for the full problem.
  1. What are the advantages of using divide and conquer paradigm in algorithm design?
  • The advantages of using divide and conquer paradigm in algorithm design are:
    1. It provides a clear and structured approach to solving complex problems.
    2. It can lead to more efficient algorithms by reducing the problem size and avoiding redundant computations.
    3. It allows for parallel processing of subproblems.
  1. What are the disadvantages of using divide and conquer paradigm in algorithm design?
  • The disadvantages of using divide and conquer paradigm in algorithm design are:
    1. It may lead to increased memory usage due to the recursive calls.
    2. It may not always be the most efficient approach for certain types of problems.
    3. It can be difficult to implement and debug.
  1. What is the divide and conquer approach for finding the maximum subarray?
  • The divide and conquer approach for finding the maximum subarray involves dividing the array into two halves, finding the maximum subarrays in each half recursively, and then combining them to find the maximum subarray that crosses the middle.
  1. What is the recurrence relation for the time complexity of a typical divide and conquer algorithm?
  • The recurrence relation for the time complexity of a typical divide and conquer algorithm is T(n) = aT(n/b) + f(n), where a is the number of subproblems, n/b is the size of each subproblem, and f(n) is the time taken to divide the problem into subproblems and combine their solutions.
Divide and conquer is a problem-solving strategy that involves breaking down a complex problem into smaller sub-problems, solving each sub-problem individually, and then combining the solutions to form the solution to the original problem. This strategy is commonly used in algorithm design and computer science. The basic steps of the divide and conquer strategy are:
  1. Divide the problem into smaller sub-problems
  2. Solve each sub-problem individually
  3. Combine the solutions to solve the original problem
One of the classic examples of the divide and conquer strategy is the merge sort algorithm, which sorts an array by recursively dividing it into smaller sub-arrays, sorting each sub-array, and then merging the sorted sub-arrays back together. The divide and conquer strategy can be very efficient when used appropriately, as it allows for efficient algorithms to be developed for complex problems. However, it may not always be the best approach for every problem, and the effectiveness of the strategy may depend on the specific problem at hand. In addition to its use in computer science, the divide and conquer strategy has applications in other fields, such as economics, where it is used to analyze market behavior and make investment decisions. Overall, the divide and conquer strategy is a powerful problem-solving tool that can be used to solve a wide range of problems in various fields.