Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A gentle introduction to linked lists Please remember to read and follow all of the assignment guidelines. In particular, for this problem, remember to write

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
A gentle introduction to linked lists Please remember to read and follow all of the assignment guidelines. In particular, for this problem, remember to write your own routines and classes for dealing with linked lists-don't just reproduce the ones in the textbook or notes. Also keep in mind the essentials of program design; each basic operation you perform should be in one (or more, if necessary) method (s). For this assignment, you are to write a Java program to perform some manipulations on a list of students' marks, similar to the assignment 1. Given the ever-increasing class sizes at universities, your program should use a linked list to store the mark for each student. You may be able to use part of code from assignment 1 if you want to. Each node in the linked list should contain two pieces of data-the student's number (an integer) and that student's mark (a double). In the linked list, student marks should be stored in order of descending mark values; thus, the rst student in the linked list should be the one with the highest mark, the second in the list should have the second highest mark, and so on. This order should be maintained for each student added to the list (when you add a new node to the linked list, insert it at the correct position to maintain sorted order). Input data to your program will consist of a le containing student number and mark pairs, one per line. For example, the le might contain: 11111 63.5 22222 59.9 33333 82.4 Every time you read in a line from the file, dynamically create a new node containing that student's number and mark, and insert it in the correct position in the linked list. For example: After reading the first line of data: Top-> Second line: 11111 22222 63.5 59.9After reading in all of the data and storing it in your list, you should perform two operations on the list. First, you should print out the contents of the linked list, from start to nish, nearly in a table. For example: Student Number: Mark: 33333 82.4 11111 63.5 22222 59.9 Secondly, you should print out the median mark in the list. However, there are two rules you must follow. First, the method you use to calculate the median mark must be recursive. The functionx'method which calculates the median cannot use any loops, or call any functions which use loops. This function should return the node in the list which contains the median mark. Secondly, in order to nd the median, you need to know how many items in total are in the list. Your recursive function must calculate that number (also recursively); you may not keep track of this count elsewhere your program. Your recursive solution should only examine each node only once, and the depth of the recursion should be equal to the number of nodes in the list. In order to make this (slightly) easier, the normal mathematical calculation for determining median is eased somewhat-if you have an even number of nodes in your list, either of the two marks in the middle may be considered the median (for example, if your list contains the four marks {90, 80, 70, 60 }, your function could return either 80 or 70 for the median). From the example above, your program should print out something like: The median mark is 63.5, by student number 11111. You do not require to have any interface, but are encouraged to do so. Submission: Upload into CMS with the source code of your program, and the output of running your program twice, using the following two sets of input data (save as files, test1.txt and test2.txt): Data set #1: 11111 63.5 22222 59.9 33333 82.4 44444 70.1\f

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions