ECCE 342 Assignment Spring 2022
ECCE 342 Assignment Spring 2022
ECCE 342 Assignment Spring 2022
AIM
The aim of this assignment is to build a class (or more) and a driver class to test and
analyze the implementation and performance of various sorting algorithms.
Note: In case of any query please contact first your Lab Instructors.
TASKS
TASK 1. GENERATE DATA. [10 MARKS]
Design and write a Java class that generates data of 2000 books. The data for each book
consists of:
You will need to generate the data for the 2000 books into a text file called books.txt.
The values for all data cannot be repeated, meaning no two identifiers are the same, no
two names or titles are the same, etc. Below is a sample books.txt file.
books.txt
93842 Statistical Decision Theory Pratt,John 350
61275 Slaughterhouse Five Vonnegut,Kurt 1000
…
85938 Making Software Oram,Andy 150
93844 Orientalism Said,Edward 123
Your program must read and store the data of the books in an array of objects. Further,
the method should write the books data into a numbered and neatly formatted text file
called formatted_books.txt, as in the sample below. For good formatting, make
sure to use formatted printing printf().
formatted_books.txt
No. ID Name Title Price
1 93842 Pratt,John Statistical Decision Theory 350
2 61257 Vonnegut,Kurt Slaughterhouse Five 1000
...
1000 93844 Said,Edward Orientalism 123
Use the implemented sorting algorithms on the array of books objects and write the
sorted arrays into the following numbered and neatly formatted files:
Make sure that you maintain the integrity of the data after sorting.
You will need to create 4 arrays of books (number of elements detailed below in the
tables) and apply the sorting algorithms on these unsorted arrays. Then again, you need
to re-apply the sorting algorithms on the sorted arrays.
TABLE 1. SHORT BUBBLE SORT ON UNSORTED ARRAY.
You need to justify the retrieved number of operations in the unsorted case of 200
elements and estimate how these numbers can be calculated. Moreover, correlate the
time the algorithms took with its big-O time complexity.
Finally, investigate whether or not heap sort is a stable algorithm, and describe what
does that mean.
CODE
All submitted code should be properly documented and written in a good
programming style with comments and proper indentation.
You are only allowed to use code from the notes in class or lab with no change of
structure or naming style (no internet code will be accepted).
SUBMISSION
Submit screenshots of the results in the report (output files and console results).
Your report must be a single Word document, containing all code, screenshots of
first and last 10 books for each run. Name your report document as
FIRSTNAME_ID.docx.
Compress the .java files into a FIRSTNAME_ID.zip file and submit the code
along the Word document.
Submission delay will be penalized by 5% points a day with a maximum delay of
5 days. Submissions after that will not be accepted.
WARNINGS
No collaboration between students is allowed and any detection of plagiarism
from each other or from the internet will be penalized with zero mark for all of
those involved and will be reported to the Dean’s office to take further
disciplinary actions.