Lecture7_DnC_LinearSpace

# Lecture7_DnC_LinearSpace - An Introduction to...

This preview shows pages 1–8. Sign up to view the full content.

www.bioalgorithms.info An Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms

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

View Full Document
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Divide and Conquer Algorithms Divide problem into sub-problems Conquer by solving sub-problems recursively. If the sub-problems are small enough, solve them in brute force fashion Combine the solutions of sub-problems into a solution of the original problem (tricky part)
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Sorting Problem Revisited Given: an unsorted array Goal: sort it 5 2 4 7 1 3 2 6 1 2 2 3 4 5 6 7

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

View Full Document
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Mergesort: Divide Step Step 1 – Divide 5 2 4 7 1 3 2 6 5 2 4 7 1 3 2 6 5 2 4 7 1 3 2 6 5 2 4 7 1 3 2 6 log( n) divisions to split an array of size n into single elements
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Mergesort: Conquer Step Step 2 – Conquer 1 2 2 3 4 5 6 7 2 4 5 7 1 2 3 6 2 5 4 7 1 3 2 6 5 2 4 7 1 3 2 6 O( n ) O( n ) O( n ) O( n ) O( n log n ) log n iterations, each iteration takes O (n) time. Total Time:

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

View Full Document
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Mergesort: Combine Step Step 3 – Combine 2 arrays of size 1 can be easily merged to form a sorted array of size 2 2 sorted arrays of size n and m can be merged in O(n+m) time to form a sorted array of size n+m 5 2 2 5
An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Mergesort: Combine Step Combining 2 arrays of size 4 2 4 5 7 1 2 3 6 1 2 4 5 7 2 3 6 1 2 4 5 7 2 3 6 1 2 2 4 5 7 3 6 1 2 2 3 4 5 7 6 1 2 2 3 4 Etcetera… 1 2 2 3 4 5 6 7

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/07/2010 for the course EPI 220 taught by Professor A during the Fall '10 term at UCLA.

### Page1 / 28

Lecture7_DnC_LinearSpace - An Introduction to...

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

View Full Document
Ask a homework question - tutors are online