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

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

View Full Document Right Arrow Icon
Merge Sort Biostatistics 615/815 ecture 8 Lecture 8
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
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
Background image of page 2
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
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
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[]
Background image of page 4
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?
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
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
Background image of page 6
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?
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
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 ); }
Background image of page 8
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; }
Background image of page 9

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

View Full Document Right Arrow Icon
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
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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