Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please it has to be in c++ Consider that individual nodes in an unsorted linked list have the following definition: struct ListRec {char value; ListRec*

image text in transcribed

Please it has to be in c++

Consider that individual nodes in an unsorted linked list have the following definition: struct ListRec {char value; ListRec* next;}; Without implementing a separate class to maintain the list, simply create a simple list directly in the main function You should create a pointer to point to the head of the list, and name that pointer head. Use the previously stated definition of a node, and create the following list in main: In the above visual depiction, the means that the next data member points to NULL (or nullptr.) Write a void function in the same file as means to print out a linked list, given that the head is passed into the function as an argument. The prototype (and subsequently, the header) of the function should look like this: void print(ListRec* listHead) {//print out the elements in the list} Write another function that takes two parameters bullet The head of a list to be copied bullet The head of another list that will contain the copy of the first bullet The function performs a deep copy. Recall that with a deep copy, you must create a new node and copy over the value from the corresponding node in the list being copied to the list that will contain the copy. The function prototype/header is as follows: void deepCopy(ListRec* oldListHead, ListRec* newListHead) {//perform a deep copy from old list to new list} Write the main function to perform a test of each of the above tasks It must create the list (task 1), call the print function (from task 2), and the deepCopy function (from task 3.) From main, you should: make a copy of the original list change the data in first node of the original list call the print function on both the original list you created, and the copied list to verify that the deep cop)-worked as expected

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions