Please answer this question. This is review for exam. Explain as
possible and use C++ code.
C++ code for above problem
#include<iostream>
using namespace std;
#define V 6
#define MAX 9999999
void floyd_warshall(int graph[][V],int distances[][V])
{
for(int i=0;i<V;i++)
{
for(int
j=0;j<V;j++)
{
distances[i][j]=graph[i][j];
if(i!=j
&& distances[i][j]==0)
{
distances[i][j]=MAX;
}
}
}
for(int k=0;k<V;k++)
{
for(int
i=0;i<V;i++)
{
for(int
j=0;j<V;j++)
{
distances[i][j]=min(distances[i][j],distances[i][k]+distances[k][j]);
}
}
}
}
int main()
{
int graph[V][V]={{0,1,0,0,1,0},
{1,0,1,0,0,1},
{0,1,0,1,0,0},
{0,0,1,0,1,0},
{1,0,0,1,0,1},
{0,1,0,0,1,0},
};
int distances[V][V];
floyd_warshall(graph,distances);
char src,dest;
cout << "Enter source vertex: ";
cin >> src;
cout << "Enter destination vertex: ";
cin >> dest;
cout << "Distance from " << src << "
to " << dest << ": " <<
distances[src-'A'][dest-'A'] << endl;
return 0;
}
Sample output
Mention in comments if any mistakes or errors are found. Thank you.
Please answer this question. This is review for exam. Explain as possible and use C++ code....
write a program that will find the shortest path from a given vertex to a given vertex. Your program must allow the user to enter any start vertex and any destination vertex and output the shortest path. A B F E D Using the attached graph, write a program that will find the shortest path from a given vertex to a given vertex. Your program must allow the user to enter any start vertex and any destination vertex and output...
Dijkstra’s Algorithm: You have to implement the Dijkstra’s algorithm and apply it on the graph provided below. You have to take the input from the user as an adjacency matrix representing the graph, the source, the destination. Then you have to apply the Dijkstra’s algorithm to find the shortest path from the source and the destination, and find the shortest route between the source and the destination. For the input you have to read it from a file. It will...
CSC 430 GRAPH PROJECT Implement a graph class using an adjacency matrix or an adjacency list. The class should have a constructor, a copy constructor, a destructor and all the methods necessary to add/delete vertices, add/delete edges… Write a menu-driven program to THOROUGHLY check your class and all the functions included in your program. You can choose the data type. Allow the user to continue with operations as long as he/she wants to. Your program should check if an operation...
***** running late, mere 3 hours left for due time, please help ** #needed in c++ #inputfile MinPath2.txt 0 SF 1 LA 2 DALLAS 3 CONCORD 4 PHOENIX 5 CHICAGO 6 ST LOUIS 7 BOSTON 8 NY 9 LONDON 10 PARIS 11 TOKYO 12 BANGKOK 13 MEXICO CITY 14 MONTREAL -1 0 1 40 0 2 100 0 4 130 0 8 200 0 9 800 0 10 900 1 2 50 1 3 80 1 4 70 1 8 ...
PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here do { // program here }while (true); } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...
Please post following code with criteria below... please leave as many comments as possible Exam Four: the election Outcome: Student will demonstrate all core competencies from this class: Program Design (design tools) Variables Decision Error Checking Looping Functions Arrays Program Specifications: Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama. You can assume that there are fifty states casting votes. You will do not need to deal...
can anyone help me figure out how fo write matlab code for these problems? BME 2013 Spring 2019 Exam 3 Matlab Review Sheet 1. Given the vector of patient body temperatures T (98.6, 102, 101, 99,98.9, 102.1, 100.3, 101.2, 98.4 97.6, 100] use conditional statements and loops to write a program that determines and displays (using the fprintf function) the number of patients with a fever and patients without a fever. The program must ask the user to input the...
CAN SOMEONE PLEASE HELP ME WRITE THIS CODE IN C++, PLEASE HAVE COMMENTS IN THE CODE IF POSSIBLE!! General Description: Write a program that allows the user to enter data on their friends list. The list holds a maximum of 10 friends, but may have fewer. Each friend has a name, phone number, and email address. The program first asks the user to enter the number of friends (1-10). You are not required to validate the entry, but you may...
Write a C++ code for this question- Write a program with a method that plays the guess a number game. The program should allow the user to pick a number between 1 and 1000 in his head. The method should guess the user's number in a minimal amount of attempts. The method should ask the user "is the number greater than or less than the number " and the program gives a particular number. The user in some way just...
Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an email address, and reports to the user whether or not the email address is valid. For the purposes of this assignment, we will consider a valid email address to be one that contains an @ symbol The program must allow the user to input as many email addresses as desired until the user enters "q" to quit. For each email entered, the program should...