Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

n C language, with linked list , not array In this assignment, you will build a linked list data structure for storing and organizing a

n C language, with linked list, not array

In this assignment, you will build a linked list data structure for storing and organizing a student list that can be iterated in name-alphabetical order (sorted based on the names of the students), in surname-alphabetical order (sorted based on the surnames of the students), and in numeric order (sorted based on the student IDs). The students with their names, surnames, and IDs will be read from an input file (i.e., students.txt) and they will be organized by using a singly linked list data structure in the program. Each student struct in your linked list should contain a char pointer, as name; a char pointer named, as surname; a long integer, named as ID; a pointer to a struct with the same type, named as name_next; a pointer to a struct with the same type, named as surname_next; a pointer to a struct with the same type, named as ID_next. Below is a picture of the relationships between the nodes with only three students:

Thats a whole lot of pointers!! The example above contains only 3 nodes (i.e., students) connected to each other with name_next, surname_next, and ID_next pointers. These pointers tie nodes to each other based on the name-alphabetical order, the surname-alphabetical order, and the ID order (increasingly). As it is seen from the example, there are 3 different types of orderings of the students. There are three head pointers (i.e., name_head, surname_head, and ID_head) that show the

name: Ayse surname: Yilmaz ID: 1204 name_next surname_next=NULL ID_next
name: Veli surname: Aslan ID: 1515 name_next = NULL surname_next ID_next = NULL
name: Fatma surname: Ozde ID: 1001 name_next surname_next ID_next

name_head surname_head ID_head starting node based on the target order. It should be noted that the head pointers can show either different or similar nodes (or students) based on the target ordering. Firstly, you should construct the linked list (and the connections) based on the given input file. Then, we can insert a new student to the list or delete an existing student from the list. When we add a new node to the list, it must be inserted to the sorted list to maintain the consistent alphabetical and ID orderings. We can delete any existing node from the beginning, middle, or end of the list. After insertion and deletion operations, you should carefully re-arrange the links among the nodes. Your tasks: You should declare a student struct with the mentioned features above. You should implement a function insertNode to insert a new node to your list. You should carefully arrange the pointers to construct different orderings. You should implement a function deleteNode to delete an existing node from your list. You should carefully arrange the pointers to maintain consistent orderings. You should implement a function printList to print the content of the linked list based three different orderings. You can use the linked list examples covered in lectures to implement these functions. Firstly, you should read the names, surnames and of the students from a given input file (i.e., students.txt). The input file name is given as a first command line argument to your program. Then, you should print the content of the list to the standard output (stdout) based on three orderings. Then, print a menu to the user containing options such as; o insert a new node to the list, o delete an existing node from the list, o print the content of the list based on the three orderings to the standard output, o print the content of the list based on the three orderings to a given output file, and o exit from the program.

An example input file (ex: students.txt) and the produced output file (ex: output.txt) are given to you based on the sample execution scenario given below. In the input file, the name and the surname of a student is separated by a single space (consider that a student has only a single name and surname), and the ID is separated using a TAB character.

example:

Enter your choice: 1 to insert a student into the list. 2 to delete a student from the list. 3 to print the students in the list. 4 to print the students to an output file. 5 to end.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

4. Who should be invited to attend?

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago