ACO 101 Study Guide - Final Guide: Loop Invariant, Metic, Liquid Oxygen

60 views3 pages
18 Mar 2015
School
Course
Professor

Document Summary

Lecture 16: mergesort proof of correctness, and running time. We would like to prove that mergesort works correctly. To do this, let us rst look at the correct- ness of the merge function, as this is iterative, and we have done proofs like this before. Recall that in such cases we want to nd a loop invariant which is a condition that holds every time the internal loop (or loops) is executed, and helps us prove correctness. In this case, let us focus on the tmp array. At iteration k, suppose that the indices in the two parts of the array a are i and j. Then, our loop invariant will be: tmp[k] a[l], l {i, . m} and tmp[k] a[l], l {j, . q}. In other words, the element we just copy at position k is the minimum of the remaining elements.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related textbook solutions

Related Documents

Related Questions