Algorithm Flashcards

1
Q

Greedy algorithm

A

Always takes the best option that is immediately available (finds the optimal solution)
Picking the best option at face value at each step (Prim’s)

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

Prim’s algorithm

A

Easiest method to find minimal spanning tree, greedy algorithm

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

Minimal spanning tree

A

Subset of edges in a weighted, undirected graph to connect all nodes in the smallest distance possible

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

Recursive algorithm

A

Calls itself during runtime
* takes up lots of space in computer memory and can lead to exponential/polynomial time complexity

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

Iterative algorithm

A

Loops a process x times or until it satisfies a condition (for and while loops)

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

Dijkstra’s algorithm

A

Finds shortest path between one node and all other nodes in weighted and directed graph (positive edges only)

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

Bellman-Ford algorithm

A

Finds shortest path between one node and all other nodes in weighted and directed graph. Takes longer than Dijkstra’s. (positive and negative edges)

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

Brute force algorithm

A

Trying every single option until you find the solution, guaranteed solution eventually but can take very long

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

Divide and conquer algorithm

A

Dividing problem into several subproblems, which are solved and joined to find original problem’s solution (Merge sort)

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

Decrease and conquer

A

Shrinks main problem into smaller problem that can be solved more easily (Binary search)

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

Transform and conquer

A

Converting given problem into different problem that gives the same answer as required

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

Backtracking

A

Systematically generating possible solutions to a problem and then going back and regenerating a part of the solution when it reaches a dead end or solution is incorrecct

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

Floyd-Warshall Algorithm

A

Looks for transitive closure, solves all pairs shortest paths problem. The time complexity is Θ (V³).
i -> starting point
k -> midpoint
j -> endpoint

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

Algorithm design patterns

A
  • Brute-force algorithm
  • Greedy algorithm
  • Decrease and conquer
  • Divide and conquer
  • Dynamic programming
  • Backtracking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly