## Printing pre and post visited times in DFS of a graph

Depth First Search (DFS) marks all the vertices of a graph as visited. So for making DFS useful, some additional information can also be stored.… Read More »

- Print all the cycles in an undirected graph
- Check if a given graph is Bipartite using DFS
- Find the number of distinct islands in a 2D matrix
- Tree, Back, Edge and Cross Edges in DFS of Graph
- Maximum number of edges among all connected components of an undirected graph
- DFS traversal of a tree using recursion
- Find the maximum node at a given level in a binary tree
- Subtree of all nodes in a tree using DFS
- Find the ordering of tasks from given dependencies
- Find whether it is possible to finish all tasks or not from given dependencies
- Print the DFS traversal step-wise (Backtracking also)
- Find maximum path length in a binary matrix
- Sum of all odd nodes in the path connecting two given nodes
- Minimum time to return array to its original state after given modifications
- Find the probability of a state at a given time in a Markov chain | Set 1
- Level with maximum number of nodes using DFS in a N-ary tree
- Lexicographically largest prime path from top-left to bottom-right in a matrix
- Perform the given queries on the rooted tree
- De Bruijn sequence | Set 1
- Find alphabetical order such that words can be considered sorted
- Print levels with odd number of nodes and even number of nodes
- Product of lengths of all cycles in an undirected graph
- Queries for DFS of a subtree in a tree
- Printing pre and post visited times in DFS of a graph
- Queries for M-th node in the DFS of subtree
- Undirected graph splitting and its application for number pairs

Depth First Search (DFS) marks all the vertices of a graph as visited. So for making DFS useful, some additional information can also be stored.… Read More »

Given a N-ary tree, the task is to print the level with the maximum number of nodes. Examples: Input : For example, consider the following… Read More »

Given a binary tree and two nodes of that binary tree. Find the sum of all nodes with odd values in the path connecting the… Read More »

Given an N-ary tree, print all the levels with odd and even number of nodes in it. Examples: For example consider the following tree 1… Read More »

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites, for example to pick… Read More »

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites tasks, for example to… Read More »

Given an integer n and a set of characters A of size k, find a string S such that every possible string on A of… Read More »

Given two arrays of integers arr and P such that after a cycle an element arr[i] will be at location arr[P[i]]. The task is to… Read More »

Given a square matrix mat every element of which is either 0 or 1. A value 1 means connected and 0 means not connected. The… Read More »

Given integers ‘N’ and ‘K’ where, N is the number of vertices of an undirected graph and ‘K’ denotes the number of edges in the… Read More »

Given a Markov chain G, we have the find the probability of reaching the state F at time t = T if we start from… Read More »

Given a rooted tree and not necessarily binary. The tree contains N nodes, labeled 1 to N. You are given the tree in the form… Read More »

Given a boolean 2D matrix. The task is to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms… Read More »

Given a m x n matrix of positive integers. The task is to find the number of paths from the top left of the matrix… Read More »

Consider a directed graph given in below, DFS of the below graph is 1 2 4 6 3 5 7 8. In below diagram if… Read More »