Question
PLEASE HELP IN JAVA: Write a recursive version of Selection Sort, and compare the time it takes with the non-recursive version. Use words.txt as your
PLEASE HELP IN JAVA:
Write a recursive version of Selection Sort, and compare the time it takes with the non-recursive version. Use words.txt as your input file and input the data into two arrays so you can use one array with each sort.
THINK ABOUT WHY I ASKED YOU TO USE TWO ARRAYS. THIS IS A HINT TO HELP YOU CREATE A WELL DESIGNED AND EFFICIENT ALGORITHM
IF you used one array and sorted it you could store the time somewhere. You could then go back to the top of your input file and get all the data from the input file a second time and do a second sort. You have only used one array, but you have collected the data from the data file TWICE. I/O takes a lot more time than processing time, so you have just eaten up a lot of time and overhead collecting your data twice.
If you collect your data ONCE and then load two arrays with the same string each time you will have two identical arrays. Yes, you will be using twice the storage, but your transmission time (in getting the input) will be halved.
Insert a timer so we can see how long each sort takes. When you submit the assignment, in the comments state how long your non-recursive method took, how long the recursive one took, and whether one was clearly better than the other.
This assignment really only requires you to alter a few lines of code in the non-recursive selection sort. However, it tests your ability to think recursively, which is what will be required in the following chapters. So start thinking about it early, don't give up, and get your 'recursive' hat on!!
You will need to know how to use a timer.
WORDS.TXT:
noncollectable
reallocation
drenching
obnoxious
venality
dybbuk
shotgun
changelessly
handiwork
unheralded
dovecote
anode
spellbind
psychologist
improvisational
.......
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started