## Find the probability of a state at a given time in a Markov chain | Set 1

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 »

## Perform the given queries on the rooted tree

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 »

## Find the number of distinct islands in a 2D matrix

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 »

## Lexicographically largest prime path from top-left to bottom-right in a matrix

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 »

## Tree, Back, Edge and Cross Edges in DFS of Graph

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 »

## DFS traversal of a tree using recursion

Given a Binary tree, Traverse it using DFS using recursion. Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical… Read More »

## Product of lengths of all cycles in an undirected graph

Given an undirected and unweighted graph. The task is to find the product of the lengths of all cycles formed in it. Example 1: The… Read More »

## Find the maximum node at a given level in a binary tree

Given a Binary Tree and a Level. The task is to find the node with the maximum value at that given level. Recommended: Please try… Read More »

## Queries for M-th node in the DFS of subtree

Given a tree of N nodes and N-1 edges. Also given an integer M and a node, the task is to print the M-th node… Read More »

## Queries for DFS of a subtree in a tree

Given a tree of N nodes and N-1 edges. The task is to print the DFS of the subtree of a given node for multiple… Read More »

## Print all the cycles in an undirected graph

Given an undirected graph, print all the vertices that form cycles in it. Pre-requisite: Detect Cycle in a directed graph using colors In the above… Read More »

## Print the DFS traversal step-wise (Backtracking also)

Given a graph, the task is to print the DFS traversal of a graph which includes the every step including the backtracking. 1st step:- 0… Read More »

## Find alphabetical order such that words can be considered sorted

Given an array of words, find any alphabetical order in the English alphabet such that the given words can be considered sorted (increasing), if there… Read More »

## Undirected graph splitting and its application for number pairs

Graphs can be used for seemingly unconnected problems. Say the problem of cards which have numbers on both side and you try to create a… Read More »

## Check if a given graph is Bipartite using DFS

Given a connected graph, check if the graph is bipartite or not. A bipartite graph is possible if the graph coloring is possible using two… Read More »