Final Review Flashcards

1
Q

What does it mean to say that a problem is in the complexity class P?

A

Solved in polynomial time by determinstic algorithms.

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

What does it mean to say that a problem is in the complexity class NP?

A

Solved in polynomial time by nondeterminstic algorithms.

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

What does it mean to say that a problem is NP-Complete?
List 3 NP-complete algorithms.

A

Its is NP Hard and NP.

  1. Graph Coloring
  2. Generalized minesweeper
  3. Travelling Salesman Problem.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do most computer scientists believe that these P and NP are not the same? What evidence do they have for this.

A

If you have the algorithm to solve on NP problem in polynomial time, you could solve all NP problems in polynomial time.

Evidence: No one was done it yet lol.

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

Name some greedy algorithms

A

Prim’s Minimal Spanning tree.
Fractional Knapsack
Huffman’s Compression Algorithm.

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

What is a, b, and d for the master’s theorm.

A

a = number of subproblems
b = sub-problem size
d = overhead price

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

When a priority queue is implemented using a binary heap, what is the complexity of insertion and removal.

A

Both O(log n) for insertion and removal.

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

When a priority queue is implemented using an unsorted array, what is the complexity of insertion and removal.

A

Insertion: O(1)
Removal: O(n)

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

Name 3 algorithms that use a priority queue.

A
  1. Huffman’s Compression Algorithm.
  2. Heap Sort
  3. Dikjstra’s
  4. Prim’s
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the complexity of the traditional grade-school algorithm for adding two n-bit numbers?

A

O(n)

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

What is the complexity of the traditional grade-school algorithm for multiplying two n-bit numbers?

A

O(n^2)

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

What is the recurrence for the complexity of Karatsuba’s divide and conquer algorithm for multiplication two n-bit numbers?

A

T(n) = 3T(n/2) + n

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

What is the solution of Karatsuba’s recurrence in O notation as a function of n?

A

O(n ^ log2(3))

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

Most efficient algorithm for solving single source shortest path problem in an unweighted graph and its worst case complexity in a sparse graph.

A

Bread First Search

O(V+E)

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

Most efficient algorithm for solving single source shortest path problem in a graph with non-negative weights and its worst case complexity in a sparse graph.

A

Dijkstra’s
O(V log V)

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

Most efficient algorithm for solving single source shortest path problem in a graph with negative weights but no negative weight cycles and its worst case complexity in a sparse graph.

A

Bellman Ford

O(V*E) or
O(V^2)

17
Q

What is the asympotic complexity of the fastest algorithm for finding the strongly connected conponents of a graph?

A

O(V+E)

DPS

18
Q

What is the complexity of Dijkstra’s algorithm in a sparse graph?

A

O(E log V)