QuestionQuestion

Write a program that reads a list of students (first names only) from a file. It is possible for the names to be in unsorted order in the file but they have to be placed in sorted order within the linked list.

The program should use a doubly linked list.

Each node in the doubly linked list should have the student’s name, a pointer to the next student, a pointer to the previous student and a pointer to a single linked list that will contain each student’s set of scores. Here is a sample visual. The head points to the beginning of the list. The tail points to the end of the list.

The information for each student will be on a single line in a text file. Below, you will find a sample of what the file looks like. Notice the names are in unsorted order but the information placed in the linked list (above visual) is in sorted order. The name of the file should be “input.txt”. Also, notice the scores for each student ends with the word “end”.

In the text file, the word delete followed by a name, should delete the node with that specific student’s name from the doubly linked list. If the name is not found, then nothing is deleted.

(NOTE: The above visual represents only the first three lines from the text file below.)

Jim 70 95 end
jill 50 90 80 end
John 65 end
delete jill
jack 50 35 end
delete jim

At the end of the program, traverse through the contents of the linked lists in both ascending and descending order, using the doubly linked list, and write the contents into the file output.txt. For example, given the above list, here is the sample display:

John    65
Jack 50 35
=============
Jack 50 35
John    65

Assumptions: Names are all in lower case. Names cannot be duplicated.

Summary:

When deleting, make sure to use deallocate all the spaces. This would be all the scores for the individual from the singly linked list and the individual from the doubly linked list.

There is no user input. Everything is done through the file.

• Code should be modularized.
• Do not use classes. Write the program in C.
• The only global variables should be the file handles.
• The name of your input file should be input.txt.
• The name of your output file should be output.txt.
• The names in the text file may appear in unsorted order but should be inserted into the linked list in sorted order.
• End marks the end of the list of scores for each student.
• Delete, followed by a name, should eliminate that individual, along with his/her scores from the list.
• The list should be written in ascending and descending order, with a line in-between, into the file, output.txt.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LENGTH 50
#define MAX_SIZE 500

// structs

// Score node
struct Score{
    int score;
    struct Score * next;
};
typedef struct Score Score;

// Student node
struct Student{
    struct Student * next;
    struct Student * prev;
    char * name;
    Score * scorePtr;
};
typedef struct Student Student;

// double linked list
struct DoubleLinkedlist{
    Student * head;
    Student * tail;
};...
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats