Mortgage website template free download

A Completely responsive mortgage website template free download with HTML CSS Bootstrap and JavaScript. This is also called loan broker website template design and you easily free download it from our website free website create

Mortgage websites are a necessary part of the mortgage industry. They are the easiest way for potential homeowners to find the best mortgage products, regardless of their financial situation. However, the mortgage industry is now a competitive industry and in order to remain competitive, mortgage companies need to offer their customers the latest and greatest mortgage website.

A Completely responsive mortgage website template free download with HTML CSS Bootstrap and JavaScript

Dynamic Programming: Longest Common Subsequence

Perhaps the two most important examples of dynamic programming are finding the longest common subsequence and edit distance because they have many practical applications. Before reading this article I hope you know some basic dynamic programming like coin change, knapsack.

If you can’t, you can see my previous posts. In this article, we will look at finding the longest common subsequence, printing the solution, and finding all possible solutions. If you already know about these topics then check the related problem section at the end of the article, solving the last 3 problems will require some thinking.

  subsequence

Suppose there is 1 string “ABC”. If zero, one or more characters are removed from this string, what remains is the subsequence of the string. The subsequences of “ABC” are {“ABC” , “A”,”B”,”C”,”AB”,”AC”,”BC”,” “}. If all the characters are removed, what remains is the empty string and a subsequence.

For each character we had 2 options, we can take it or delete it. Then a string of length n can have 2^n subsequences.

  Longest Common Subsequence (LCS)

Longest Common Subsequence (LCS) is the longest of all common subsequences between two strings.

For example “HELLOM” and “HMLLD” have common subsequences like “H”, “HL”, “HLL”, “HM” etc. “HLL” is the longest common subsequence of length 3.

  Bruteforce Algorithm:

We can generate all subsequences from 2 strings by backtracking. Then we can compare the strings with 2 subsequences to see if they are “common”. I have already seen that the total subsequence will be 2^n, and then compare them again! This algorithm can take years to complete once the value of n exceeds 20-25! So we need good algorithms.

[NOTE: I have started a new series on dynamic programming. Click here to read new version]

  Dynamic Programming:

Remember the basics of dynamic programming? Divide the problem into small parts, solve those parts first and combine them to solve the big problem. During the coin change we solved for the remaining coins by taking or discarding each coin. I will do that for each character here!

Suppose you want to extract the LCS between “HELLOM” and “HMLLD”. At the beginning you are at the first character of 2 strings.

The blue color means that you are on which character of the string. You have to solve the problem for the rest of the string starting from the blue character.

Now notice that the two letters in blue are the same. That means you can just insert this character into the LCS without thinking and solve the problem recursively for the rest of the string.

We have taken the letter H. Now we’re at the 2nd character of 2 strings. We will now solve for the rest of the string from the blue letters. So the problem is reduced, we need to find the LCS between “ELLOM”, and “MLLD”.

Now the two blue letters are not the same. That means LCS has to be calculated by excluding at least 1. We will calculate once by removing E from above, another time by removing M from below.

That is, to extract LCS(“ELLOM”,”MLLD”) we would extract LCS(“LLOM”,”MLLD”) and extract LCS(“ELLOM”,”LLD”). I will take the bigger one between these two!

