【发布时间】:2016-09-09 07:54:45
【问题描述】:
以下 OZ 程序使用内置的分区函数来执行快速排序算法。需要使用原有的分区方案而不是内置的分区函数来修改程序。 我搜索并找到了2个原始方案:Lomuto分区方案和Hoare分区方案,但我无法修改程序(我是OZ语言的新手)!所需的两种分区方案在 Wikipedia 中的以下链接中进行了说明:https://en.wikipedia.org/wiki/Quicksort
我正在尝试修改的 OZ 程序:
声明 有趣的{QuickSort Xs} 情况 Xs 为 nil 然后 nil [] 枢轴|Xr 然后 有趣 {IsSmaller X} X
【问题讨论】:
-
declare fun {QuickSort Xs} case Xs of nil then nil [] Pivot|Xr then fun {IsSmaller X} X