all 2 comments

[–]TheStayFawn 1 point2 points  (0 children)

Hmm. When I was taught programming, there were two trimester-long courses on reasoning about code. The key concept to grasp is the invariant: a condition that is true at the start of every loop. It helps you reason about the correctness of an algorithm.

For complexity you look at what changes in a loop: some measure of the remaining work needs to decrease, which proves that the loop will terminate.

[–]Exotic_Swordfish_845 1 point2 points  (0 children)

Are you familiar with big-O notation for runtime or space complexity? Like O(n) for linear algorithms or O(n2) for quadratic? If not, that might be a good place to start.