cse101-w12-dq1-tablet

Cse101-w12-dq1-table - Divide and Conquer(DQ First paradigm or framework DQ(S if S is small return ADHOC(S else decompose S into subproblems S1 Sk

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Divide and Conquer (“DQ”) First “paradigm” or “framework” DQ(S) if S is small return ADHOC(S) else decompose S into subproblems S 1 ,…, S k // divide for i = 1 to k do y i = DQ(S i ) // conquer recombine y i into solution y // compose return y “Universal method”: Mergesort, Quicksort, FFT, Matrix/Integer arithmetic are classic examples
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
DQ for Sorting • Divide (into two equal parts) • Conquer (solve for each part separately) • Combine separate solutions • Mergesort – Divide into two equal parts – Sort each part using Mergesort (recursion!!!) – Merge two sorted subsequences
Background image of page 2
Merging Two Subsequences Sequence #1: x[1]-x[2]- … - x[k] Sequence #2: y[1]-y[2]- … - y[l] if y[i] < x[j] compare y[i+1] and x[j] < k+l-1 edges = # (comparisons) = linear time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Tree of Recursions in Mergesort 1 2 3 4 5 6 7 8 1 3 5 8 2 4 6 7 1 5 3 8 5 1 8 3 4 7 2 6 7 4 6 2 log n n comparisons per level log n levels total runtime = n log n
Background image of page 4
(Unhelpful) DQ for Integer Multiplication Can we apply D/Q? – Let n = 2s, r = 10 radix – A = wx, B = yz – AB = xz + 10 s (wz + xy) + 10 2s wy Complexity analysis – 4 n/2-digit multiplications:
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2012 for the course ECE 101 taught by Professor Siegel during the Spring '08 term at UCSD.

Page1 / 12

Cse101-w12-dq1-table - Divide and Conquer(DQ First paradigm or framework DQ(S if S is small return ADHOC(S else decompose S into subproblems S1 Sk

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online