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
# onlineclasses

## 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
## Inorder Predecessor of node in Binary Tree Using Parent Pointer

Introduction
This is the seventh article in the Tree Traversals - Online Classes.
This article presents ways to find out inorder predecessor of node in binary tree. As we have already read about the Inorder Successor it wont take much effort to understand the predecessor.
Definition - Inorder Predecessor of node in Binary Tree
If a node K is called the inorder predecessor of node N then N must be visited immediately after K in a inorder traversal of the tree.
Below is a more formal definition of Inorder Predecessor:
If the node has a left sub-tree, then inorder predecessor is the ...

Read More
## Graph Operations

Introduction
This is the third article in the Graph Theory - Online Classes.
With some basic concepts we learnt in the previous two articles listed here in Graph Theory, now we have enough tools to discuss some operations on any graph. In this article we will try to define some basic operations on the Graph.
Graph Operations - Extracting sub graphs
In this section we will discuss about various types of sub graphs we can extract from a given Graph.
Sub graph
Getting a sub graph out of a graph is an interesting operation. A sub graph of a graph G(V,E) can be obtained by the following...

Read More
## Special Graphs

Introduction
This is the second article in the Graph Theory - Online Classes.
Dear readers, I assume that you have already finished reading the first post, if not I would advise you to please go through the first article in the series Introduction to Graph Theory, as this post will require some basic knowledge which we discussed in the previous post.
Few Special Graphs
The Null Graph
The first graph we will discuss is the Null Graph. By definition, this graph has a V(G) which is non-empty and a E(G) which is empty. In simple words a graph which only has vertices and no edges is a Null...

Read More
## Graph Theory

Preface
This is the first article in the Graph Theory - Online Classes. To all my readers and friends, you can safely skip the first two paragraphs.
The motivation to write this series
Its been long I have been planning to write this article and now I think is the right time to start a new category & series of articles in the Graph Theory. As a student it was always the most complicated topic for me and I was scared with the topic. I am sure many of you must have faced the same. Of course everyone has their own reason, for me it was the order in which it was taught and definitely it w...

Read More