## Print the path between any two nodes of a tree | DFS

Given a tree of distinct nodes N with N-1 edges and a pair of nodes P. The task is to find and print the path… Read More »

- Islands in a graph using BFS
- Travelling Salesman Problem implementation using BackTracking
- Bellman Ford Algorithm (Simple Implementation)
- Longest path in a directed Acyclic graph | Dynamic Programming
- Detect cycle in the graph using degrees of nodes of graph
- Introduction to Data Structures | 10 most commonly used Data Structures
- Number of special nodes in an n-ary tree
- Minimum distance to the corner of a grid from source
- Spanning Tree With Maximum Degree (Using Kruskal's Algorithm)
- Program to count Number of connected components in an undirected graph
- Shortest paths from all vertices to a destination
- Shortest path from source to destination such that edge weights along path are alternatively increasing and decreasing
- Convert the undirected graph into directed graph such that there is no path of length greater than 1
- Pair with a given sum in BST | Set 2
- Lexicographically Smallest Topological Ordering
- Find the shortest distance between any pair of two different good nodes
- Minimum number of pairs required to make two strings same
- Minimum steps to color the tree with given colors
- Check if a directed graph is connected or not
- Find the number of paths of length K in a directed graph
- Find the weight of the minimum spanning tree
- Graph Representation using Java ArrayList
- Uniform-Cost Search (Dijkstra for large Graphs)
- Minimum number of given operations required to convert a permutation into an identity permutation
- Check if the array can be sorted using swaps between given indices only
- Maximum number of nodes which can be reached from each node in a graph.
- Find the winner of the match | Multiple Queries
- Find two disjoint good sets of vertices in a given graph
- Find K vertices in the graph which are connected to at least one of remaining vertices
- Sum of degrees of all nodes of a undirected graph

Given a tree of distinct nodes N with N-1 edges and a pair of nodes P. The task is to find and print the path… Read More »

Given a tree with N vertices and N-1 Edges. Let’s define a function F(a, b) which is equal to the minimum edge weight in the… Read More »

Given a two dimensional grid, each cell of which contains integer cost which represents a cost to traverse through that cell. The task is to… Read More »

We have learnt about Generic class in Java. We can also use them to code for Graph in Java. The Graph Class is implemented using… Read More »

Given an array of pairs arr of size N which represents a game situation where the first player wins against the second player. Given multiple… Read More »

Given a directed graph with N vertices and M edges that may contain cycles, the task is to find the lexicographically smallest topological ordering of… Read More »

A data structure is a particular way of organizing data in a computer so that it can be used effectively. The idea is to reduce… Read More »

Given a directed, unweighted graph with N vertices and an integer K. The task is to find the number of paths of length K for… Read More »

Given an integer N and valid subsequences of an array of integers where every element is distinct and from the range [0, N – 1],… Read More »

Given a connected graph with N vertices. The task is to select k(k must be less than or equals to n/2, not necessarily minimum) vertices… Read More »

Given a binary search tree, and an integer X, the task is to check if there exists a pair of distinct nodes in BST with… Read More »

Given an undirected unweighted graph with N vertices and M edges. The task is to find two disjoint good sets of vertices. A set X… Read More »

Given a graph with N nodes and K bidirectional edges between them find the number of nodes which can be reachable from a particular. Two… Read More »

Given an integer L which is the sum of degrees of all the vertices of some tree. The task is to find the count of… Read More »

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weighted string… Read More »