Fundamentals Flashcards

1
Q

Explain: logbx = n

A

n is how often I need to multiply b by itself to get x

logbx = n​

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

Name the most common runtimes.

A
  • O(log(n))
  • O(n)
  • O(n * log(n))
  • O(n2)
  • O(n!)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Runtime of binary search?

A

O(log(n))

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

Runtime of linear search?

A

O(n)

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

Runtime of quicksort?

A

O(n * log(n))

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

Runtime of selection sort?

A

O(n2)

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

Runtime of traveling salesman problem?

A

O(n!)

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

How many permutations exist for n elements?

A

n!

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

What is recursion?

A

When a function calls itself.

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

Explain partially completed.

A

A function that calls another function is ‘paused’ until the called function returns. During this time its values are stored on the call stack in its own stack frame.

This “paused state” is called partially completed.

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

Name the two cases that need to be considered in a recursive function.

A
  1. Base case (for termination)
  2. Recursive case (loop)

It needs to be shown that the recursive case progresses towards the base case.

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

How are recursion and induction similar?

A
  • both have a base case
  • the recursive case corresponds to the inductive case
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Divide-and-Conquer?

A

A recursive technique to solve algorithmic problems.

  1. Figure out a simple case as the base case
  2. Figure out how to reduce the problem to the base case

e.g. Quicksort

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

Name 1 Algorithm Design Strategy.

A
  • Divide-and-Conquer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the runtime of Breadth-First-Search?

A

O(V + E)

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

How can you solve the shortest path problem?

A

Breadth-First-Search (BFS)

17
Q

Describe how Breadth-First-Search works.

A
  1. Start at the start node/vertex
  2. If current node == search node => end
  3. Put current node in the visited set
  4. Enqueue all children of the current node that are not contained in the visited set in the to search queue
  5. If the search queue is empty return “not found”
  6. Dequeue the next node in the search queue and go to (2)
18
Q

Name the most common FIFO data structure.

A

Queue.

19
Q

Name the most common LIFO data structure.

A

Stack.