## Count the number of nodes at given level in a tree using BFS.

Given a tree represented as undirected graph. Count the number of nodes at given level l. It may be assumed that vertex 0 is root… Read More »

Given a tree represented as undirected graph. Count the number of nodes at given level l. It may be assumed that vertex 0 is root… Read More »

Count the total number of ways or paths that exist between two vertices in a directed graph. These paths doesn’t contain a cycle, the simple… Read More »

We are given a matrix that contains different values in its each cell. Our aim is to find the minimal set of positions in the… Read More »

Given two four digit prime numbers, suppose 1033 and 8179, we need to find the shortest path from 1033 to 8179 by altering only single… Read More »

Travelling Salesman Problem (TSP): Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route… Read More »

Degree In graph theory, the degree (or valency) of a vertex of a graph is the number of edges incident to the vertex, with loops… Read More »

You are given a m litre jug and a n litre jug . Both the jugs are initially empty. The jugs don’t have markings to… Read More »

Given a array arr[] of n integers. For every value arr[i], we can move to arr[i] + 1 clockwise considering array elements in cycle. We… Read More »

Problem 1 – There are 25 telephones in Geeksland. Is it possible to connect them with wires so that each telephone is connected with exactly… Read More »

In graph theory, betweenness centrality is a measure of centrality in a graph based on shortest paths. For every pair of vertices in a connected… Read More »

We have introduced Graph implementation using array of vectors in Graph implementation using STL for competitive programming | Set 1. In this post, a different… Read More »

Given n friends and their friendship relations, find the total number of groups that exist. And the number of ways of new groups that can… Read More »

A STL based simple implementation of BFS using queue and vector in STL. The adjacency list is represented using vectors of vector. In BFS, we… Read More »

Main Purposes: Dijkstra’s Algorithm is one example of a single-source shortest or SSSP algorithm, i.e., given a source vertex it finds shortest path from source… Read More »

Given an undirected and connected graph and a number n, count total number of cycles of length n in the graph. A cycle of length… Read More »