Introduction Flashcards

1
Q

What are some of the common algorithm design techniques? Name one example for each.

A
  • Incremental. Example: Insertion sort.
  • Divide-and-conquer. Example: Merge sort.
  • Using a data structure. Example: Heap sort.
  • Greedy algorithms. Example: Minimum-spanning tree.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is loop invariant?

A

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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe divide-and-conquer algorithm approach.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are commonly used asymptotic notations for describing algorithm running time?

A
  • Big O
  • Big Theta
  • Big Omega
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Big O notation?

A

Big O asymptotic notation gives an upper bound for a function to within a constant factor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Big Theta notation?

A

Big Theta asymptotic notation bounds a function to within constant factors from above and below.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Big Omega notation?

A

Big Omega asymptotic notation gives a lower bound for a function to within a constant factor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly