PDF4PRO ⚡AMP

Modern search engine that looking for books and documents around the web

Example: bachelor of science

Proving Algorithm Correctness - Northeastern University

CS 5002: Discrete StructuresFall 2018 Lecture 11: November 20, 20181 Instructors: Adrienne Slaughter, Tamara BonaciDisclaimer:These notes have not been subjected to the usual scrutiny reserved for formal may be distributed outside this class only with the permission of the Algorithm CorrectnessReadings for this week:Rosen: Chapter 5: Induction and RecursionObjective: Analyzing Divide and Conquer Algorithms1. Review of Mergesort2. Ways to prove algorithms correct Counterexample Induction Loop Invariant3. Proving Mergesort correct4. Other types of IntroductionLast week, we focused on computing runtime of algorithms, in particular divide-and-conquer and Merge Sort AlgorithmMerge-Sort(A, low, high)1if(low < high)2mid=b(low+high)/2c3 Merge-Sort(A, low, mid)4 Merge-Sort(A, mid+1, high)5 Merge(A, low, mid, high)11-111-2 Lecture 11: November 20, 2018 Merge(A, low, mid, high)1 L = A[low:mid]//(L is a new array copied from A[low:mid])2 R = A[mid+1, high]//(R is a new array copied from A[mid+1:high])3i= 14j= 15fork=lowtohigh6ifL[i]<R[j]:7A[k] = L[i]8i=i+ 19else10A[k] = R[j]11j=j+ Mergesort AnalysisMergesort: AnalysisWe do 2 things in our analysis: What s the runtime?

Mathematical induction is a very useful method for proving the correctness of recursive algorithms. 1.Prove base case 2.Assume true for arbitrary value n 3.Prove true for case n+ 1 Proof by Loop Invariant Built o proof by induction. Useful for algorithms that loop. Formally: nd loop invariant, then prove: 1.De ne a Loop Invariant 2.Initialization

Loading..

Tags:

  Proving, Correctness

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Spam in document Broken preview Other abuse

Transcription of Proving Algorithm Correctness - Northeastern University

Related search queries