## Longest path in a directed Acyclic graph | Dynamic Programming

Given a directed graph G with N vertices and M edges. The task is to find the length of the longest directed path in Graph.… Read More »

- Find the number of distinct islands in a 2D matrix
- DFS traversal of a tree using recursion
- Tree, Back, Edge and Cross Edges in DFS of Graph
- Maximum number of edges among all connected components of an undirected graph
- Number of special nodes in an n-ary tree
- Find the ordering of tasks from given dependencies
- Sum of all odd nodes in the path connecting two given nodes
- Find whether it is possible to finish all tasks or not from given dependencies
- Find maximum path length in a binary matrix
- Unique paths covering every non-obstacle block exactly once in a grid
- Minimum number of edges between two vertices of a graph using DFS
- Level with maximum number of nodes using DFS in a N-ary tree
- Longest path in a directed Acyclic graph | Dynamic Programming
- Minimum time to return array to its original state after given modifications
- De Bruijn sequence | Set 1
- Count the number of nodes at a given level in a tree using DFS
- Lexicographically largest prime path from top-left to bottom-right in a matrix
- Find the probability of a state at a given time in a Markov chain | Set 1
- Perform the given queries on the rooted tree
- Printing pre and post visited times in DFS of a graph
- DP on Trees | Set-3 ( Diameter of N-ary Tree )
- Minimum edges to be added in a directed graph so that any node can be reachable from a given node
- Print levels with odd number of nodes and even number of nodes
- Product of lengths of all cycles in an undirected graph
- Number of connected components in a 2-D matrix of strings
- Print the lexicographically smallest DFS of the graph starting from 1
- Find the maximum value permutation of a graph
- Number of unique paths in tree such that every path has a value greater than K
- Even size subtree in n-ary tree
- Minimum number of groups of nodes such that no ancestor is present in the same group

Given a directed graph G with N vertices and M edges. The task is to find the length of the longest directed path in Graph.… Read More »

Given an n-ary tree of n vertices and n-1 edges. The tree is given in the form of adjacency list. Find number of subtrees of… Read More »

Given an n-ary tree rooted at vertex 1. The tree has n vertices and n-1 edges. Each node has a value associated with it and… Read More »

Given a 2-D matrix mat[][] the task is count the number of connected components in the matrix. A connected component is formed by all equal… Read More »

Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest DFS traversal of the graph starting from… Read More »

Given a tree as set of edges such that every node has unique value. We are also given a value k, the task is to… Read More »

Given a graph containing N nodes. For any permutation of nodes P1, P2, P3, …, PN the value of the permutation is defined as the… Read More »

Given a directed graph and a node X. The task is to find the minimum number of edges that must be added to the graph… Read More »

Given an N-ary tree T of N nodes, the task is to calculate the longest path between any two nodes(also known as the diameter of… Read More »

Given a tree of N nodes. The task is to form minimum number of groups of nodes such that every nodes belong to exactly one… Read More »

Given an integer l and a tree represented as an undirected graph rooted at vertex 0. The task is to print the number of nodes… Read More »

Given an undirected graph G(V, E) with N vertices and M edges. We need to find the minimum number of edges between a given pair… Read More »

Given a grid grid[][] with 4 types of blocks: 1 represents the starting block. There is exactly one starting block. 2 represents the ending block.… Read More »

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 »