# Category Archives: Graph

## Lexicographically Smallest Topological Ordering

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 »

## Introduction to Data Structures | 10 most commonly used Data Structures

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 »

## Find the number of paths of length K in a directed graph

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 »

## Build original array from the given sub-sequences

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 »

## Find K vertices in the graph which are connected to at least one of remaining vertices

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 »

## Pair with a given sum in BST | Set 2

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 »

## Find two disjoint good sets of vertices in a given graph

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 »

## Maximum number of nodes which can be reached from each node in a graph.

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 »

## Number of trees whose sum of degrees of all the vertices is L

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 »

## Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes

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 »

## Count the nodes of a tree whose weighted string is an anagram of the given string

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 »

## Count the nodes of a tree whose weighted string does not contain any duplicate characters

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

## Print the degree of every node from the given Prufer sequence

Given a Prufer sequence, the task is to find the degrees of all the nodes of the tree made by the prufer sequence. Examples: Input:… Read More »

## Print the node with the maximum degree in the prufer sequence

Given a Prufer sequence of a Tree, the task is to print the node with the maximum degree in the tree whose Prufer sequence is… Read More »

## Count the nodes of the given tree whose weight has X as a factor

Given a tree, and the weights of all the nodes, the task is to count the nodes whose weights are divisible by x. Examples: Input:… Read More »