int ans=INT_MAX;
void shortest(town* A,town* B,int currentsum,town* currenttown){
if(currenttown->name==B->name) {
ans=min(ans,currentsum);
return ;
}
while(currenttown->roads!=NULL){
shortest(A,B,currentsum+currenttown->roads->length,currenttown->roads->whereto);
currenttown->roads=currenttown->roads->next;
}
return;
}
Description : It is a basic dfs call from the source town and record the current distance , In the base statement this current distance is compared with the overall minimum distance till now.
Our answer is stored in variable "ans".
Hope it helps :)
3 Given that somebody has already defined the required structs represent a road map as a...
Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank you. Here are the temps given: January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 83 57 September 81 52 October 64 46 November 52 41 December 45 35 Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...