Question
C++ Linked Lists This program is to implement a number of functions on a linked list. 1.Insertion of a node to a linked list, by
C++
Linked Lists
This program is to implement a number of functions on a linked list.
1.Insertion of a node to a linked list, by given criteria
2. Deletion of a node on a linked list, by given criteria
3. Search a node on a linked list, by given criteria
4. Sorting a linked list, by given criteria
5. Write: print out information (name and score) in each and every node on the linked list, from the first node to the last Node
structure: Use the circular doubly linked list discussed in lecture Info Field: Name (only one string, for simplicity) Score (an integer) Links: prev, next
1. Insertion criteria: a. The linked list insertion is based on alphabetical order of the given names. b. Names will not be duplicated. 2. Deletion criterion For a given name, delete that name associated node from the linked list, if it exists.
3. Search criteria: a. For a given name, search on the linked list if there is a node that has this name. b. If found, print out the node info: Name and Score. One single line for each searched node. c. If not found, print out not found. d. The search process cannot change any info or node on the list.
4.Given a criterion, sort the linked in either ascending or descending order. The program reads from a3.txt for actions (insertion, deletion, or search): %SEARCH, %INSERT, %DELETE, %WRITE, %SORT, %END The WRITE command directs the program to print out information (name and score) in each and every node on the linked list, from the first node to the last. The SORT is to sort the list according to the scores, in ascending order. The END command ends the program running, but not closing the window.
A code blocks project (assig3_start) is provided as a starting point to build on. The project opens the text file and reads in the instructions. This is provided as an example as to how to read in the instructions and do conversions from strings to integers. The program uses an if-then-else structure for implementing the commands. Also the project provides a possible llist (linked list) class structure to implement the linked list functions. Please feel free to use this structure or change it. There are many ways to implement these functions. Hint for implementing the sort function you can use the selection sort algorithm. You can use two pointersthat are moved as the for loop indices are incremented. You need a swap function for nodes. It is easier to swap node data than pointers but this is less efficient for nodes that hold large amounts of data.
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