Title: CSE 331
1Lecture 28
2HW 7 due today
Q1, Q2 and Q3 in separate piles
I will not take any HW after 115pm
3Other HW related stuff
HW 6 will be available for pickup from Monday
Solutions to HW 7 at the end of the lecture
HW 8 has been posted (link on the blog)
4On Algorithms, Practicality and Proofs
Indeed most of you will not write proofs in your
jobs
5A request and a warning
Please ask questions if something is not clear
The pace of the lectures is going to pick up
6High Level view of the course
Problem Statement
Problem Definition
Three general techniques
Done with greedy
Algorithm
Implementation
Data Structures
Analysis
CorrectnessRuntime Analysis
7Sorting
Given n numbers order them from smallest to
largest
Works for any set of elements on which there is a
total order
8Divide and Conquer
Divide up the problem into at least two
sub-problems
Recursively solve the sub-problems
Patch up the solutions to the sub-problems for
the final solution
9Mergesort Algorithm
Divide up the numbers in the middle
Unless n2
Sort each half recursively
Merge the two sorted halves into one sorted output
10HW 7 due today
Q1, Q2 and Q3 in separate piles
I will not take any HW after 115pm
11How fast can sorted arrays be merged?
Group talk time
12Mergesort algorithm
Input a1, a2, , an
Output Numbers in sorted order
If n 1 return the order a1
13An example run
If n 1 return the order a1
14Correctness
Input a1, a2, , an
Output Numbers in sorted order
By induction on n
If n 1 return the order a1
Inductive step follows from correctness of MERGE