Question: Please implement in C++. Problem 2: Going home [5 pts) On one late night wing you were going back home after meeting one of your

 Please implement in C++. Problem 2: Going home [5 pts) On
Please implement in C++.

Problem 2: Going home [5 pts) On one late night wing you were going back home after meeting one of your friends Before saying goodbye and taking different a path than your friend to go back home, you thought: What if there is a certain path that we can both take that maximize the umber of roads we walk together before separating, stach path is not longer than the shortest path I would take going home alone, and the same is true for my friend? Let us represent the city you were in as an unlitected graph G = (VE), where a vertex stands for a neighborhood, and an edgee is around between two neigh- borhood. Moreover, you are initially a vertex S with you feed. You are and to find a vertex U that maximizes that number of edges along the path from S to U. Also going from Stol with your friend them aparating paths at an oing home will be equivalent to taking the shortest path from S to your home (this should also bold for your friend as well, that is one of the shortest paths that leads from 3 to your friend's home should also have as initialement the path S-U). Please make sure to explain your approach for this prob lem, to elaborate on the proof of correctness of your algorithm, and to calculate the running time complexity of your code Input: first line is NMS Hy the muber of sighborhood, the number of edges, the starting neighborhood, the neighborhood your house is in, and the neighborhood your friend's how is in respectively. In each of the Taxt Mines you are given 2 intes , nifying that there is an edge between and (Note that the graph is 0-indexed, that is, the first buildings and the last bull - Output: find a vertex U that maximizes the death of the path S - Recall that at least one of the shortest paths from s to your home and from S to your friend's home should have as initial segment the path S-t. Note that if all shortest paths from Sto do not internect with any of the shortest paths from Sto, then the awer is that bus Sample input/output: Input 670 45 01 02 03 24 11 output 1 Explanation: both you and your friend shall take the path 0-1 then will separate pathus, and you will go 1 - 4 and your friend will po 1-5 Note: If O and 4 (or and Sin care of your friend) were cotinected, then you wonki have taken the path to directly in this hypothetical scenario, you peder loeter paths to home than friendship) Grading: you should concisely and cobertently explon your approach along with the proof of corrections and the running time complexity of your code. Further more your program should run in O(+) and produce correct results for any valid input in order to get 5 points on this question. Any program that runs in a higher time complexity than the aforementioned shall get points deducted depending on how bad the time complexity of the program is. A program that have exponential running time yet produce correct results shall at only 1 point Problem 2: Going home [5 pts) On one late night wing you were going back home after meeting one of your friends Before saying goodbye and taking different a path than your friend to go back home, you thought: What if there is a certain path that we can both take that maximize the umber of roads we walk together before separating, stach path is not longer than the shortest path I would take going home alone, and the same is true for my friend? Let us represent the city you were in as an unlitected graph G = (VE), where a vertex stands for a neighborhood, and an edgee is around between two neigh- borhood. Moreover, you are initially a vertex S with you feed. You are and to find a vertex U that maximizes that number of edges along the path from S to U. Also going from Stol with your friend them aparating paths at an oing home will be equivalent to taking the shortest path from S to your home (this should also bold for your friend as well, that is one of the shortest paths that leads from 3 to your friend's home should also have as initialement the path S-U). Please make sure to explain your approach for this prob lem, to elaborate on the proof of correctness of your algorithm, and to calculate the running time complexity of your code Input: first line is NMS Hy the muber of sighborhood, the number of edges, the starting neighborhood, the neighborhood your house is in, and the neighborhood your friend's how is in respectively. In each of the Taxt Mines you are given 2 intes , nifying that there is an edge between and (Note that the graph is 0-indexed, that is, the first buildings and the last bull - Output: find a vertex U that maximizes the death of the path S - Recall that at least one of the shortest paths from s to your home and from S to your friend's home should have as initial segment the path S-t. Note that if all shortest paths from Sto do not internect with any of the shortest paths from Sto, then the awer is that bus Sample input/output: Input 670 45 01 02 03 24 11 output 1 Explanation: both you and your friend shall take the path 0-1 then will separate pathus, and you will go 1 - 4 and your friend will po 1-5 Note: If O and 4 (or and Sin care of your friend) were cotinected, then you wonki have taken the path to directly in this hypothetical scenario, you peder loeter paths to home than friendship) Grading: you should concisely and cobertently explon your approach along with the proof of corrections and the running time complexity of your code. Further more your program should run in O(+) and produce correct results for any valid input in order to get 5 points on this question. Any program that runs in a higher time complexity than the aforementioned shall get points deducted depending on how bad the time complexity of the program is. A program that have exponential running time yet produce correct results shall at only 1 point

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!