I will not show you all the state pictures, you must have understood what our work will be. Suppose the function calcLCS(i,j) calculates the LCS of the remaining string from the ith character of the first string and the jth character of the 2nd string. That is, i,j are the blue characters of the 1st and 2nd strings. And the two strings are A and B. Then the function can be defined as:

  calcLCS(i,j)=1+calcLCS(i+1,j+1) if A[i]==B[j]

  calcLCS(i,j)=max(calcLCS(i+1,j) , calcLCS(i,j+1) if A[i]!=B[j]

The recursion will not terminate before the runtime returns an error unless the base-case is given. For which state we can answer without calculation? Strings get smaller at each step and if a string becomes “empty” then any other string with LCS will be 0.

  calcLCS(i,j)=0 if A[i]==NULL or B[j]==NULL.

A Completely responsive mortgage website template free download with HTML CSS Bootstrap and JavaScript

If you pay attention, you will see that the same function will be called again and again. So we need to do the memorization that we do in other DP problems. The whole code might look like this:

#define MAXC 1000

char A[MAXC],B[MAXC];

int lenA,lenB;

int dp[MAXC][MAXC];

bool visited[MAXC][MAXC];

int calcLCS(int i,int j)

{

if(A[i]==’\0′ or B[j]==’\0′) return 0;

if(visited[i][j])return dp[i][j];

int ans = 0;

if(A[i]==B[j]) ans=1+calcLCS(i+1,j+1);

else

{

int val1=calcLCS(i+1,j);

int val2=calcLCS(i,j+1);

ans=max(val1,val2);

}

visited[i][j]=1;

dp[i][j]=ans;

return dp[i][j];

}

int main() {

scanf(“%s%s”,A,B);

lenA=strlen(A);

lenB=strlen(B);

printf(“%d\n”,calcLCS(0,0));

return 0;

}

Solution Print:

Now I got how big LCS is, but how do I get the string? It’s also very simple, we’ll get the string as soon as the calcLCS function proceeds along the path. We can write another function, let’s say the function is printLCS(i,j). Here also i,j means the index of two strings. Now if A[i]==B[j] we print the character and go to state (i+1,j+1). And if A[i]!=B[j] then look at the values of dp[i+1][j] and dp[i][j+1] from the previously calculated dp array and proceed to the direction where the maximum length is found. I will go The following code will make it clear:

string ans;

void printLCS(int i,int j)

{

if(A[i]==’\0′ or B[j]==’\0′){

cout<<ans<<endl;

return;

}

if(A[i]==B[j]){

ans+=A[i];

printLCS(i+1,j+1);

}

else

{

if(dp[i+1][j]>dp[i][j+1]) printLCS(i+1,j);

else printLCS(i,j+1);

}

}

That is, our calcLCS function goes along the path where it got the highest value.

Now the question may come that there can be more than one solution, how to get all of them? For example, the LCS of the two strings “hello” and “loxhe” are “he” and “lo”. All solutions have to be backtracked. Suppose the function printAll(i,j) prints all the solutions. As before if A[i]==B[j] then go to (i+1,j+1). And if A[i]!=B[j] then dp[i+1][j] and dp[j][i+1] will move to whichever is larger, difference is if dp[i+1][j ]==dp[i][j+1] then we advance in both directions.

string ans;

void printAll(int i,int j)

{

if(A[i]==’\0′ or B[j]==’\0′){

cout<<ans<<endl;

return;

}

if(A[i]==B[j]){

ans+=A[i];

printAll(i+1,j+1);

ans.erase(ans.end()-1); //Delete last character

}

else

{

if(dp[i+1][j]>dp[i][j+1]) printAll(i+1,j);

else if(dp[i+1][j]<dp[i][j+1]) printAll(i,j+1);

else

{

printAll(i+1,j);

printAll(i,j+1);

}

}

}

The code is pretty much the same as before. “ans.erase(ans.end()-1);” You can see an extra line like this. Its job is to delete the last character of the string. Why are you doing this? If you delete this line, what will be the problem? Figure it out, delete the line and see what happens.

  Complexity:

If the strings are of length n and m, the calcLCS() function can be in a total of n*m states. Then the complexity is O(n*m).

  Practice Problems:

Longest Common Subsequence

The Twin Towers

History Grading

Is Bigger Smarter?

  Related Problem 1: Edit Distance (Level-1)

You are given two strings A,B. You can perform 3 operations on string A only, replace any character, delete any character, insert new character at any position. That means change, delete, insert are your 3 operations. Now your task is to convert the string A to B in the minimum operation. For example, to make “blog” into “bogs” you can delete the l and insert the s at the end of the string.

(Hints: Like LCS two indexes i,j should be kept state. Now you think how i,j will change if you delete any character from string A. Similarly find out how i,j will change for the remaining 2 operations )

Problem link

  Related Problem 2: Lexicographically Minimum Longest Common Subsequence (Level-2)

Find the lexicographically minimum of the LCSs of the 2 strings. The lexicographically minimal LCS between “hello” and “loxhe” is “he”.

Problem link

  Related Problem 3: Longest Common Increasing Subsequence (Level-3)

In this problem only subsequences that are sorted from smallest to largest must be considered. Find the longest common subsequence among them. Problem link

  Related Problem 4: Different Longest Common Subsequences (Level-3)

How many different LCS are there between 2 strings? String length can be up to 1000, backtracking is not possible. Problem link

Happy Coding!

A Completely responsive mortgage website template free download with HTML CSS Bootstrap and JavaScript

Before Download

You must Join our Facebook Group and Subscribe YouTube Channel

All Links in Below:






Join Our FreeWebsiteCreate Facebook Group to get an instant update for projects, templates, design resources, and solutions.

Join Our YouTube Channel & Subscribe with Bell Icon for New Video:

Join Our Official Facebook Page For the Latest updates All Code Projects are Free:

Visit our service page to get premium services.

Free Website Create – HTML CSS, PHP, JavaScript Programming Projects For Free

Follow Us

Thank You,

Stay with FreeWebsiteCreate.net

Share the post if necessary.

Before Download

You must Join our Facebook Group and Subscribe YouTube Channel




FreeWebsiteCreate.net tries to provide HTML, CSS, SCSS, JavaScript, React, Android Studio, Java, PHP, Laravel, Python, Django, C#(C Sharp), and ASP.net-related projects 100% free. We try to make learning easier. Free Website Create always tries to give free projects to new learners. Free projects and source code will help to learn quickly.

They can save time and learn more. In this post, we share a free portfolio project website code with HTML and CSS. This free code portfolio contains a single landing page with a responsive design. In this post, we get a free best carpenter and craftsman service website designed by FreeWebsiteCreate with HTML, CSS, Bootstrap, and JavaScript.

To get a free website project code,

Keep bookmarking our website, Save categories links, Follow Social Media, Follow the youtube channel Join Facebook groups.

Stay with FreeWebsiteCreate.net

Share the post if necessary.

Leave a Comment