--- title: "Divide and Conquer Introduction" format: html: toc: true number-sections: true code-line-numbers: true --- [In-class notes](hand_written_notes/Divide_and_Conquer.pdf) ## Learning Goals - Describe Divide and Conquer Structure ## Divide and Conquer ### Structure A divide and conquer algorithm is a recursive algorithm that divides the original problem into equal sized parts, recursively solves each part, and then combines the solutions to the parts to get a solution to the whole. In fact, most of you are familiar with a divide and conquer algorithm, MergeSort: ```python Mergesort(A) # Input: Integer array A of size n # Output: Sorted array # Base case: if A==1: return A # Preprocessing # None for MergeSort # Divide and Conquer A1=MergeSort(A[1:n/2]) A2=MergeSort(A[n/2+1:n]) #Combine p1,p2=1 for i=1 to n: if A1[p1]