| | |
Please Help With Linked List Programming
![]() |
•
•
Join Date: May 2006
Posts: 4
Reputation:
Solved Threads: 0
I have a program project to complete, but I don't know exactly what to do. This program is in C++ programming language. This what I have to do?
Write a program that will use a array to store a linked list. Your linked list should contain an Student number and an the student's last name. You linked list should use the student number as the key field to order the list and contain a maximum of 8 students. Each line will start with a number that will indicate the operation. The data necessary to perform the operation will follow. Each operation shoud print out a message indicating that it was performed correctly. Your program should process the following operations:
Initialize an empty list
This operation should initialize the list to an empty list
0
Add an student to the list:
This operation should add this student to the linked list
1 4521 Smith
Delete an student from the list:
Delete this student from the linked list. If the student is not in the list, print a message.
2 1000
Print the list in Logical Order
3
Find an student in the list:
Find this student from the linked list. If the student is not in the list, print a message.
4 1000
Print the list in Physical Order
This operation should print the physical contents of the list along with all of the links, list and free.
5
Your program should read the input from a data file by redirecting the input to the program ($ a.out < datafile).
Example data file:
0
1 3000 Hill
1 1000 Smith
1 2000 Green
3
5
For this data file, the first operation should initialize the list, the next 3 operations should add the 3 students to the list, the 4th operation (3) should print the list logical order:
1000 Smith
2000 Green
3000 Hill
The last operation (5) should print the physical contents of the list.
list=1 avail= 3
0 3000 Hill -1
1 1000 Smith 2
2 2000 Green 0
3 4
4 5
5 6
6 7
7 -1
Write a program that will use a array to store a linked list. Your linked list should contain an Student number and an the student's last name. You linked list should use the student number as the key field to order the list and contain a maximum of 8 students. Each line will start with a number that will indicate the operation. The data necessary to perform the operation will follow. Each operation shoud print out a message indicating that it was performed correctly. Your program should process the following operations:
Initialize an empty list
This operation should initialize the list to an empty list
0
Add an student to the list:
This operation should add this student to the linked list
1 4521 Smith
Delete an student from the list:
Delete this student from the linked list. If the student is not in the list, print a message.
2 1000
Print the list in Logical Order
3
Find an student in the list:
Find this student from the linked list. If the student is not in the list, print a message.
4 1000
Print the list in Physical Order
This operation should print the physical contents of the list along with all of the links, list and free.
5
Your program should read the input from a data file by redirecting the input to the program ($ a.out < datafile).
Example data file:
0
1 3000 Hill
1 1000 Smith
1 2000 Green
3
5
For this data file, the first operation should initialize the list, the next 3 operations should add the 3 students to the list, the 4th operation (3) should print the list logical order:
1000 Smith
2000 Green
3000 Hill
The last operation (5) should print the physical contents of the list.
list=1 avail= 3
0 3000 Hill -1
1 1000 Smith 2
2 2000 Green 0
3 4
4 5
5 6
6 7
7 -1
This seems to me an excersize similar to serialisation. A real linked list would use pointers to connect the "nodes" - if you're using an array to simulate addressable memory, then use an int to contain the array indexes, simulating the pointers. The rest of the program should be fairly similar to a real linked list.
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- help implementing singly linked list (C++)
- Doubly Linked List Problem (C++)
- doubly linked list implementation (Java)
- Cannot figure out how to implement linked list and rbtree for a project! (Java)
- Linked List (C++)
- help by sorting a simply linked list (C)
Other Threads in the C++ Forum
- Previous Thread: skiping inputs
- Next Thread: Getting back into it.
| Thread Tools | Search this Thread |
action api array auto based beginner binary bitmap c++ c/c++ calculator challenge char class classes code coding compile console conversion count createcopyofanyfileinc delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game garbage givemetehcodez graph gui hmenu homeworkhelp homeworkhelper iamthwee ifstream input insert int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node noob output parameter pointer primenumbersinrange problem program programming project python random read recursion reference rpg sockets string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets





