Correct, then fast.
Say what the code guarantees. Then say how the cost grows.
These are the CS 3343 notes in the order the homework already uses. Read a page, step the picture, then try the question at the bottom. The long version, with the full practice exam and answer key, is a PDF on the Files page.
- CasesName the input that makes the algorithm kind, and the one you can actually promise.
- CountingCost times times. The while-test runs once more than the body.
- Bounds\(O\), \(\Omega\), \(\Theta\), and the strict cousins. Watch them pull apart.
- HoareA precondition, a line of code, a postcondition. Forward is strongest. Backward is weakest.
- InvariantsInit, maintenance, termination. The fact that is true every time you are at the top of the loop.
- SortsInsertion can stop early. Selection never does. They do not share an invariant.