分而治之方法还可以用于实现另一种完全不同的排序方法,这种排序法称为快速排序(quick sort)。在这种方法中, n 个元素被分成三段(组):左段l e f...
代码说明:
分而治之方法还可以用于实现另一种完全不同的排序方法,这种排序法称为快速排序(quick sort)。在这种方法中, n 个元素被分成三段(组):左段l e f t,右段r i g h t和中段m i d d l e。中段仅包含一个元素。左段中各元素都小于等于中段元素,右段中各元素都大于等于中段元素。因此l e f t和r i g h t中的元素可以独立排序,并且不必对l e f t和r i g h t的排序结果进行合并。m i d d l e中的元素被称为支点( p i v o t )。图1 4 - 9中给出了快速排序的伪代码,,Delphi 赫夫曼编码.rar.rar - 用delhi做的程序实现了哈夫曼编码,做的还不错。,,Delphi -divide and rule method can be used to achieve an entirely different sort of way This sorting called Quick Sort (quick sort). In this approach, n elements is divided into three (group) : Left of the l e f t, Right of g h i r t and middle m i d e d l. Middle contains only one element. Left of the elements are less than equal to the middle element of the right elements are larger than the middle element. So l and f t e r t h i g of elemental independent sort, and no need to l and f t e r t h i g ranking results merger. M i d e d l The element known as Fulcrum (p i v o t). Figure 1 4-9 is given a quick sort of pseudo-code. Delphi Hefuman coding. rar.rar- delhi do wi
下载说明:请别用迅雷下载,失败请重下,重下不扣分!