Divide and Conquer Paradigm By: Melissa Manley How does it work? - - PowerPoint PPT Presentation

divide and conquer paradigm
SMART_READER_LITE
LIVE PREVIEW

Divide and Conquer Paradigm By: Melissa Manley How does it work? - - PowerPoint PPT Presentation

Divide and Conquer Paradigm By: Melissa Manley How does it work? Divide : the original problem into two or more sub-problems Recursively solves the sub-problems Conquer : by then combining the solutions to these sub-problems


slide-1
SLIDE 1

Divide and Conquer Paradigm

By: Melissa Manley

slide-2
SLIDE 2

How does it work?

Divide: the original problem into two or more sub-problems

Recursively solves the sub-problems

Conquer: by then combining the solutions to these sub-problems

slide-3
SLIDE 3

Karatsuba Karatsuba

& Gauss

& Gauss

slide-4
SLIDE 4

Advantages

 Allows us to solve difficult problems  Helps find other efficient algorithms  Effectively uses Memory Caches  Sometimes will produce more precise

  • utcomes.
slide-5
SLIDE 5

Disadvantages

 Recursion is slow

 Occasionally more complicated than an iterative

approach

 Sub-problems can occur more than once

slide-6
SLIDE 6

Binary Search

Referred to as the “ultimate divide and conquer algorithm”

The main concept: decides to use one half

  • f the data set, or the other

For example, if trying to find a key k in a set

  • f keys containing data z[0,1,…,n-1] :

  Compare k to n/2  Based on this result, use either the 1st or 2nd half of the data

slide-7
SLIDE 7

Binary Search Tree

slide-8
SLIDE 8

Mergesort Algorithm

 

The merge sort divides the data into two halves



It then recursively solves each half of the data



Then merges the data sets back together after they have been sorted

slide-9
SLIDE 9
slide-10
SLIDE 10

Quicksort Algorithm

A Random sorting algorithm

Sorts by applying the divide and conquer strategy.

How it works:

  Pick a random element from the set  Divide the data into 3 groups  Recursively sort the sub-list of lesser elements

and the sub-list of greater elements.

slide-11
SLIDE 11
slide-12
SLIDE 12

Cooley Tukey FFT Algorithm

 most common Fast

Fourier Transform

 Originally used by

Carl Friedrich Gauss

 Been rediscovered

many times and popularized by J. W. Cooley and J. W. Tukey in 1965

slide-13
SLIDE 13

Cooley-Tukey

 It is a D & C algorithm  Recursively breaks down a Discrete Fourier

Transform of size N = N1N2 into smaller DFT’s of size N1 and N2.

slide-14
SLIDE 14

Running Time

Based on three criteria:

 

The # of sub instances the problem is split into



The ratio of the original problem size to the sub problem size



The number of steps required to divide and conquer

slide-15
SLIDE 15

Comparing different sorting algorithm Running Times

O(nlog(n)) (Fastest) Quicksort O(nlog(n)) (Fast) Mergesort O(n^2) (Slow) Insertion Sort O(n^2) (Slow) Selection Sort Running Times Algorithm

slide-16
SLIDE 16