You are on page 1of 1

Quick sort

1. Pick an element, called a pivot, from the array.

2. Partitioning: reorder the array so that all elements with values less than the pivot come before the
pivot, while all elements with values greater than the pivot come after it .

3. After this partitioning, the pivot is in its final position. This is called the partition operation.

4. Recursively apply the above steps to the sub-array of elements with smaller values and separately
to the sub-array of elements with greater values.

Bi-Connected Components:

1.Check whether the given graph is biconnected or not.

2. If its not biconnected identify all the articulation point.

3. After obtaining the articulation points, determine the set of edges whose inclusion makes the graph connected in the absence of
articulation point.

All pair shortest:

1. We initialize the input graph matrix .

2. Then we update the solution matrix by considering all vertices as an intermediate vertex.

3. Then one by one pick all vertices and update all shortest paths which include the picked vertex as an intermediate vertex in the
shortest path.

4. Pick vertex number k as an intermediate vertex, we already have considered vertices {0, 1, 2, .. k-1} as intermediate vertices.

5. For every pair (i, j) of source and destination vertices respectively, there are two possible cases.
1) k is not an intermediate vertex in shortest path from i to j. We keep the value of dist[i][j] as it is.
2) k is an intermediate vertex in shortest path from i to j. We update the value of dist[i][j] as dist[i][k] + dist[k][j].

0/1 knapsack problem:

1. Calculate the cost function and the Upper bound for the two children of each node.

2. If the cost function for a given node is greater than the upper bound, then the node need not be explored further. Hence, we can kill
this node.

3. Otherwise, calculate the upper bound for this node. If this value is less than U, then replace the value of U with this value. Then,
kill all unexplored nodes which have cost function greater than this value.

4. The next node to be checked after reaching all nodes in a particular level will be the one with the least cost function value among
the unexplored nodes.

5. While including an object, one needs to check whether the adding the object crossed the threshold. If it does, one has reached the
terminal point in that branch, and all the succeeding objects will not be included.

You might also like