standard-problem

Snake and Ladder Problem

Problem statement Given a snake and ladder coordinates which represent the actual snake and ladder board, find the minimum number of dice throws required to reach the destination cell from source cell. This problem can be easily solved bu using 0-1 BFS. Example Input Expected Output Implementation in Python

Topological Sorting

In graph theory, a topological sorting of a directed graph is a linear ordering of vertices of graph such that if there is a directed edge uv from vertex u to vertex v, u comes before v in the ordering. Note: Graph must be directed and acyclic. Example Input Expected Output 0 2 1 3 Pseudocode Implementation in Python

Depth First Traversal for a Graph

Depth First Search (BFS) is a recursive graph traversal algorithm that is used to traverse all the vertices of a graph in a depthward motion. In other words, it starts the graph traversal from root node and explores all the branches. Example of Depth First Traversal for a Graph Depth First Traversal is used to traverse all the vertices of …

Depth First Traversal for a Graph Read More »

How to check if two binary trees are identical ?

Given two binary trees, write a program to check if the two binary trees are identical or not ? Solution We can solve the above problem recursively. If the root node of the tree is equal then we check for the equality of left subtree and right subtree.Similarly, we check for the equality of the …

How to check if two binary trees are identical ? Read More »

Kruskal’s Minimum Spanning Tree Algorithm

Kruskal’s Minimum Spanning Tree Algorithm The Kruskal’s Minimum Spanning Tree Algorithm is an algorithm which is used to construct a Minimum Spanning Tree for a connected weighted graph. Kruskal’s algorithm to find the minimum cost spanning tree uses the greedy approach. This algorithm works on principle of finding the subset of the edges from the …

Kruskal’s Minimum Spanning Tree Algorithm Read More »

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]