Question: 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

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 returned

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!