Description
Write 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 section
Given
You are given the following file:
main.cpp
What to Submit
Submit for this lab:
main.cpp
Requirements
Implement the exchange_data function in main.cpp
You may add more functions that are needed to implement the above
Your code will not cause any runtime errors such as segmentation faults
Answer all three questions in the Problems Encountered & More section
Tips
Use visual aids to help you understand your plan for the function
Consider boundary cases, such as:
When the list is empty
When the list has only one node
You might want to “rewrite” or “copy/type out” other functions that are already implemented to solidify your understanding with linked list first
Test Cases
Suggestion: 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 7
Problems Encountered & More
In 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========================================================== */
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.
The post void question appeared first on The Nursing TermPaper.


0 comments