Hey all,
I'm in a Java data structures class in college and I have a problem with this one sorting assignment. I'm not very experienced in java and have tried tackling this assignment in an assortment of ways but have failed miserably. Basically, here is the assignment:::
=============== =============== =============== ===========
"If you look in http://csis.pace.edu/~bergin/temp/circles.zip , you will find a file containing, among other things, a file named circles.arrayli st. This file was created by writing an ArrayList of circle objects on an object output stream. It contains 5000 circle objects. The circle class and the main that created the circles file is also included in the zip. The data is random.
You will need to include the trials.Circle class in your project. in particular, the package must be trials and you should not modify the circle class.
Your job is to:
(a) Sort the circles by radius, smallest first
(b) Sort the circles by the red component of their color, largest first, and for those with the same red component by the blue (largest first) and if the red and blue is the same, then by green (largest first). This requires three sorts, the last two of which need to be stable. First sort by green, then blue (stable) and finally by red( stable). Note that merge sort is fast and stable. Quick sort is fast, but not stable.
Also build an adequete JUnit test to show that you have indeed sorted them as required.
=============== =============== =============== ============
Im really not to sure how to go about solving this. Im not asking you guys to solve this for me, but if someone could give me a push in the right direction and tell me what to do, I would appreciate it. Please keep in mind that Im an amateur programmer, and some things you guys will probably suggest might be out of my skill range, so a slight explanation wouldnt hurt :)
Thanks in advance.
I'm in a Java data structures class in college and I have a problem with this one sorting assignment. I'm not very experienced in java and have tried tackling this assignment in an assortment of ways but have failed miserably. Basically, here is the assignment:::
=============== =============== =============== ===========
"If you look in http://csis.pace.edu/~bergin/temp/circles.zip , you will find a file containing, among other things, a file named circles.arrayli st. This file was created by writing an ArrayList of circle objects on an object output stream. It contains 5000 circle objects. The circle class and the main that created the circles file is also included in the zip. The data is random.
You will need to include the trials.Circle class in your project. in particular, the package must be trials and you should not modify the circle class.
Your job is to:
(a) Sort the circles by radius, smallest first
(b) Sort the circles by the red component of their color, largest first, and for those with the same red component by the blue (largest first) and if the red and blue is the same, then by green (largest first). This requires three sorts, the last two of which need to be stable. First sort by green, then blue (stable) and finally by red( stable). Note that merge sort is fast and stable. Quick sort is fast, but not stable.
Also build an adequete JUnit test to show that you have indeed sorted them as required.
=============== =============== =============== ============
Im really not to sure how to go about solving this. Im not asking you guys to solve this for me, but if someone could give me a push in the right direction and tell me what to do, I would appreciate it. Please keep in mind that Im an amateur programmer, and some things you guys will probably suggest might be out of my skill range, so a slight explanation wouldnt hurt :)
Thanks in advance.
Comment