圆形排序帮助!! [英] Circle Sorting Help!!

查看:84
本文介绍了圆形排序帮助!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,


我在大学的Java数据结构课程中,我对这一个排序任务有疑问。我在java方面不是很有经验,并且已经尝试过各种各样的方法解决这个问题但却失败了。基本上,这里是作业:::


============================= ===================== ======

"如果你查看http://csis.pace.edu /~bergin/temp/circles.zip,你会发现一个文件,其中包含一个名为circles.arraylist的文件。此文件是通过在对象输出流上写入圆形对象的ArrayList来创建的。它包含5000个圆形对象。创建圆圈文件的圆圈类和主要内容也包含在zip中。数据是随机的。


您需要在项目中包含trials.Circle类。特别是,包装必须是试用,你不应该修改圆圈类。


你的工作是:

(a)按半径对圆圈排序,最小的第一个

(b)按照颜色的红色分量排序圆圈,最大的是第一个,对于那些具有相同红色分量的蓝色(最大的第一个),如果红色和蓝色是同样的,然后是绿色(最大的第一个)。这需要三种,其中最后两种需要稳定。首先是绿色,然后是蓝色(稳定),最后是红色(稳定)。请注意,合并排序快速而稳定。快速排序很快,但不稳定。


同时构建一个充满优雅的JUnit测试,以表明您确实已根据需要对它们进行了排序。

============= ===================================== =======



我真的不确定如何解决这个问题。我不是要求你们为我解决这个问题,但如果有人能给我一个正确的方向并告诉我该怎么做,我将不胜感激。请记住,我是一个业余程序员,你们可能会建议的一些事情可能超出我的技能范围,所以一个轻微的解释不会伤害:)


提前谢谢。

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.arraylist. 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.

推荐答案

你是否学会了如何编写排序方法并让它们起作用?
Have you learned how to write sorting methods and get them to work?


我对它们并不完美但我想我可以把它拉下来。你有什么建议?
I''m not perfect with them but I think I can pull it off. What do you suggest?


那么你的程序基本上是自己编写的。你有一个文件,其中包含有关许多Circles的信息 - 创建一个方法将它们读入一个数组/ ArrayList / whatever并返回该列表/数组。然后创建一个方法,按半径大小对它们进行排序。然后制作一个方法按颜色对它们进行排序(根据你的问题,将结合几种方法)。然后制作一个方法来打印数组/列表中的圆圈。


来吧试一试,告诉我们你到达的地方。
Well, then your program basically writes itself. You have a file that contains information about however many Circles - make a method to read them into an array/ArrayList/whatever and return that list/array. Then make a method to sort them by radius size. Then make a method to sort them by color (which, according to your problem, will be several methods combined). Then make a method to print out the circles in the array/list.

Go ahead and give it a try and let us know where you get.


这篇关于圆形排序帮助!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