## Detect Cycle in a Directed Graph using BFS

Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More »

## Find whether it is possible to finish all tasks or not from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites, for example to pick… Read More »

## Find the ordering of tasks from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites tasks, for example to… Read More »

## Number of paths from source to destination in a directed acyclic graph

Given a Directed Acyclic Graph with n vertices and m edges. The task is to find the number of different paths that exist from a… 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 »

## Maximum edges that can be added to DAG so that is remains DAG

A DAG is given to us, we need to find maximum number of edges that can be added to this DAG, after which new graph… Read More »

## Longest path between any pair of vertices

We are given a map of cities connected with each other via cable lines such that there is no cycle between any two cities. We… Read More »

## Longest Path in a Directed Acyclic Graph | Set 2

Given a Weighted Directed Acyclic Graph (DAG) and a source vertex in it, find the longest distances from source vertex to all other vertices in… Read More »

## Topological Sort of a graph using departure time of vertex

Given a Directed Acyclic Graph (DAG), find Topological Sort of the graph. Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices… Read More »

## Kahn’s algorithm for Topological Sorting

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge uv, vertex u comes before v… Read More »

## All Topological Sorts of a Directed Acyclic Graph

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge uv, vertex u comes before v… Read More »

## Top 10 Algorithms and Data Structures for Competitive Programming

In this post “Important top 10 algorithms and data structures for competitive coding “. Topics : Graph algorithms Dynamic programming Searching and Sorting: Number theory… Read More »

## Top 10 algorithms in Interview Questions

In this post “Top 10 coding problems of important  topics with their solutions ” are written. If you are preparing for a coding interview, going through… Read More »

## Find Itinerary from a given list of tickets

Given a list of tickets, find itinerary in order using the given list. Example: Input: “Chennai” -> “Banglore” “Bombay” -> “Delhi” “Goa” -> “Chennai” “Delhi”… Read More »

## Assign directions to edges so that the directed graph remains acyclic

Given a graph with both directed and undirected edges. It is given that the directed edges don’t form cycle. How to assign directions to undirected… Read More »