Algorithms Flashcards

1
Q

Where does backtracking work best?

A

Backtracking works best where solution is a sequence of choices and each choice restraints subsequent choices. It identifies as soon as possible the choices you made cannot give you solution, so you can sooner step back and try something else. Fail fast, fail often.

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

What is heuristic method or heuristic?

A

A heuristic method is a method that leads to solution without guaranteeing that its the best or optimal one. This method helps when brute force or backtracking are too slow.

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

What is Greedy algorithm?

A

Greedy algorithm is a common type of heuristic method. It consists of never coming back to the previous choices. It is the opposite of backtracking. Try to make best choice at each step and don’t question it later.

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

Essence of Greedy algorithm

A

Try to make the best move at each step and don’t question it later. Like the burglar will fill the knapsack with highest valued items that fill his bag and don’t look at other items or combinations that may have given higher value.

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

Greedy algorithm is inverse of?

A

Backtracking, where we come back to previous moves and try to make better move. Like 8 chess queens problem

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

Greedy Travelling Salesman

A

At each city, visit the unvisited city that is nearest

and repeat until all cities are visited.

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

Greedy power line question: How to connect unconnected cities with least cable? Power can be transmitted from one connected location to other.

A

1) From all that don’t have power, choose the one that is closest to the settlement that has power. Connect those two.
2) Repeat till all the settlements are connected.

This is the best solution to this problem.

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