Question
C++ linked list help! 1. Create a single source file (.cpp or .cc), 2. Implement a struct called listNode before main() to represent each node
C++ linked list help!
1. Create a single source file (.cpp or .cc),
2. Implement a struct called listNode before main() to represent each node in the singly-linked list. Use a typedef before main to set the type of the element stored in the struct (set to int for this lab),
3. Write three functions, tested using the instructions below: a. Insert node takes a pointer to the first element in the list and the item to add as parameters (make sure to use the typedef for the type!). Adds the specified item to the end of the list. b. Delete node takes as parameters a pointer to the first element in the list, and takes an element (i.e., type defined by the typedef) to delete from the list if found. For simplicity, assume there are no duplicate items in the list. c. Print list takes a pointer to the first element of the list, prints the entire list from start to end.
Testing:
1.Create nodes with following values: 326 38 27 94 4 8 15
2. Delete node 94
3. Add new node 16(should be added to end)
4.Print the list.
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