Breadth first search for a Graph

Traversal of a Graph means visiting each and every nodes present in the Graph. Traversal can be done using various approaches and here we are going to talk about one of most famous and useful traversal algorithm known as Breadth first search (BFS). In this algorithm, backtracking and recursion is being used along with a Queue to visit all the nodes. Before going ahead have a look into Graph Basics.

(more…)

Breadth first search for a Graph Read More

Depth first search for a Graph

Traversal of a Graph means visiting each and every nodes present in the Graph. Traversal can be done using various approaches and here we are going to talk about one of most famous and useful traversal algorithm known as Depth first search (DFS). In this algorithm, backtracking and recursion is being used along with a Stack to visit all the nodes. Before going ahead have a look into Graph Basics.

(more…)

Depth first search for a Graph Read More

Graph and its basic implementation

Graph is a data structure which consists a set of vertices which is called as Node, together with a set of collection of pair of vertices which is called as an Edge.
A graph data structure can be represented as a pair (V, E) where V is a set of nodes called vertices and E is a collection of pairs of vertices called edges. Graphs are used to solve many real life problems such as fastest ways to go from A to B etc.
Before going ahead have a look into Graph Basics.

(more…)

Graph and its basic implementation Read More

Graph basics and representation

Graph is a data structure which consists a set of vertices which is called as Node, together with a set of collection of pair of vertices which is called as an Edge. A graph data structure can be represented as a pair (V, E) where V is a set of nodes called vertices and E is a collection of pairs of vertices called edges. Graphs are used to solve many real life problems such as fastest wasy to go from A to B etc.

(more…)
Graph basics and representation Read More

Visitor Design Pattern explained with simple example

The visitor design pattern allows a programmer to separate algorithms of the module from the object or class. This will allow to modify algorithm by adding or removing new functionalities without altering objects structure. This design pattern basically allows us to add a functionality to every element without altering their structure.

Before going ahead have a look at Design pattern simplified version.

(more…)
Visitor Design Pattern explained with simple example Read More

Longest increasing sub sequence using dynamic programming

The longest increasing sub sequence (LIS) is the problem in which we need to find out the length of the longest increasing sub sequence in the given sequence. In this case, numbers doesn’t require to be in consecutive places.

For eg:
The length of LIS in the sequence {1, 2, 2, 5, 8, 6, 3, 6, 9, 7} is 7 and the longest increasing sub sequence is {1, 2, 2, 5, 6, 6, 7}

(more…)
Longest increasing sub sequence using dynamic programming Read More

State Design Pattern explained with simple example

State design pattern allows an object to change its behaviour whenever its state changes. This design pattern is very similar to state machines in which behaviour of an object based on an event is dependent on the its state. This design pattern makes the software easily extensible as adding new states are quite easy because it doesn’t affect the behaviour of existing states.

Before going ahead have a look at Design pattern simplified version.

(more…)
State Design Pattern explained with simple example Read More

Observer Design Pattern explained with simple example

Observer design pattern is one of the most famous and widely used design pattern in software industry. In this design pattern basically multiple objects which are called as observers, registers themselves to an object called as subject for getting automatic notifications, whenever any state changes occurs in subject. This is mainly used for event handling modules.

Before going ahead have a look at Design pattern simplified version.

(more…)
Observer Design Pattern explained with simple example Read More

Memento Design Pattern explained with simple example

The Memento design pattern basically stores the various states of the system and provides the ability to restore the system in some previous state. This design pattern allows software to storing store various state which can be used for retracing or can be used to go back to some previous state in case something goes wrong. Also, auditing related procedures also can be done using this design pattern.

Before going ahead have a look at Design pattern simplified version.

(more…)
Memento Design Pattern explained with simple example Read More