Tutorialspoint.dev
Welcome To Tutorialspoint.dev
Officially launched 18th May 2019
Graph BFS DFS

Check if a graph is strongly connected Set 1 (Kosaraju using DFS)

Given a directed graph, find out whether the graph is strongly connected or not. A directed graph is strongly connected if there is a path between any two pair of ve...
Tree BFS DFS

BFS vs DFS for Binary Tree

What are BFS and DFS for Binary Tree? A Tree is typically traversed in two ways: Breadth First Traversal (Or Level Order Traversal) Depth First Traversals Inorde...
Graph DFS graph-basics

Depth First Search or DFS for a Graph

Depth First Traversal (or Search) for a graph is similar to Depth First Traversal of a tree. The only catch here is, unlike trees, graphs may contain cycles, so we ...
Graph Graph

Transitive Closure of a Graph using DFS

Given a directed graph, find out if a vertex v is reachable from another vertex u for all vertex pairs (u, v) in the given graph. Here reachable mean that there is a ...
Graph Tree n-ary-tree

DFS for a n-ary tree (acyclic graph) represented as adjacency list

A tree consisting of n nodes is given, we need to print its DFS. Examples : Input : Edges of graph 1 2 1 3 2 4 3 5 Output : 1 2 4 3 5 ...
Graph BFS DFS

Iterative Deepening Search(IDS) or Iterative Deepening Depth First Search(IDDFS)

There are two common ways to traverse a graph, BFS and DFS. Considering a Tree (or Graph) of huge height and width, both BFS and DFS are not very efficient due to fo...
Graph BFS DFS

Check if a graph is strongly connected Set 1 (Kosaraju using DFS)

Given a directed graph, find out whether the graph is strongly connected or not. A directed graph is strongly connected if there is a path between any two pair of ve...
Graph Matrix Amazon

Find the number of islands Set 1 (Using DFS)

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5 islands Example: Input : ma...

Subscribe to Our Newsletter