# 615.08 - Merge Merge Sort Biostatistics 615/815 Lecture 8...

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

Merge Sort Biostatistics 615/815 ecture 8 Lecture 8

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

View Full Document
Notes on Problem Set 2 z Union Find algorithms z Dynamic Programming z Results were very positive! z You should be gradually becoming gy g comfortable compiling, debugging and executing C code
Question 1 z How many random pairs of connections are required to connect 1,000 objects? Answer: ~3,740 z Useful notes: Number of non-redundant links to controls loop Repeat simulation to get a better estimates

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

View Full Document
Question 2 z Path lengths in the saturated tree… ~1.8 nodes on average ~5 nodes for maximum path andom data is far from worst case z Random data is far from worst case Worst case would be paths of log 2 N (10) nodes z Path lengths can be calculated using weights[]
Question 3 z Using top-down dynamic programming, evaluate the beta-binomial distribution Like other recursive functions, this one can be very costly to evaluate for non-trivial cases z Did you contrast results with non- dynamic programming solution?

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

View Full Document
Last Lecture: Quick Sort z Choose a partitioning element … z Organize array such that: ll elements to the right are greater All elements to the right are greater All elements to the left are smaller z Sort right and left sub-arrays independently
Quick Sort Summary z Divide and Conquer Algorithm Recursive calls can be “hidden” z Optimizations hoice of median Choice of median Threshold for brute-force methods Limiting depth of recursion z Do you think quick sort is a stable sort?

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

View Full Document
C Code: QuickSort void quicksort ( Item a [], int start , int stop ) { int i; if ( stop <= start ) return; i = partition ( a , start , stop ); quicksort ( a, start, i - 1 ); quicksort ( a, i + 1, stop ); }
C Code: Partitioning int partition ( Item a [], int start , int stop ) { int up = start, down = stop 1, part = a [ stop ]; if ( stop <= start ) return start; while (true) { while ( isLess ( a [ up ], part )) up ++; while ( isLess ( part , a [ down ]) && ( up < down )) down -- ; if ( up >= down ) break; Exchange ( a [ up ], a [ down ]); + up ++; down --; } Exchange ( a [ up ], a [ stop ]); eturn return up; }

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

View Full Document
on- ecursive Quick Sort Non Recursive Quick Sort void quicksort ( Item a [], int start , int stop ) { nt , s = , stack 4 ; int i, s 0, stack [ 64 ]; stack [ s ++] = start; stack [ s ++] = stop ; while ( s > 0 ) { stop = stack [-- s ]; start = stack [-- s ]; if ( start >= stop
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/26/2011 for the course BIO 615 taught by Professor Abecasis during the Fall '10 term at University of Michigan.

### Page1 / 38

615.08 - Merge Merge Sort Biostatistics 615/815 Lecture 8...

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

View Full Document
Ask a homework question - tutors are online