write the program with limited method – timelynursingwriters.com

Programming – timelynursingwriters.com

write the program with limited method – timelynursingwriters.com

Goals:

  • Create your own linked list.
  • Perform basic linked list operations.

Requirements:

Write a program that implements and demonstrates a linked list using functions. Your program should first define a node that stores an integer and then your program will include the following functions:

  • append() – This function accepts the head pointer (by reference) of a linked list and an integer as it’s only arguments. It then creates a node, stores the integer argument in the node, and adds it to the end of the list.
  • find() – This function accepts the head pointer (by value) of a linked list and an integer to search for in the list as it’s only arguments. It then searches the list for the first occurrence of the integer argument. If it finds it, it returns true. If it doesn’t, it returns false.
  • clear() — This function accepts the head pointer of a linked list (by reference) as it’s only argument. It then removes all the nodes of the linked list from memory by deleting them one at a time. The function leaves the head pointer set to nullptr.
  • print() – This function accepts the head pointer of a linked list (by value) as it’s only argument and then displays on the screen all the integers stored in the list.
  • remove() — accepts the head pointer of a linked list (by reference) and an integer as it’s only arguments. The function then search for the integer argument in the list and removes the first node it finds containing the integer argument from the list.

Demonstrate your functions by adding 5 numbers to the linked list. Then, print the list. Then search the list for a value and then indicate the result. Then, remove a number from the list. Then, print the list. Then, clear the list. Then, print the list one last time.

The only functions that interact with the user is the print() function (and main()). No other functions contain cin or cout statements.

Notes:

  • Your solution will receive major penalties for memory leaks.
  • This assignment is a “capstone” assignment where you will demonstrate your accumulated knowledge over the semester.

A 20-Point Sample Run:

The first line contains all the integers of my list after appending them.

The second line is the result of my find function searching for 68.

The third line is my list after I removed 35 using the remove function.

Hints:

  • Make sure you understand pointers and dynamic memory allocation.
  • Write your print() function first, it will help in testing.
  • Write one function at a time.
  • Use hand-tracing to hunt down any errors.
  • If your program crashes, it is almost certainly because you are dereferencing an invalid memory location which is the result of a logic error.

ORDER NOW