Question
5.Write a function deleteFirst that will delete the first node in a linked list pointed to by the parameter head. Should head be a value
5.Write a function deleteFirst that will delete the first node in a linked list pointed to by the parameter head. Should head be a value parameter or reference parameter?
6.Write a boolean function called find that will be given a pointer to a linked list and a value. If the value is in the linked list, it should return true; if not, it should return false.
7.Starting from picture C, draw the pictures that show step by step what is needed to get to picture D. We are assuming the part of the linked list shown is somewhere in the middle of a long linked list.
C D
Using your pictures, write the code to delete a node from the middle of the linked list starting from picture C. Now insert before it the code that will move currentPtr and previousPtr through the list until it finds a particular value if it exists (look at the find function from above). The previousPtr should start out as NULL and always be one node behind the currentPtr. Use your code to make a boolean function findAndDelete that is given a pointer to a linked list and a value, and if the value is in the linked list, it is deleted and the function returns true. If it is not in the list, the function returns false.
8. Expand your menu to test your three new functions. When choosing to test the find or findAndDelete functions, the user will be first asked to enter the value to find or to find and delete. Depending on whether the functions returned true or false, the main program should write an appropriate message to the user.
9. Finally write a function called deleteList that will delete all nodes in the linked list and return the parameter head set to nullptr. You can add it to the menu for testing, but also put it at the end of the program to release all dynamic memory you used.
18 8 NULL NULL currentPtr previousPt c currentPtr previousPtrStep 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