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

The category contains all the lectures as posts which teaches about Datastructures & Algorithms and Problem Solving

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

Introduction
This is the sixth article in the Tree Traversals - Online Classes.
This article presents ways to find out inorder successor of node in binary tree. Before we jump into the code it would be good to correctly define the meaning of the problem.
Definition - Inorder Successor of node in Binary Tree
If a node K is called the inorder successor of node N then K must be visited immediately after N in a inorder traversal of the tree.
Below is a more formal definition of Inorder Successor:
If the node has a right sub-tree, then inorder successor is the left most node of the rig...

Read More
## Complex Graph Operations

Introduction
This is the fourth article in the Graph Theory - Online Classes.
After learning the basic graph operations, its time to dive deeper and have some understanding about the complex operations which we can be done over a graph or a set of graphs. To learn about the basics you can always visit Graph Theory Basics.
Complex Graph Operations
Union of Graphs
The union of two graphs G(VG, EG) and H(VH, EH) is the union of their vertex sets and their edge families. Which means G ∪ H = (VG ∪ VH, EG ∪ EH).
The below image shows a union of graph G and graph H. Make sure that all the v...

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