dynamic programming, network flow, & greedy algorithm Flashcards

1
Q

Dynamic Programming

A

an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems, so that we do not have to re-compute them when needed later. This simple optimization reduces time complexities from exponential to polynomial.

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

What is recursion?

A

The process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. Using a recursive algorithm, certain problems can be solved quite easily. Examples of such problems are Towers of Hanoi (TOH), Inorder/Preorder/Postorder Tree Traversals, DFS of Graph, etc. A recursive function solves a particular problem by calling a copy of itself and solving smaller subproblems of the original problems. Many more recursive calls can be generated as and when required. It is essential to know that we should provide a certain case in order to terminate this recursion process. So we can say that every time the function calls itself with a simpler version of the original problem.

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

Recursion is an amazing technique with the help of which we can reduce the length of our code and make it easier to read and write. It has certain advantages over the iteration technique which will be discussed later. A task that can be defined with its similar subtask, recursion is one of the best solutions for it. For example; The Factorial of a number.

Properties of Recursion:

A

Performing the same operations multiple times with different inputs.

In every step, we try smaller inputs to make the problem smaller.

Base condition is needed to stop the recursion otherwise infinite loop will occur.

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

Ford-Fulkerson algorithm is a greedy approach for calculating the maximum possible flow in a network or a graph.

A

flow network, is used to describe a network of vertices and edges with a source (S) and a sink (T). Each vertex, except S and T, can receive and send an equal amount of stuff through it. S can only send and T can only receive stuff.

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

Augmenttion path

A

It is the path available in a flow network.

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

Residual Graph

A

It represents the flow network that has additional possible flow.

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

Residual Capacity

A

It is the capacity of the edge after subtracting the flow from the maximum capacity.

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

Greedy algorithm

A

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to global solution are the best fit for Greedy.

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