DescriptionWrite a void function that takes a linked list of integers and interchanges data in the first node with that in the last node. The function will take a pointer to the head of the list. After the function is called, it will retrieve data stored in it, then find and retrieve data stored in the last node. The function will then interchange the data of the first node with that of the last node.Note that your function will neither create nor destroy any nodes. It will simply interchange the data stored between the head and tail nodes. Place your function in a suitable test program.** Please answer all three questions in the Problems Encountered & More sectionGivenYou are given the following file:main.cppWhat to SubmitSubmit for this lab:main.cppRequirementsImplement the exchange_data function in main.cppYou may add more functions that are needed to implement the aboveYour code will not cause any runtime errors such as segmentation faultsAnswer all three questions in the Problems Encountered & More sectionTipsUse visual aids to help you understand your plan for the functionConsider boundary cases, such as:When the list is emptyWhen the list has only one nodeYou might want to ‘rewrite’ or ‘copy/type out’ other functions that are already implemented to solidify your understanding with linked list firstTest CasesSuggestion: Change main.cpp to add more ways to test your reverse function implementation.Demo Just finished adding nodesCurrent linked list:7 5 4 8 9Just finished exchanging dataCurrent linked list:9 5 4 8 7Problems Encountered & MoreIn the end of your main.cpp file, add a blocked comment section as follows and fill it out:/* ==========================================================Q1. Problems I had working on this assignment (and how I overcame these problems)1.2.Q2. When implementing exchange_data, I had passed in head as a parameter:// your answer: by value or referenceQ3. The reason being:// your answer: explain your choice========================================================== */ ..
Never use plagiarized sources. Get Your Original Essay on
DescriptionWrite a void function that takes a linked list o
Hire Professionals Just from $11/Page