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

**Handout 8 in Graph Theory: Depth-First Search and Topological Sort Again**

If you have read the previous episodes, you might have learned Depth First Search or DFS by now. Still need to read this tutorial to know some concepts.

Now, as soon as we find a node, we will go deeper from that node, when we can’t go deeper, we will return to the previous node and try another direction, never visit a node twice. We will give the node 3 colors:

White nodes = Nodes not found/visited yet.

Gray or dark node = node that has been visited but not finished visiting the child nodes from which the node can be reached, i.e. work is in progress on the node.

Black node = the node whose work is completely finished.

Hope it’s clear how DFS works, it’s very simple stuff. Now we will learn a very important term, that is backedge. Note that 5-1 is called backedge. This is because 1 is still working, going from 5 to 1 means going back to a node that is not yet finished, so there must be a cycle in the graph.

Such an edge is called a back edge, if at any time in dfs it tries to go from one gray node to another gray node, then that edge is a back edge and there must be a cycle in the graph. Depending on the source node of dfs and the order of visiting the nodes, any edge in the cycle can be found as a backedge, for example if going from 1 to 2 instead of going to 5 then 2-1 would be found as a backedge.

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

And when we go naturally from gray to white nodes, those edges are called tree edges. The graph that remains when only the tree edges are kept and the rest of the edges are deleted is called a DFS tree.

In the case of undirected graph, returning to a previously visited node is possible even if backedge, color is not checked. But in the case of directed graphs it must be done.

The edge of 2-3 cannot be called a back edge, because the work of 3 has already been completed.

By doing each node and edge once, the complexity of dfs is O(V+E).

We solved the topological sort problem by repeatedly increasing the indegree. Now we will do it very easily with dfs. If you don’t know what topological is, read this post first, then go ahead.

I think our edges are: 2-1,2-3,3-4,1-4. That is, number 2 must be done before number 1 is done, etc. Now we will start a stopwatch while running dfs. And when I start working with a node, I will write down the starting time/discovery time of the node by looking at the clock, when the work is finished, I will write down the finishing time of the node.

We can easily topsort by looking at the finishing time. The finishing time of the node that comes first must be the highest, because the finishing time of that node is assigned after all the nodes dependent on the first node have arrived. uva 11504-dominos problem first sort the nodes by finishing time and then run dfs again, try the problem.

Many of the things we do with DFS we can do with bfs. bfs usually has less time complexity but dfs takes less time to code. A simple dfs sudocode looks like this:

procedure DFS(G, source):

U ← source

time ← time+1

d[u] ← time

color[u] ← GRAY

for all edges from u to v in G.adjacentEdges(v) do

if color[v] = WHITE

DFS(G,v)

end if

end for

color[u] ← BLACK

time ← time+1

f[u] ← time

return

**Modular Arithmetic**

What is the quotient when −17 is divided by 5? Can you find the quotient of 21000 divided by 17 without overflow? If in O(n) then O(log2n)

Can the complexity? If any of the answers is “no” then this post is for you. But if you open the post to learn modular inverse or something advanced then you are in for a disappointment.

A % in most programming languages including C/Java

k is considered the quotient operator. Dividing x by m to find the quotient means finding the value of x%m or we can say mod x by m. The expression “determine answer modulo 1000” means that the answer is 1000

Mod with and then give the output.

Let’s start with a problem. You have 100 books, how can you arrange the books? Very easy, 100!

(100 factorial) can be arranged. 100! A huge number of 158 digits. So I simplified the problem for you, suppose you can arrange the books in x ways, then you have to say how much x is. That means 100! Take out 97

Your problem is to find the quotient by dividing by . (Determine 100 factorial modulo 97)

How to do it? 100!

You can’t find its value even with a 64-bit unsigned integer, which is 264−1

can work with numbers up to , so will overflow. But we know our answer will never be greater than 97 because any number modded by m cannot be greater than m.

We will use two sources to help solve this type of problem:

(a+b)%m=((a%m)+(b%m))%m

(a∗b)%m=((a%m)∗(b%m))%m

n

Number of numbers a1,a2…an

You can use two sources for this.

The above problem requires the 2nd formula. You need to find 100! %97 means:

(100*99*98*………..*1)%97

What you will do is mod while multiplying as per formula 2, then overflow will never happen because mod is getting smaller at each step. Its code might look like this:

int fact=1;

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

{

fact=((fact%97)*(i%97))%97;

}

printf(“%d\n”,fact);

Its output will be 0. That means 100! % 97 =0. If you pay attention, you will understand that here we have applied the 2nd formula with 2 numbers each.

It is important to know why both formulas work. I show the proof of the 1st formula, the 2nd can be done in the same way. The proof is my own.

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

Let us find the value of (x+y)%5. Now if x%5=c1

And y%5=c2, then we can write x as 5n1+c1 and y as 5n2+c2 where n1 and n2

two integers. It’s a very basic rule, hope you don’t have any trouble understanding it. Now:

(x+y)%5

= (5n1+c1+5n2+c2)%5

= (5n1+5n2+c1+c2)%5

——(1)

Continue…

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