Introduction Flashcards
What are some of the common algorithm design techniques? Name one example for each.
- Incremental. Example: Insertion sort.
- Divide-and-conquer. Example: Merge sort.
- Using a data structure. Example: Heap sort.
- Greedy algorithms. Example: Minimum-spanning tree.
What is loop invariant?
Loop invariant is a technique used to help us understand why an algorithm is correct. We must show three things about a loop invariant:
- Initialization: It is true prior to the first iteration of the loop.
- Maintenance: If it is true before an iteration of the loop, it remains true before the next iteration.
- Termination: When the loop terminates, the invariant gives us a useful property that helps show that the algorithm is correct.
Describe divide-and-conquer algorithm approach.
These algorithms break the problem into several subproblems that are similar to the original but smaller in size, solve the subproblems recursively, and then combine these solutions to create a solution to the original problem.
What are commonly used asymptotic notations for describing algorithm running time?
- Big O
- Big Theta
- Big Omega
What is Big O notation?
Big O asymptotic notation gives an upper bound for a function to within a constant factor.
What is Big Theta notation?
Big Theta asymptotic notation bounds a function to within constant factors from above and below.
What is Big Omega notation?
Big Omega asymptotic notation gives a lower bound for a function to within a constant factor.