NCBC 2006-Data Structures I Assignment #3 A gentle introduction to linked lists Please remember to read...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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 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: 11111 22222 63.5 59.9 63.5 Top-> Third line: Top-> 33333 11111 22222 82.4 63.5 59.9 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 82.4 11111 22222 63.5 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 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 55555 72.3 66666 89.5 77777 68.7 88888 53.2 99999 66.8 Data set #2: 58585 72.9 43434 80.0 90909 82.3 87878 62.1 62626 64.7 71717 74.6 92929 51.5 36363 55.9 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 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 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: 11111 22222 63.5 59.9 63.5 Top-> Third line: Top-> 33333 11111 22222 82.4 63.5 59.9 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 82.4 11111 22222 63.5 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 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 55555 72.3 66666 89.5 77777 68.7 88888 53.2 99999 66.8 Data set #2: 58585 72.9 43434 80.0 90909 82.3 87878 62.1 62626 64.7 71717 74.6 92929 51.5 36363 55.9
Expert Answer:
Answer rating: 100% (QA)
Complete Java Program import javautilScanner import javaioFile import javaioFileNotFoundException class Student int number double mark Student next public Studentint number double mark thisnumber numb... View the full answer
Related Book For
Accounting Business Reporting For Decision Making
ISBN: 9780730302414
4th Edition
Authors: Jacqueline Birt, Keryn Chalmers, Albie Brooks, Suzanne Byrne, Judy Oliver
Posted Date:
Students also viewed these programming questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Common structural steel can be represented on drawings using a letter, immediately followed by a number, then another number (for example, S14x30). The two numbers for a steel member W16x60 designate...
-
What is big data?
-
Refer again to the crosstabulation of household income by educational level shown in exercise 31. a. Compute column percentages and identify the percent frequency distributions displayed. What...
-
Write the symbol for an atom or ion with: a. four electrons, four protons, and five neutrons. b. six electrons, seven protons, and eight neutrons.
-
The May 2012 revenue and cost information for Houston Outfitters, Inc., follows: Requirement 1. Prepare a standard cost income statement for management through gross profit. Report all standard cost...
-
The editor of Marker Buzz, a business m taff to come to the next staff meeting with suggestions based on who reads the magazine and any of ditor using to improve decision making?
-
HBR Working Capital Simulation: Step 2 (Analyze Reports) and Step 3 (Enter Decisions) In these steps of the simulation, you will act as the CEO of Sunflower Nutraceuticals and decide whether to...
-
Below is a model of the product design process. Explain what is going on here in terms of teamwork and a successful product. Percent of work being done Function design/styling Technical design...
-
7.12 There is a 20% chance the outcome is a gain of $100 and an 80% chance the outcome is a loss of $100. What is the expected value of the outcome?
-
Read the article " The Twitter Trap " by Bill Keller carefully. In this article, Keller uses his personal experiences to attract the audience and uses funny examples to help the audience understand...
-
create 3 possible test questions for each math equation listed with an explanation on how to solve them. Some or all of the following formulae may be required to complete certain quantitative...
-
Department of Energy's "Guide to Renewable Energy." How does the word incentives affect the meaning of this sentence? Installing renewable energy systems can be costly, but federal and state...
-
A Monorail Train Starts From Rest On A Curve Of Radius 400 Meters And Accelerates At The Constant Rate At. If The Maximum Total Acceleration Of The Train Must Not Exceed 1.5 M/s^2, Determine The...
-
The comparative statements of financial position of Menachem NV at the beginning and end of the year 2019 appear below. Net income of ¬34,000 was reported, and dividends of ¬23,000 were paid...
-
Haily Smith and Amelia Wee are discussing the results of the Aqeo Partnership. Presented below is the Aqeo Partnership statement of cash flows for the year ended 31 December 2012. a. Assess why Haily...
-
(a) What recommendations for safeguarding the integrity of financial reporting are recommended in principle 4? (b) Are there any other core principles that relate directly to financial reporting...
-
Briter Ltd, a carpet steam-cleaning business, needs to acquire new machinery. The accountant has suggested that the entity should lease the machinery rather than take out a loan to purchase it. When...
-
Powerhouse Ltd purchased machinery on 2 January 2019, at a cost of $800 000. The machinery is depreciated using the straightline method over a useful life of 8 years with a residual value of $80 000....
-
The purchases and sales of Big Flower Pty Ltd of one brand of lawn fertiliser for the year ended 31 December 2019 are contained in the schedule below. The selling price up to 30 June was $12 per unit...
-
In groups of four or five, consider the following information. On 1 July 2019, Stevenson Pty Ltd, a proprietary company with three shareholders, acquired some property by issuing 100 000 shares to...
Study smarter with the SolutionInn App