Test Review Flashcards

1
Q

A breadth-first search algorithm uses a :

A

QUEUE

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

The worse case asympotitc complexity of Dijkstra’s algorithm in a dense graph is :

A

O(V^2)

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

If an undirected graph has the same weight for every edge, then both the single-source shortest path problem and the minimal spanning tree problem for the graph can be solved in:

A

Linear Time

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

TRUE or FALSE

The greedy algorithm for the fractional knapsack problem takes a fractional amount of at most one item.

A

TRUE

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

Prim’s Algorithm can work with

A

Positive and Negative Weights.

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

TRUE or FALSE

All dynamic programming algorithms have the same asympotitc complexity.

A

FALSE.

Bellman Ford: O(V*E)
Dijkstra’s: O(E log V)

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

If a depth-first traversal of a directed graph yeilds no back edges,

A

Then the graph is acyclic

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

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

A

Insertion: O(log n)
Removal: O(log n)

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

When a priority queue is implemented using a simple 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
10
Q

Name a graph algorithm for which the implementation of a priority queue as a binary heap is best when the graph is sparse, but implementation of priority queue as a simple array is best when the graph is dense.

A

Dijkstra’s
Prim’s Minimal Spanning

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

Most efficient algoirthm for Single-source shortest path problem in an unweighted graph.

A

Breadth-First Search
O(V+E)

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

Most efficient algorithm for Single-source shortest problem path in a graph with non-negative edge weights.

A

Dijkstra’s Algorithm.
O(V log V) In Sparse.

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

Most efficient algorithm for single-source shorest path problem in a graph with negative wegiths but no negative-weight cycles.

A

Bellmann Ford
O(V*E) In Sparse.

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

What is the asympotitc complexity of the fastest algorithm for finding the strongly-connected components of a directed graph.

A

DFS: O(V+E)

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

What is the asymptotic complexity of the Bellman-Ford algorithm as a function of the size of the graph G = (V,E)?

A

O(V*E)

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

Describe a similarity and difference of “Divide and Conquer” and “Dynamic Programming”

A

Similaries: Recursively divide the problem into subproblems and solve the subproblems.

Difference:
- D+C solves the subproblem and you’ll never see it again.
- DP solves the subproblem but you might use result again, so you store result in table for later use.

17
Q

Identify 3 important characteristics of any dynamic programming algorithm that are illustrated by this algorithm.

A
  1. There a table with an entry for each subproblem.
  2. Every entry in the table has the distance we are optimizing.
  3. Every entry also has a pointer to the parent node.
  4. There is a recurrence relation.