什么应该学生教首当第一次学习排序算法?算法、学生

2023-09-12 21:18:48 作者:犯二的小痞子°

如果你是一个编程师,你必须选择一个排序算法教你的学生哪一个会是谁?我要求只有一个,因为我只是想引入的排序的概念。它应该是冒泡排序或选择排序?我注意到,这两个是教授最常见。是否有另一种排序的类型,将解释在排序更容易理解的方式?

If you were a programming teacher and you had to choose one sorting algorithm to teach your students which one would it be? I am asking for only one because I just want to introduce the concept of sorting. Should it be the bubble sort or the selection sort? I have noticed that these two are taught most often. Is there another type of sort that will explain sorting in an easier to understand way?

推荐答案

我不知道我可能是计算机科学老师,只教一个分类算法。

I'm not sure I could be a computer science teacher and only teach one sorting algorithm.

在最低限度,学生应学会至少每个主要排序类型的,即一个交换排序,选择排序,插入排序和合并排序。除了这些类型中的一种,我也将涵盖快速排序落在下的分区排序标题。

At a bare minimum the students should be taught at least one of each of the major sorting types, namely an exchanging sort, a selection sort, an insertion sort, and a merge sort. In addition to one of each of these types, I would also cover Quicksort which falls under the partitioning sort heading.

至于具体的种类从各类型的我将涵盖:

As for the specific sorts from each of the types that I would cover:

冒泡排序的作为交换排序类别的一个例子,因为它是最简单的那种类型之一和一个它们可能已经看到或偶然发现了自己。这也是排序,他们将最有可能使用最频繁,如果他们要推出自己的东西简单,所以它是有道理的,他们理解它。 堆排序从选择排序类别。这很可能是最令人困惑的排序旁边的快速排序,但一旦他们了解如何设置它们对于理解快速排序算法。 插入排序作为插入排序类的一个实例将被覆盖,因为它也是一个简单的排序,他们可以得到大量的使用出来。因为他们可能会遇到的情况,他们需要合并两个列表一起,知道这其中是有道理的。 合并排序是有点的专业排序,所以你看不到它过于频繁,但它是非常好的它做什么,仍然是在你需要你得到的零碎的数据进行排序的情况下非常有用。 Bubble Sort as an example of the exchanging sort category as it is one of the simplest sort types and one that they likely have already seen or stumbled across on their own. This is also the sort they will most likely use the most often if they have to roll their own for something simple so it makes sense for them to understand it. Heapsort from the selection sort category. This would likely be the most confusing sort next to Quicksort but once they understand how it sets them up for understanding the Quicksort algorithm. Insertion Sort as an example of the insertion sort category would be covered as it is also a simple sort that they can get a lot of use out of. Since they might encounter scenarios where they need to merge two lists together, knowing this one makes sense. Merge Sort is somewhat of a specialized sort so you don't see it too often, but it is very good at what it does and is still useful in situations where you need to sort data that you are getting in a piecemeal fashion.

如果我不得不缩小范围到只有一个那种我可以教,但我有时间,以确保学生理解究竟发生了什么事情,然后我会教快速排序。虽然这是不容易把握,绝大多数的框架在那里将其用于自己的排序算法,以便它是如何工作的认识是在你的开发与框架有益的。此外,它很可能是,如果有人能够了解快速排序然后他们应该能够学习自己的冒泡排序和插入排序。

If I had to narrow things down to just one sort that I could teach, but I had the time to make sure that the student understood exactly what was going on then I would teach Quicksort. While it is not easy to grasp, the vast majority of frameworks out there use it for their sorting algorithm so an understanding of how it works is useful in your development with that framework. Also, it is quite likely that if someone is able to understand Quicksort then they should be able to learn the Bubble Sort and Insertion Sort on their own.