Welcome To Tutorialspoint.dev
Officially launched 18th May 2019

# Diameter of n-ary tree using BFS

N-ary tree refers to the rooted tree in which each node having atmost k child nodes. The diameter of n-ary tree is the longest path between two leaf nodes. Various ap...

# BFS vs DFS for Binary Tree

What are BFS and DFS for Binary Tree? A Tree is typically traversed in two ways: Breadth First Traversal (Or Level Order Traversal) Depth First Traversals Inorde...

# 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 of the tree. Examples: Input : 7 ...

# Water Jug problem using BFS

You are given a m litre jug and a n litre jug . Both the jugs are initially empty. The jugs don&#x2019;t have markings to allow measuring smaller quantities. You have...

# BFS using vectors & queue as per the algorithm of CLRS

Breadth-first search traversal of a graph using the algorithm given in CLRS book. BFS is one of the ways to traverse a graph. It is named so because it expands the fr...

# Level of Each node in a Tree from source node (using BFS)

BFS(Breadth First Search) is a graph traversal technique where a node and its neighbors are visited first and then the neighbors of neighbors. In simple terms it trav...

# BFS using STL for competitive coding

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 start with a node. 1) C...

# Print all paths from a given source to a destination using BFS

Given a directed graph, a source vertex &#x2018;src&#x2019; and a destination vertex &#x2018;dst&#x2019;, print all paths from given &#x2018;src&#x2019; to &#x2018;ds...

# BFS for Disconnected Graph

In previous post, BFS only with a particular vertex is performed i.e. it is assumed that all vertices are reachable from the starting vertex. But in the case of disco...

# 0-1 BFS (Shortest Path in a Binary Weight Graph)

Given a graph where every edge has weight as either 0 or 1. A source vertex is also given in the graph. Find the shortest path from source vertex to every other vert...