Free Online Flashcard Deck

06 — Algorithms and Correctness Free Online FlashCards

Study 06 — Algorithms and Correctness with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is an algorithm?

Back

An algorithm is a precise, finite sequence of steps for solving a problem or computing a result.

02
Front

How do a specification and implementation differ?

Back

A specification states what an algorithm must achieve; an implementation explains how to achieve it.

03
Front

What are linear search’s key properties?

Back

Linear search examines elements from left to right and takes O(n) time in the worst case. It does not require sorted data.

04
Front

What condition and complexity characterize binary search?

Back

Binary search requires sorted data, repeatedly halves the remaining range, and runs in O(log n) time.

05
Front

How does insertion sort build a sorted list?

Back

Insertion sort builds a sorted prefix by taking each next unsorted element and inserting it into its proper position.

06
Front

When is insertion sort especially useful?

Back

Insertion sort uses O(1) extra space and has O(n²) worst-case time. It is often effective for small or nearly sorted lists.

07
Front

What is merge sort’s divide-and-conquer process?

Back

Merge sort divides the list, recursively sorts both parts, and merges the sorted parts. It runs in O(n log n) time and usually uses O(n) extra space.

08
Front

What is a loop invariant?

Back

A loop invariant is a statement that remains true at a particular point during every loop iteration.

09
Front

What are the three parts of a loop-invariant proof?

Back

The three parts are initialization, maintenance, and termination: establish the invariant, preserve it, then use it with the stopping condition to prove the postcondition.

10
Front

What makes a recursive algorithm correct?

Back

A recursive algorithm needs a base case, a recursive case that reduces the problem, progress toward the base case, and a way to combine results.

11
Front

What is the recursive definition of factorial?

Back

The factorial base case is 0! = 1; for n > 0, n! = n × (n−1)! .

12
Front

What is a termination variant?

Back

A termination variant is a nonnegative quantity that strictly decreases on every iteration or recursive call.