How to create a completely responsive Online Tours & Travel Website Design Template – Using HTML CSS JavaScript. **Tours and Travel website templates free download HTML CSS**

**UVA 10702 (Travelling Salesman)**

The Raveling Salesman is essentially an NP-complete classical problem. uva 10702 is a variant of the original problem that can be solved by dynamic programming. A peddler travels from town to town selling goods. He can visit a city more than once (a node cannot be visited more than once in the classic tsp problem). Going from one city to another gives a certain amount of profit. The hawker ends his journey at certain cities and travels to different cities a certain number of times before completing the journey (inter-city travel). What is the maximum profit he can make? In this problem the graph is complete, from all cities to all cities.

In the sample input the vendor can travel at most 2 times, the travel path will be 1-3,3-2, this will give a profit of 5+2=7 which is the maximum for this graph.

**Tours and Travel website templates free download HTML CSS**

The problem can be solved with the help of dynamic programming. Let F(n,d) be our function. Let’s say I am now in the nth city and I can make d number of trips, f(n,d) will return the maximum profit I can make in this state. But how to get the maximum profit? Suppose we can go from nth city to a,bth city. Then:

f(n,d)=max( w[n][a]+ ‘profit earned after traveling d-1 times from city a to destination’ , w[n][b]+ ‘from city b to d- Profit earned after 1 trip to destination’)

or,f(n,d)=max( w[n][a]+F(a,d-1) , w[n][b]+F(b,d-1) )

A good understanding of this function will solve the problem. Now we need a base case. When d==1 we must travel to one of the “destination cities” because then no further travel is possible. In this case, the maximum profit will be returned. I wrote the function like this:

i64 call(i64 u,i64 d)

{

if(d==0) return 0;

if(!vis[u][d])

{

vis[u][d]=1;

i64 MX=-1*1e16;

if(d==1)

{

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

if(last[i]) MX=max(MX,mat[u][i]);

return dp[u][d]=MX;

}

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

{

i64 ret=mat[u][i]+call(i,d-1);

MX=max(ret,MX);

}

return dp[u][d]=MX;

}

return dp[u][d];

}

Another such problem is 10681, where the graph is not complete and the conditions are slightly different.

Determine the execution time of the code

Sometimes we need to find out the execution time of whole code or of a particular function. All languages have timer functions which can be used to calculate the execution time.

Let’s start with C/C++.

#include<iostream>

#include<ctime>

using namespace std;

void f()

{

int sum=0;

for(int i=0;i<=10000000;i++)

sum++;

}

void g()

{

int sum=0;

for(int i=0;i<=30000000;i++)

sum++;

}

int main()

{

clock_t start,end;

start = clock();

f();

end = clock();

double total_time1=((double)end-start)/CLOCKS_PER_SEC;

start = clock();

g();

end = clock();

double total_time2=((double)end-start)/CLOCKS_PER_SEC;

cout<<“Function g() is “<<total_time2/total_time1<<” times slower”;

}

clock() returns the number of system clock ticks after starting the program. CLOCKS_PER_SEC is a builtin macro by which we can calculate the time in seconds.

We can do this using the time.time() function in Python:

import time

def F():

sum=0

for i in range (0,10000001):

sum=sum+1

def G():

sum=0

for i in range (0,30000001):

sum=sum+1

tStart = time.time()

F()

time1=(time.time() – tStart)

tStart = time.time()

G()

time2=(time.time() – tStart)

print “Function G() is %f times slower” %(time2/time1)

PHP:

<?

function F()

{

$sum=0;

for($i=0;$i<=10000000;$i++)

$sum++;

}

function G()

{

$sum=0;

for($i=0;$i<=30000000;$i++)

$sum++;

}

$time_start = microtime(true);

F();

$time_end = microtime(true);

$time1 = $time_end – $time_start;

$time_start = microtime(true);

G();

$time_end = microtime(true);

$time2 = $time_end – $time_start;

echo “Function G() is ” . $time2/$time1 .”Times Slower”;

?>

The microtime() function returns the current unix time stamp.

You can find the runtime in JavaScript using the getTime() function. For Java, System.currentTimeMillis() can be used.

If you run the above code, you will see that the output looks slightly different each time. The execution time depends on some other factors including processor capacity, load, so it varies from case to case, but there is not much difference. For this, it is best to average the execution time several times.

**UVA problem 11280**

It is a shortest path problem. Find the shortest path from 1 to Nth node using maximum X nodes. The problem can be solved in several ways. One solution is to use dijkstra, and keep track of how many edges have been used in the current node. A maximum of X nodes can be used in other words a maximum of X+1 edges can be used.

Another solution is bellman ford. Bellman Ford’s basic algorithm is as follows:

//taken from topcoder

for i = 1 to n

d[i] = infinity

d[source] = 0

for i = 1 to n-1

for all edges (u,v) in E

if d[v] > d[u] + cost[u][v]

d[v] = d[u] + cost[u][v]</code>

After the outer loop ends 1 time we get the shortest path using 1 edge, after M times we get the shortest path using maximum M edges. But here it is important in which order to take edge. If the nearest nodes are updated first, the next ones can be updated with the 2nd node in the first iteration. So while updating, it should be done in reverse, the edges farthest from the source should be taken first.

**Tours and Travel website templates free download HTML CSS**

My code is like this:

//Spoiler Warning: don’t copy the code

#include <cstdio>

#include <iostream>

#include <cstring>

#include <map>

#include <vector>

using namespace std;

#define INF 999999999

int main()

{

freopen(“in”,”r”,stdin);

//freopen(“out”,”w”,stdout);

int T,kas=0;

cin>>T;

while(T–)

{

int w[202][202];

int mat[102][102];

map<string,int>MP;

memset(w,0,sizeof(w));

memset(mat,0,sizeof(mat));

vector<int>list;

int N,i,E;

cin>>N;

for(i=1;i<=N;i++)

{

string S;

cin>>S;

MP[S]=i;

}

cin>>E;

for(i=1;i<=E;i++)

{

string A,B;

int x,y,cost;

cin>>A>>B>>cost;

x=MP[A]; y=MP[B];

if(w[x][y]) w[x][y]=min(w[x][y],cost);

else w[x][y]=cost;

mat[x][y]=1;

}

int Q;

cin>>Q;

printf(“Scenario #%d\n”,++kas);

while(Q–)

{

int limit;

cin>>lim;

int d[202],j;

for(i=1;i<=N;i++)d[i]=INF;

d[1]=0;

for(int loop=1;loop<=lim+1;loop++)

{

for(i=N;i>=1;i–)

for(j=N;j>=1;j–)

{

if(mat[i][j])

d[j]=min(d[j],d[i]+w[i][j]);

}

}

if(d[N]>=INF)

puts(“No satisfactory flights”);

else

printf(“Total cost of flight(s) is $%d\n”,d[N]);

}

if(T) puts(“”);

}

return 0;

}

A great tutorial on Bellman Ford: http://apps.topcoder.com/forums/?module=Thread&threadID=671406&start=0

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