Lecture7_DnC_LinearSpace

Lecture7_DnC_LinearSpace - An Introduction to...

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

View Full Document Right Arrow Icon
www.bioalgorithms.info An Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms
Background image of page 1

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

View Full Document Right Arrow Icon
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)
Background image of page 2
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
Background image of page 3

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

View Full Document Right Arrow Icon
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
Background image of page 4
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:
Background image of page 5

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

View Full Document Right Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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 Right Arrow Icon
Ask a homework question - tutors are online