DSA Java Graph Part 2 Sort Algo Part 1 (M 26)
DSA Java Graph Part 2 Sort Algo Part 1 (M 26)
Kosaraju's Algorithm
Kosaraju's Algorithm is based on the depth-first search algorithm implemented
twice.
Three steps are involved.
1.Perform a depth first search on the whole graph.
Let us start from vertex-0, visit all of its child vertices, and mark the visited
vertices as done. If a vertex leads to an already visited vertex, then push this
vertex to the stack.
For example: Starting from vertex-0, go to vertex-1, vertex-2, and then to vertex-
3. Vertex-3 leads to already visited vertex-0, so push the source vertex (ie.
vertex-3) into the stack.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
Go to the previous vertex (vertex-2) and visit its child vertices i.e. vertex-4,
vertex-5, vertex-6 and vertex-7 sequentially. Since there is nowhere to go from
vertex-7, push it into the stack.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
Go to the previous vertex (vertex-6) and visit its child vertices. But, all of its child
vertices are visited, so push it into the stack.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
Start from the top vertex of the stack. Traverse through all of its child vertices.
Once the already visited vertex is reached, one strongly connected component is
formed.
For example: Pop vertex-0 from the stack. Starting from vertex-0, traverse through
its child vertices (vertex-0, vertex-1, vertex-2, vertex-3 in sequence) and mark
them as visited. The child of vertex-3 is already visited, so these visited vertices
form one strongly connected component.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Kosaraju Algorithm
• Maps
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
• Searching & Sorting Algorithms
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Bubble Sort Algorithm
Algo.
The bubble sort algorithm compares two adjacent elements and swaps them if
they are not in the intended order.
For example,
Suppose we have an unsorted array with elements: 45, 1, 4.
Here, the bubble sort algorithm compares the first element 45 and second
element 1.
Similarly, the new second element is compared with the next element. This
process continues until all the elements are sorted.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
2. Remaining Iteration
The same process goes on for the
remaining iterations.
After each iteration, the largest
element among the unsorted elements
is placed at the end.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Selection Sort Algorithm
Algo.
unsorted list in each iteration and places that element at the beginning of the
unsorted list.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
After each iteration, minimum is placed in the front of the unsorted list
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
Sorting and Searching
Algo.
This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video