排序问题,找到最短的排序方式 [英] Sorting problem, finding the shortest way to sort it

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

问题描述





好​​吧,首先,这不是我的功课,根本不是作业,我不想要你们中的任何人为我解决它。我正准备参加一个编程竞赛,有一个我无法解决,我想要一些提示。

所以问题是图书馆里有书,我有把它们整理好。但是我必须找到最好的方法(尽管不是最快的!)来排序它。



所以我有这些数字:

 7,10,1,3,2,8,4,9,6,5 





我有把它们整理好。我试过quicksort,但当然这是最快但不是最好的。冒泡排序也是出来的,它必须做很多步骤。



所以我有一个答案,即7(我必须做的步骤的数量)排序它,但我找不到办法弄清楚怎么做...



(我不知道要写什么标签,所以既然我尝试用C#写它,我就把它放在那里)



谢谢

解决方案

< blockquote>我建​​议看看 C#中排序算法的可视化和比较并尝试使用源代码来比较不同的算法。



我花了几分钟来测试你的数字而且我确信7的限制可以很荣幸。 ;)



问候,

Daniele。


如果这是用于编程比赛,这是与作业相比,作弊也不少。比赛应评估您的实际工作和技能。我们为什么要比竞争对手更多地帮助你?这不好。



毕竟,你和你的竞争对手可以在网上学习现有的技术,那么问题是什么?



如果我是比赛问题的作者,我绝不会像排序那样造成问题。这样,评估了现有技术的一些知识,而不是深入的知识和思考能力。即使它们很难发明,总是可以提出原始问题。不要为比赛提供一些标准问题,最好不要进行任何比赛。



所以,如果你要去参加真正的编程竞赛,已知算法的知识不会真正有用。但是如果你自己找到一些已知的算法,完全独立,它可以大大提高你的技能和获胜的机会。但在这种情况下,如果我们回答你的问题,我们将完全剥夺你的机会。因为我不想抓住这个机会因此伤害了你,我没有回答,抱歉。希望它可以帮到你。 :-)



-SA


Hi,

All right, so first of all, this is not my homework, not a homework at all, I don''t want any of you to solve it for me. I am just preparing for a programming competition, and there is this one I can''t solve, and I would like some hint.
So the problem is that there are books in a library and I have to put them in order. But I have to find the the best way (definetely not the fastest!) to sort it.

So I have these numbers:

7, 10, 1, 3, 2, 8, 4, 9, 6, 5



I have to put them in order. I tried quicksort, but of course thats the fastest but not the best. Bubble sort is out as well, it has to do many steps.

So I have an answer, which is 7 (the count of the steps I have to do to sort it), but I can''t find a way to figure out how to do it...

(I didn''t know what tags to write, so since I try to write it in C# I just put that one there)

Thank you

解决方案

I suggest to take a look at Visualization and comparison of sorting algorithms in C# and experiment with the source code to compare different algorithms.

I took some minutes to test your numbers and I''m confindent that the constraint of 7 could be honored. ;)

Regards,
Daniele.


If this is for programming competition, this is no less of cheating than if it is a homework. The competition should evaluate your real work and skills. Why should we help you more than your competitors? This is no good.

And, after all, you and your competitors can learn existing techniques on the Web, so what''s the problem?

If I was the author of the problems for the competition, I would never pose a problem like sorting. This way, some knowledge of existing technique is evaluated, not in-depth knowledge and the ability to think. It is always possible to put forward an original problem, even though they are quite difficult to invent. Instead of offering some standard problems for a competition, it''s much better not conduct any competitions at all.

So, if you are going for a real programming competition, knowledge of known algorithms won''t really help. But if you find even some known algorithm by yourself, fully independently, it can greatly improve your skills and chances to win. But in this case, if we answer your question, we will fully take away that chance from you. As I don''t want to take out this chance and hence hurt you, I''m not answering, sorry. Hope it can help you. :-)

—SA


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

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