Linked List
In this program, you will implement a number of functions:
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
Node structure:
Info Field: Name (only one string, for simplicity)
Score (an integer)
Link: a pointer
1. Insertion criteria:
a. The linked list insertion is based on alphabetical order of the given names.
b. If a node on the list has the same name as the one that is to be inserted, then the
existing one is deleted and the new one is inserted.
2. Deletion criterion
For a given name from a3.txt, delete that name associated node from the linked list.
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.
The program reads from a3.txt for actions (insertion, deletion, or search):
%SEARCH, %INSERT, %DELETE, %PRINT, %END
The “PRINT” command directs the program to print out information in each and every node
on the linked list, from the first node to the last. The “END” command ends the program
running, but not closing the window.
below is the file
%INSERT
MARK 29
DAVID 21
JOHN 44
JOHN 51
LARRY 39
MARK 21
DAVID 18
JOHN 28
MARK 35
DONALD 41
PHIL 26
%PRINT
%DELETE
MARK
DAVID
%PRINT
%SEARCH
JONE
DAVID
LARRY
%INSERT
LARRY 13
GARY 15
GARY 42
%PRINT
%INSERT
TERRY 23
%DELETE
GARFIELD
%SEARCH
PHIL
%PRINT
%END
I am having hard time doing this program....
was wondering if someone can help
It is best if you answer this question so it does not look like you just want someone to do it for you: What have you done so far and what errors/problems are you having?
i have started the main program but am not sure how to read the file
i mean i can open the file but then how to read
%INSERT
%PRINT
and after reading i know i need to create diffrent function which i can do
but am stuck at beganning
int main()
{
ifstream infile;
infile.open("a3.txt");
if (!infile.is_open()){
cout << "Error Opening file! Check folder for a file!"<<endl;
exit(1);
}