How to create a completely responsive Online GYM – Fitness Website Design Template – Using HTML – CSS – JavaScript. **Fitness Website Design Free Download HTML CSS JavaScript**

**Bitmask Dynamic Programming**

How many different states can our call function be in? Each of the n bits is either 0 or 1, so there can be 215 states. And an n2 inside

The loop is running so the total complexity is (2^n)*(n^2).

Bitmask DP is the easiest way to know n

See its value. If the value of n is 16 or less, there is a very good chance that the problem can be solved with bitmask DP.

When to use Bitmask DP? We will need bitmask only when any object/digit/node etc used in previous state will be used in my current state. According to that information we take the new digit/node etc. from the current state and move to the next state by turning on that bit. when n

I will return the base case when the T bit is turned on.

The first bitmask DP I solved was uva 10651. Hope the problem can be solved easily now. The problem uses a mask to store the state of the board at any given time, and return the minimum with all the possible moves in that state.

**Fitness Website Design Free Download HTML CSS JavaScript**

For now these are the basics of Bitmask DP. I will try to discuss in more detail in future episodes. Now try to solve the following problems, the 1st problem discussed in this episode:

Pimp My Ride

False Mirror

Agent 47

Painful Bases

**Algorithm Complexity (Big “O” Notation)**

Before you implement an algorithm in code, you need to know how efficient the algorithm is. Before writing the algorithm, you need to answer some questions yourself, such as:

1. Will my algorithm deliver results within the specified time?

2. What is the maximum number of inputs my algorithm will work for?

3. How much memory is my algorithm using?

We can answer the first two questions by figuring out the complexity of the algorithm. The number of “instructions” an algorithm uses to work is simply the complexity of that algorithm. Multiplying two numbers is one instruction, and if a loop is executed 100 times, there are 100 instructions. How long it takes to get the result will depend on the CPU processor, complexity will not tell us cputime, complexity will tell us how good our algorithm is in comparison. That is, it is a scale to determine the performance of the algorithm. And BIG O

Notation is a notation for expressing complexity.

We start with an example. We have a function called myAlgorithm

, we will find the complexity of that function. Think of the function as:

int myAlgorithm1(int n)

{

int x=n+10;

x=x/2;

return x;

}

This algorithm is n

Regardless of its value, it will always operate on a constant number of instructions. Converting the code into machine code will get 3-4 instructions in addition, we don’t need to do math about it. Processors work so fast that we don’t worry about the time it takes to process so few instructions, we do worry if there are too many instructions, and usually not much to worry about if there are no loops.

The complexity of the algorithm is O(1).

, this means that the algorithm will finish in a constant time regardless of the size of the input.

Now look at the following code:

int myAlgorithm2(int n)

{

int sum=0;

for(int i=1;i<=n;i++)

{

sum+=i;

if(sum>=1000) break;

}

return sum;

}

This code has a loop running and it depends on n. If n=100 the loop will run 100 times. Don’t worry about how many instructions are inside or outside the loop, because that number is very small. The complexity of the above algorithm is O(n) because the loop will run n times. You can say break if sum is greater than 1000, the loop may break before going to n. But programmers always work with the worst case! It is true that the loop can break earlier, but in the worst case it is n

It will continue until

The number of instructions in the worst case is our complexity.

int myAlgorithm3(int n)

{

int sum=0;

for(int i=1;i<=n;i++)

{

for(int j=i;j<=n;j++)

{

sum+=(i+j);

}

}

return sum;

}

In the above code, the inner loop runs n times for the first time, n−1 times for the next time. Then total loop runs n+(n−1)+(n−3)+…….+1=n×(n+1)/2=(n2+n)/2 times. There is no difference between n2 and n2+n. Again the difference between n2/2 and n2 is very small. So the complexity will be O(n2)

**Fitness Website Design Free Download HTML CSS JavaScript**

Constant factors have to be excluded while calculating the complexity. But constant factor must be kept in mind while writing the code.

Which of the above 3 algorithms will take least time? Of course O(1)

It will take less time and more than O(n2). In this way the performance of algorithms can be compared by calculating the complexity. Look at the following code:

int myAlgorithm4(int n,int *val,int key)

{

int low=1,high=n;

while(low<=high)

{

int mid=(low+high)/2;

if(key<val[mid]) low=mid-1;

if(key>val[mid]) high=mid+1;

if(key==val[mid]) return 1;

}

return 0;

}

This is a binary search code. Every time low+high=n+1 or the value of n is dividing into two parts. What is the maximum number of times a number can be divided by 2? A calculation can find the maximum divisible by log2n times. That means the loop will break after log2n steps. Then the complexity will be O(log2n).

.

Now suppose an algorithm has a number of loops, one n4

There is a loop, there is an n2 loop and there is a logn loop. Then total instructions: n4+n3+logn t. But the remaining terms are so small compared to n4 that we calculate the complexity by excluding them, O(n4).

Complexity depends on depth in recursive functions, eg:

int myAlgorithm5(int n)

{

if(n==1) return 1;

return n*myAlgorithm5(n-1);

}

The maximum depth in this algorithm is n, so the complexity is O(n).

. Below are a few more examples:

f(n)

= number of instructions

Complexity is O(n2) if f(n)=n2+3n+112.

Complexity is O(n3) if f(n)=n3+999n+112.

Complexity is O(n×logn) if f(n)=6×log(n)+n×logn.

Complexity is O(2n) if f(n) = 2n+n2+100

. (This is called exponential complexity)

Another common mistake beginners make is writing code like this:

int myAlgorithm6(char *s)

{

int c=0;

for(int i=0;i<strlen(s);i++)

{

if(s[i]==’a’) c++;

}

return c;

}

s is the length of the string |s| Then the complexity here is O(|s|2). Why square? Because the strlen(s) function itself has complexity O(|s|), it is called O(|s|) more times in the loop. So put the value of strlen(s) in another variable first and then run the loop with it, then the loop will run in O(|s|).

In the programming contest, we do not assume that Jazz’s PC can run approximately 108 instructions in 1 second. It can be more or less according to Jazz-PC, like topcoder can run more instructions in 1 second but spoj or codechef can’t easily run 107 with their Pentium 3 PC. In the Onsite National Contest, we write 108 codes in 1 second.

Before writing the code, first check the worst case complexity of your algorithm and how many test cases and check the time limit. Be careful that many new programmers do not care about the number of test cases even if they correctly calculate the complexity of the algorithm.

The expected algorithm can often be estimated by looking at the input size of the problem in the contest. For example, if n=100, it is likely that this is a DP problem of n^3 complexity, or a maxflow-matching problem. If n=10^5 the problem has to be solved in normal nlogn complexity so it is likely a binary search or segment tree problem.

So far today.

## 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,**

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