Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. Create a project for this lab. Get the files node1.h and node1.cpp that contain the linked list toolkit and add them to the project.
. Create a project for this lab.
Get the files node1.h and node1.cpp that contain the linked list toolkit and add
them to the project.
Include the files check lists.cpp and check lists.h in the project.
Create a C++ file that will contain a main program.
2. Create a function that will print a list out, given the header node. Here is the function
header: void list print(node * head ptr)
1
Place this function before the main function in your program.
The function should print out the elements in the list separated by spaces all on
one line.
The function should print an end of line after the list data is printed.
3. Carry out the following steps in the program, that is, in the function main.
Create a list header and insert the following data in order: 23.5, 45.6, 67.7, 89.8,
12.9
Print out the list using the function you wrote.
Call the function check list1 with the list as argument. This will print a single
message if successful. Otherwise the program will terminate.
Create a list with two pointers, one to the head and one to the tail.
Insert 23.5 into the list. Then insert these elements in order at the tail of the
list: 45.6, 67.7, -123.5, 89.8 and 12.9.
Print the list. Then call the function check list2 with the list as argument.
Declare head and tail pointers for another list
Use those pointers to make a copy of the first list you created. Print the list.
Call the function check list1 with the list as argument.
Print out the data at the tail of the list, it should be 23.5.
Remove the first item in the second list created above.
Print the list.
Call the function check list2B with the list as argument
Continue with the same list and remove the third item in the list.
Print the list.
Call the function check list2C with the list as argument.
4. Here is the output from one version of the exercise. This uses a fancier version of the
print list function.
{12.9, 89.8, 67.7, 45.6, 23.5}
check list1 done
{23.5, 45.6, 67.7, -123.5, 89.8, 12.9}
check list2 done
at location 4 in list2 -123.5
{12.9, 89.8, 67.7, 45.6, 23.5}
check list1 done
at tail3: 23.5
{45.6, 67.7, -123.5, 89.8, 12.9}
check list2B done
{45.6, 67.7, 89.8, 12.9}
check list2C done
Step 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