Examination Cover Page Examination Period: 2021 HE Term 1 Academic Institution: Central Queensland University Academic Group: Higher Education Division Academic Career: Postgraduate Examination Type:...

1 answer below »
1) Need answers to T1-2021 Paper and T2-2021 paper
2) Assessment 3 need with report











Examination Cover Page Examination Period: 2021 HE Term 1 Academic Institution: Central Queensland University Academic Group: Higher Education Division Academic Career: Postgraduate Examination Type: 2021 HE Term 1 Standard Affix Student ID Sticker here I have read and understood the penalties involved if I do not abide by the rules outlined on the back of this examination paper. Student Signature: _______________________________________ Student ID Number: Unit: Data Structures and Algorithms Subject Area: COIT Catalog Number: 20256 Paper Number: 1 Component: ALL Components Duration 180 minutes Exam Conditions Open Book Perusal Time 15 minutes First Contact Jacqueline Jarvis Contact Number (07) 3023 4238 Second Contact Colin Lemmon Contact Number (07) 4037 5146 Office Use: Release examination paper via the CQ University Past Exams website two weeks after the DE/SE examination period? Yes Instructor Authorised/Allowed Materials Calculator - non-programmable, no text retrieval, silent only Dictionary - non-electronic, concise, direct translation only (dictionary must not contain any notes or comments). Student Calculator - Make:____________________ / Model: ____________________ Special Instructions to Students: Please see instruction sheet on first page of the examination paper. Examination Office Supplied Materials 1 x Rough Paper 1 x Exam Answer Booklet Questions Answered Marks Questions Answered Marks Number of examination answer booklets used: Number of separate sheets attached (Do not include rough paper): This examination paper is not to be released to the student at the conclusion of the examination. Central Queensland University considers improper conduct in examinations to be a serious offence. Penalties for cheating are exclusion from the University and cancellation with academic penalty from the unit concerned. Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 1 of 15 INSTRUCTION SHEET 1. Write all answers in the answer booklet provided. 2. Attempt all ten questions. Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 2 of 15 TOTAL 50 MARKS Attempt all 10 questions in the answer booklet provided. Question 1 4 Marks Describe the purpose of the singleton pattern. Explain what is required to implement the singleton pattern in Java (and why). Question 2 4 Marks A common task in computer-based wargaming is to specify the locations that an aircraft must fly to when conducting a surveillance mission. These locations are called waypoints. (a) What would be a suitable data structure to represent this information? Assume that a waypoint is specified by x, y and z coordinates. (2 marks) (b) Explain why you have chosen this data structure over other alternatives. (2 marks) Question 3 4 Marks (a) Explain how hash tables work in terms of hash functions and collisions. (3 marks) (b) What would be the consequences if the key for an entry in a hash table was changed? Explain your answer. (1 mark) Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 3 of 15 Question 4 6 Marks The following Queue class uses the generic List class developed in chapter 21 of the textbook – see Appendix A of this exam for the code from the textbook. public class Queue { private final List< e=""> q;//see Fig 21.3 for List public Queue(){ q = new List<>("queue"); } public void enqueue(E object) { q.insertAtBack(object); } public E dequeue(){ return q.removeFromFront(); } public boolean isEmpty(){ return q.isEmpty(); } } public class GenericFIFOQueue { public static void main(String[] args) { Queue queue = new Queue<>(); queue.enqueue(20); queue.enqueue(10); queue.enqueue(15); while (!queue.isEmpty()){ int item = queue.dequeue(); System.out.printf("%d%n", item); } } } Question 4 continued over the page Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 4 of 15 Question 4 continued (a) What is output by this code? Explain your answer. (1 mark) (b) The data added to the queue is of type int, but the queue is of type Integer. What conversion happens when the int data is added to the queue (using enqueue)? (1 mark) (c) Where else in the code do you see such mixing of types and what happens in that case? (1 mark) (d) Suppose that instead of a queue of numbers you want a queue of Customer records (the class diagram for the Customer class is provided below). Rewrite the main method above to use the Queue class to build a queue with 3 Customer records, then “dequeue” and print the customer records as they come off the queue. (3 marks) Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 5 of 15 Question 5 8 Marks (a) Given the following code, use lambdas and streams to calculate and display the number of elements in the following array of body mass indexes that are greater than or equal to 25 (i.e. the total number that are overweight or obese). (2 marks) public static void main(String[] args) { int[] bmis = {10, 20, 35, 27, 16, 29, 33, 21, 22, 25}; //use lambdas and streams to work out how many //bmis are >= 25 and display the result. // } Output should be similar to the following: The number of patients with a body mass greater than or equal to 25 = 5 (b) The following is the class diagram for the PatientBMI class used in this question. Question 5 continued over the page Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 6 of 15 Question 5 continued Given the code below, use lambdas and streams to complete the main method as follows: i. Write a Predicate called unhealthyWeight that returns true if the patient’s bmi is in the unhealthy weight range (>=25 or < =18)="" and="" false="" if="" the="" bmi="" is="" in="" the="" healthy="" weight="" range.="" (2="" marks)="" ii.="" make="" use="" of="" the="" predicate="" from="" part="" (a)="" to="" display="" all="" the="" patient="" records="" (patient="" id="" and="" bmi)="" with="" body="" mass="" indexes="" that="" are="" not="" in="" the="" healthy="" weight="" range.="" (2="" marks)="" iii.="" use="" lambdas="" and="" streams="" to="" calculate="" and="" display="" the="" summary="" statistics="" for="" the="" data="" (i.e.="" a="" count="" of="" the="" data="" elements,="" sum="" of="" the="" data="" elements,="" minimum,="" average="" and="" maximum).="" (2="" marks)="" public="" static="" void="" main(string[]="" args)="" {="" patientbmi[]="" bmis="{new" patientbmi("p123345",="" 10),="" new="" patientbmi("p678901",="" 20),="" new="" patientbmi("p778901",="" 35),="" new="" patientbmi("p878901",="" 27),="" new="" patientbmi("p078901",="" 16),="" new="" patientbmi("p688901",="" 29),="" new="" patientbmi("p698901",="" 33),="" new="" patientbmi("p679901",="" 21),="" new="" patientbmi("p678911",="" 22),="" new="" patientbmi("p678912",="" 25)};=""> bmiList = Arrays.asList(bmis); //(i) Write the code for the supplementary predicate // // (ii) using the predicate (and lambdas and streams), // display the student id and mark for all results in // the supplementary range // // (iii) using lambdas and streams calculate and display // the summary statistics (count of patients, total/sum of the data, // average and maximum // } Question 5 continued over the page Term 1 Standard Examination 2021 Data Structures and Algorithms – COIT20256 Page 7 of
Answered 10 days AfterSep 01, 2022

Answer To: Examination Cover Page Examination Period: 2021 HE Term 1 Academic Institution: Central Queensland...

Manikandan answered on Sep 05 2022
69 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here