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

Mediator Design Pattern explained with simple example

Mediator design pattern basically defines an interface class which provides a mechanism for providing communication between various modules/components of the software. Since, mediator needs to access each component of the software, which means it should be added as a reference in each component. Using this mediator class components becomes less dependent on each other which means coupling is reduced.

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

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

Iterator Design Pattern explained with simple example

An iterator is an object which allows a developer to easily traverse through a container class. The Iterator design pattern is relatively simple and easy to implement kind of design pattern in which an iterator is used to traverse through a complex container in order to access the elements of the container. This design pattern tries to decouple container classes from the other modules in order to achieve low coupling.

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

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

Print longest common subsequence string of two string

The longest subsequence problem (LCS) is the problem in which we need to find the longest subsequence present in two sequences. In this case, characters doesn’t require to be in consecutive places.

For eg:

LCS for sequence “ABCDFG” and “ABCGDFG” is “ABCDFG” and its length is 6.

For calculating longest common subsequence length we can use recursion or dynamic programming, here we are going to see how to find the longest common subsequence string.

(more…)
Print longest common subsequence string of two string Read More

Longest common subsequence problem using dynamic programming

This problem can be solved using multiple approaches but here we will solve this problem using Dynamic Programming and showcase how dynamic programming will make the execution super-fast.

We will go through with the same steps as mentioned in Dynamic Programming post to tackle this problem step by step for better understanding.

Let’s explain the problem,

The longest subsequence problem (LCS) is the problem in which we need to find the longest subsequence present in two sequences. In this case, characters doesn’t require to be in consecutive places.

For eg:

LCS for sequence “ABCDFG” and “ABCGDFG” is “ABCDFG” and its length is 6.

Let’s apply the 3 Steps rule (Dynamic Programming) to tackle this problem.

(more…)

Longest common subsequence problem using dynamic programming Read More

Converting Roman number to Decimal using Interpreter design pattern

Interpreter design pattern is mainly used in compiler and other language processing programs. This design pattern used to identify various language mainly textual such as numbers, regular expression etc. This design pattern interprets every language syntax and assign a class accordingly, to do further processing.

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

(more…)
Converting Roman number to Decimal using Interpreter design pattern Read More