Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NCBC 2006-Data Structures I Assignment #3 A gentle introduction to linked lists Please remember to read and follow all of the assignment guidelines. In particular,

image text in transcribed
image text in transcribed
image text in transcribed
NCBC 2006-Data Structures I Assignment #3 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 I. 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 first 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 file containing student number and mark pairs, one per line. For example, the file 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: 22222 59.9 63.5 635 599 2 of 3 635 Top-> Third line: Top 33353 After 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 finish, nearly in a table. For example: Student Number: Mark 33333 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 function 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 find 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 media is cased 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 citier 80 of 70 for the median). From the example above, your program should print out something like The median mark is 63.5, by studcat 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, test.txt and test2.txt): Data set 1: 11111 63.5 22222 599 33333 82.4 44444 701

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

Intercultural Communication Challenges?

Answered: 1 week ago

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago