Question
C++ Using the diagram presented in the section called Diagram 1 on page 2. You are to first create the 4directional linked list to appear
C++ Using the diagram presented in the section called Diagram 1 on page 2. You are to first create the 4directional linked list to appear as illustrated in the diagram. Use the same names for each node asshown in the diagram and the directions between the nodes are two way. You can directly input thesenodes and their directions in the main.Your program should then ask the user for a starting node and an ending node. They are able to chooseany starting and ending locations and your program should be able to begin from that starting node (byplacing a pointer to that node) and going through each of the 4 directions until it finds the ending node.At this point, it should output the path it took. An example of the ending result is shown below.This test will be covering linked lists as well as recursion. Because of this, you are to solve the problemusing one recursive function. This functions base case is if the current node it is located in is equal tothe node the user typed in as the ending node. If it is, you are to output the name of that node andterminate the current node (this base case gives us the path in reverse, which is what we want).Assuming the testing goes up, left, down, rightOUTPUT:Please enter the starting node: BPlease enter the destination node: IGoing left to AGoing down to DD endsA endsGoing down to EGoing down to HGoing left to GG endsH endsGoing right to FGoing up to CC endsGoing down to IDestination Reached, path was: I F E BBe aware that if the testing goes up, right, down, left, it would give a different answer. Your programwill allow ANY start node and ANY destination node... even if they type in the same start anddestination.
Diagram 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started