Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ ONLY PLEASE Country * createLoop(string countryName); As a way to test the detectLoop() function, develop a createLoop() function that adds a loop to the
C++ ONLY PLEASE
Country * createLoop(string countryName); As a way to test the detectLoop() function, develop a createLoop() function that adds a loop to the linked list pointed to by head. You'll achieve this by creating a link from the last node in the linked list to an intermediate node. The function takes as argument the country name of that intermediate node to loop back into. The function should return the last node of the linked list before creation of the loop. This will be needed by the driver function to break the loop. For example, consider the linked list: "A - B - C - D - E -> NULL". Suppose the function is called as -- createLoop ("C"); After execution of the function the linked list should be "A - B - C -> D -> E ->C" and it will return a pointer to the node E. NOTE: node E was the last node before creation of the loop. If the country is not present in the linked list, the function should return without creating a loop. A pointer to the last node should still be returnedStep 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