A statement true whenever execution reaches a chosen point in a loop, usually immediately before its condition is tested. Establish it initially, preserve it through each iteration, and combine it with the exit condition to establish algorithm correctness. Termination needs a separate argument.[ref]
Loop invariants. CS 2112 Fall 2019; Loop invariants, Using loop invariants to show code is correct: the three partial-correctness obligations and separate Termination step
Write I for the loop invariant, B for the condition, P for the precondition, and Q for the postcondition. Prove that initialization under P establishes I, that a completed body starting with I and B restores I, and that I with false B implies Q.[ref]
Loop invariants. CS 2112 Fall 2019; Loop invariants, Using loop invariants to show code is correct: Establishment, Preservation, and Postcondition
In the prefix maximum correctness example, the loop invariant remembers exactly the maximum of the processed prefix and the valid index bounds. The weaker statement best≥a0 survives every iteration, but does not imply the postcondition: for [3,1,4,4,2], the wrong value 3 satisfies it. A useful loop invariant retains enough information to recover the answer when the condition becomes false.
A decreasing measure used to prove algorithm termination. A nonnegative integer loop variant must strictly decrease after every completed body whose condition was true; the body itself must terminate.[ref]
Loop invariants. CS 2112 Fall 2019; Loop invariants, Using loop invariants to show code is correct: Termination and the decrementing function
The prefix maximum correctness example uses V=n−k. It counts unread entries and is independent of whether the new entry changes the maximum. Ties therefore cannot stall progress: k increases even when best stays the same. An integer bounded below cannot strictly decrease indefinitely, which supplies the missing algorithm termination argument.
Control flow and four proof obligations for the prefix maximum correctness example
. Initialization, preservation, and exit establish partial correctness; the loop variant establishes algorithm termination and hence total correctness. The loop invariant is restored after both variable assignments. The input array stays unchanged throughout. Details. Ancestors (4)
Incoming links (221)
- Algorithm
- Algorithm correctness
- Array bounds
- Binary long division
- Binary search
- Conditional expectation choice invariant
- Coupled binary exponentiation
- Distinct-index two-sum by suffix lower bounds
- Doubling-loop ceiling logarithm
- Explicit-stack depth-first tree traversal
- Exponentiation by squaring
- Formal verification
- Greedy-choice property
- Greedy Egyptian fraction expansion
- In-place linked-list reversal
- Insertion sort
- Integer logarithm
- Kruskal safe edge
- Linear search correctness
- Loop invariant
- Loop variant
- Lower-bound binary search invariant
- Mathematical induction
- Merge algorithm
- Modular exponentiation
- Partial correctness
- Past exam of the computer science course of the University of Oxford / 2015 / Concurrent programming / 1 / a / Solution
- Past exam of the computer science course of the University of Oxford / 2015 / Probability and computing / 3 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2003 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2003 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2003 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 6 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2003 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 6 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2003 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 6 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2005 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 6 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2005 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 7 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2005 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 8 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2005 / Functional programming, data structures and algorithms, procedural programming, and digital hardware / 8 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Functional programming, design and analysis of algorithms / 3 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Functional programming, design and analysis of algorithms / 5 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Functional programming, design and analysis of algorithms / 8 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 2 / b / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 3 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 3 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 6 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 8 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Digital systems, linear algebra, introduction to formal proof / 1 / c / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Functional programming, design and analysis of algorithms / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Functional programming, design and analysis of algorithms / 3 / d / iii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Functional programming, design and analysis of algorithms / 5 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Functional programming, design and analysis of algorithms / 5 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Functional programming, design and analysis of algorithms / 7 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Imperative programming / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Imperative programming / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2014 / Imperative programming / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Discrete mathematics, continuous mathematics, and probability / 3 / c / iii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 3 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 1 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 3 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 3 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 3 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 3 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 7 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2015 / Imperative programming (resit) / 7 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Digital systems, linear algebra, introduction to formal proof / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Functional programming, design and analysis of algorithms / 7 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 2 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 3 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 3 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 4 / c / iii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming / 4 / c / iv / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 3 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 3 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 3 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2016 / Imperative programming (resit) / 4 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Discrete mathematics, continuous mathematics and probability / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Functional programming, design and analysis of algorithms / 5 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 2 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 3 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 3 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 3 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 3 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 6 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 8 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming (resit) / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming (resit) / 3 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 1 / a / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 1 / a / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 3 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 3 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 3 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 3 / g / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 4 / d / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2018 / Imperative programming / 5 / d / iii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Digital systems, linear algebra, introduction to formal proof / 1 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Digital systems, linear algebra, introduction to formal proof / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Digital systems, linear algebra, introduction to formal proof resit / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Functional programming, design and analysis of algorithms / 5 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Functional programming, design and analysis of algorithms / 5 / d / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 1 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 3 / a / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 3 / d / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 4 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 5 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming / 6 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 1 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 3 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 3 / g / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 5 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 5 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2019 / Imperative programming resit / 7 / b / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 1 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 4 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 4 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 5 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming / 8 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming (resit) / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming (resit) / 4 / d / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2021 / Imperative programming (resit) / 5 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Digital systems, linear algebra, introduction to formal proof / 2 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Digital systems, linear algebra, introduction to formal proof / 3 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Digital systems, linear algebra, introduction to formal proof resit / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 1 / a / ii / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 1 / a / i / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 2 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 2 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 4 / f / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Imperative programming (resit) / 4 / g / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Functional programming, design and analysis of algorithms / 6 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 1 / a / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 1 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 1 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 1 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 2 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 2 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 2 / e / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 3 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 4 / b / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 4 / c / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 5 / d / Solution
- Past exam of the year 1 of the computer science course of the University of Oxford / 2023 / Imperative programming / 5 / e / Solution
- Prefix maximum correctness example
- Prefix reversal sorting
- Radix sort suffix invariant
- Sign-bracketing binary search
- Simultaneous exponentiation by squaring
- Snapshot representatives before quick-find union
- Sorted sparse dot product
- Sparse dot product by merging indices
- Stable record placement in counting sort
- Staircase matrix search
- Summation loop verification
- Tentative distance
- Total correctness
- Upper-bound search
- While loop
Discussion (0) New discussion
There are no discussions about this article yet.
Articles by others on the same topic (1)
A **loop invariant** is a property or condition that holds true before and after each iteration of a loop in a computer program. It is used primarily in the context of program correctness and formal verification to help understand and prove that a loop behaves as intended. The concept of a loop invariant is important in analyzing loops for correctness, particularly when applying proofs by induction.
