How to create a completely responsive Online eCommerce Website Design Template – Using HTML CSS JavaScript. eCommerce Website Design Free Download HTML CSS JS
The work of 7 numbers is finished in an index!! Not just 7, actually 31 numbers will end up with 1 index (because we are using 31 bits per index). Now the question is the primality of a number will be indicated by how many bits of the number index? Very simple, if the number is i then we need to check the i%32nd bit of index i/32nd. So if i=1 then I will check bit 1 of index 0, if i=33 I will check bit 1 of index 1 etc. (zero based indexing)
The coding part is quite simple. Since you know how to use the bitwise operator, you can easily check whether a number has a 1 or a 0 in the pos th bit. You can put 1 or 0 as you wish in the pos th bit. We don’t need to put 0 here, just put 1. Let’s write two functions:
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int Set(int N,int pos){ return N=N | (1<<pos);}
Now write the following:
int N =100,prime[100];
int status[100/32];
void sieve()
{
int i, j, sqrtN;
sqrtN = int( sqrt( N ) );
for( i = 3; i <= sqrtN; i += 2 )
{
if(check(status[i/32],i%32)==0)
{
for( j = i*i; j <= N; j += 2*i )
{
status[j/32]=Set(status[j/32],j % 32) ;
}
}
}
put(“2”);
for(i=3;i<=N;i+=2)
if(check(status[i/32],i%32)==0)
printf(“%d\n”,i);
}
Notice, we wrote everything like normal cive, but instead of checking the value of status[i] we checked the value of bit number i%32 of status[i/32].
You can generate primes up to 10^8 using bitwise sieve. It will take less time + memory than normal sieve. Bitwise operations are faster than simple multiplication and division operations. We can do some more optimization. As you have read the tutorial above, you know that multiplying a number by 2 is the same thing as shifting the binary of the number 1 place to the left. Again dividing by 2 and shifting 1 house to the right is the same thing, mod with 32 and AND with 31 is the same thing. Then we can write the code as follows:
int status[(mx/32)+2];
void sieve()
{
int i, j, sqrtN;
sqrtN = int( sqrt( N ) );
for( i = 3; i <= sqrtN; i += 2 )
{
if(Check(status[i>>5],i&31)==0)
{
for( j = i*i; j <= N; j += (i<<1) )
{
status[j>>5]=Set(status[j>>5],j & 31) ;
}
}
}
put(“2”);
for(i=3;i<=N;i+=2)
if(Check(status[i>>5],i&31)==0)
printf(“%d\n”,i);
}
Using macros instead of functions will take much less time. Bitwise sieving is rarely needed in programming contests, simple sieving works just fine. Even then, if you learn it, the bit concepts will be a little clearer, maybe you can reduce the memory in some other problem. In dynamic programming we often use bitmasks mainly to reduce memory.
eCommerce Website Design Free Download HTML CSS JS
(Note: many people have the wrong idea that the size of bool type variable is 1 bit. In fact, the size of bool is 8 bits or one byte, equal to char. This is because the computer cannot address small memory segments of 1 byte, so the minimum size of the variable is 1 byte)
Using macros instead of functions will take much less time. Bitwise sieving is rarely needed in programming contests, simple sieving works just fine. Even then, if you learn it, the bit concepts will be a little clearer, maybe you can reduce the memory in some other problem. In dynamic programming we often use bitmasks mainly to reduce memory.
(Note: many people have the wrong idea that the size of bool type variable is 1 bit. In fact, the size of bool is 8 bits or one byte, equal to char. This is because the computer cannot address small memory segments of 1 byte, so the minimum size of the variable is 1 byte)
Handbook in Graph Theory 7: Topological Sort
Suppose you have a list of tasks that must be completed. The tasks are going to office, having breakfast, watching sports on TV, answering some e-mails, having dinner with friends, etc. But you cannot do the work in any order, some conditions have to be followed. Like having breakfast before going to office, going to office before watching sports, answering e-mails before sitting for dinner.
You list the terms:
1. Breakfast —> Office (A—>B means A must be done before B is done)
2. Reading Suit-Tie —-> Office
3. Office -> Email
4. Office — -> Dinner
5. Office —-> Game
6. Email —> dinner
7. Email —> Game
8. Dinner —> Play
When will you do any work now? If you order in reverse, your work will be fake, if you sit to watch the game without email, you will lose clients, so ordering is very important.
This is a “task scheduling” problem. We have to figure out which job to do after which. That is, it is a type of sorting called topological sorting. In this tutorial we will find the topsort by removing the edge or reducing the degree.
In the above figure each task is represented by one node. The arrow pointing from breakfast to office means that you have to have breakfast before coming to office. The above 8 conditions are shown by 8 directed edges in the figure.
You can see small numbers next to each node. Like 0 with office, 2 with dinner etc. This means that a task is dependent on several other tasks. For example, before dinner, you need to do these 2 tasks: office, email, 2 arrows have entered the dinner node, and we have written “2” next to it. Just like this 1 is written next to the email. These numbers are called indegree.
Note that Breakfast and Dressup are not dependent on any tasks, so they have a 0 next to them. That means we can start the day with either of these two tasks. I think you want to eat breakfast first. After eating breakfast, the tasks that were dependent on breakfast are no longer dependent on it
Removed office arrow from breakfast. Now the office is dependent on only 1 task (previously it was 2). Now you have to dress up, because now this is the only task that does not depend on anyone:
Office arrow removed from dressup, no more work, now you are ready to go to office. Those who depend on commuting to the office can now be de-tickled:
Now the email “node” has a dependency of 0:
Now you’ve got work ordering, eating breakfast, office attire, going to the office, emailing, having dinner, watching sports.
This is called topological sort (topological sort) or topsort. Basically this algorithm is used to find job ordering. The computer uses topsort to fix the ordering of various tasks within it. Topsort is a very important topic in computer science as it has many real life applications. There is another method to find topsort called “Depth First Search”, discussed in this article.
The above algorithm works in O(n^2). A graph can have many sorted orders, e.g. in the above problem you could wear clothes before eating breakfast. It may ask you to print the lexicographically shorter one or print the one that is earlier in the input first, hopefully these conditions can be easily handled.
eCommerce Website Design Free Download HTML CSS JS
Not much to say about implementation. Find the indegree of all nodes. Then reduce the indegree of those whose indegree is zero with those who have an edge by 1, then find again whose indegree is now zero. Never take a node twice. I have shown the edge in the picture to understand, you don’t need to remove the edge from the matrix, just reduce the indegree.
Sometimes it can be said to topsort in as many ways as possible to get all of them out. Then you need to take help of backtracking.
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.