Introduction
This post about Bellman Ford Algorithm is a continuation of the post Shortest Path Using Dijkstra's Algorithm. While learning about the Dijkstra's way, we learnt that it is really efficient an algorithm to find the single source shortest path in any graph provided it has no negative weight edges and no negative weight cycles.
The running time of the Dijkstra's Algorithm is also promising, O(E +VlogV) depending on our choice of data structure to implement the required Priority Queue.
Why Bellman Ford Algorithm?
There can be scenarios where a graph may contain negative weight ...

Read More
# online classes

## Further Reading for Minimum Spanning Tree

Introduction
This is a supplement to the posts for Minimum Spanning Tree and their Analysis. Check out the other related articles in the following section.
Further Reading for Minimum Spanning Tree
This section is meant to be read in conjunction to the post Minimum Spanning Tree - Prim's Algorithm
The minimum spanning tree of a Graph is the union of minimum spanning trees of its connected components.
This is a very important observation and it must be discussed in length and breadth because this will help us design our algorithm for MST in a
better way.
Why is it so important to underst...

Read More
## Shortest Path using Dijkstra’s Algorithm

Introduction
This is the third post in the Graph Traversals – Online Classes.
After learning how to move through a graph, we might be interested in learning more. One interesting problem is determining the shortest path between two vertices of a graph.
The problem can be extended and defined in many other forms. I prefer to call it "minimizing the cost". For e.g.
When we measure the cost in terms of the distances between vertices, it can be called as the Shortest Path.
When we measure the cost in terms of the money spent between vertices, it can be called as the Cheapest Path.
Whe...

Read More
## Depth First Traversal

Introduction
This is the second post in the Graph Traversals – Online Classes.
I Recommend you to look at the first post Breadth First Traversal as it contains more explanation and details and I will keep this post smaller just around the depth first concept.
Depth First Traversal
The Idea
In this traversal, we choose a start vertex and keep moving forward along the length of the graph until there is no undiscovered vertex in that path. Once reaching a dead end, we back track to all the visited vertices and check if we have any vertex which has an adjacent undiscovered vertex.
We kee...

Read More
## Breadth First Traversal

Introduction
This is the first article in the Graph Traversals – Online Classes.
Dear Readers, these set of posts under Graph Traversals will make more sense if you have read the Graph Theory. Here is a quick brush up for the same. However, if you are familiar with Graph Theory and have a basic knowledge of what graphs are and how they are stored, you can dive into the traversals.
Later in the series we will discover that the Graph Traversals are widely used in various application. Let me point out a couple of real world examples here:
How can we conduct matches between teams in a C...

Read More
## Make anagrams from two Strings

Problem Statement
Given two strings, find the total number of characters we need to delete from these strings to make them anagrams of each other.
Understanding Anagrams
Anagrams are defined with respect to a given string of characters (not necessarily characters in the English Alphabet) but a wider set of characters may be.
Given two strings A and B, if the number of time each character occurs in both the string is exactly same, we say A and B are anagrams. However, the order in which the character appears may be different and doesn't matter.
For example
A = axbbxxcecdeedda
B = abacb...

Read More
## Matrix Rotation and Matrix Transpose

Problem Definition – Matrix Rotation (by 90, 180, 270 degrees)
This is a very famous interview question and has been asked numerous times. We are trying to solve the problem of matrix rotations where the inputs are as follows:
A matrix of dimension M * N
A number from the set (90, 180, ,270) by which we need to rotate the matrix.
For simplicity we will consider a matrix to be a 2 dimensional array of integers.
What does it mean to rotate a matrix?
This can only be explained by nice diagrams. Just for a formal definition, I would say that matrix rotation is a structural re-arrangeme...

Read More