文件名称:QuickSort
介绍说明--下载内容来自于网络,使用问题请自行百度
快速排序(快速排序)是一种快速排序算法,它被广泛应用于实践。它是用于分而治之的原则。快速排序的工作原理是划分一个给定的数组A [P。 。 R]分成两个非空的子阵列A [页。 。 Q]和A [Q + 1。 。 R]使得在[P每个元素。 。问]是小于或等于每个元素A [Q + 1。 。 R]。然后两个子阵列被递归调用快速排序排序。快速排序的细节描述如下:
1.选择一个支点值(基准)。您可以采取的第一个元素的值
枢轴值,但它可以是任何值,这是在排序的值的范围,即使它不存在于阵列中。
2.分区(划分)。重新排列以这样的方式是比所述枢轴更低所有元素去阵列的左侧部分的元素,并且比枢轴更大所有元素去阵列的右侧部分。值等于枢轴可以留在阵列的任何位置。
3.排序两个子阵列。递归地应用快速排序算法的左侧和所述阵列的右侧部分。编写一个函数模板快速排序下Fig.8.15的排序程序的参考,同时也写输入,排序和输出int数组和一个float数组元素的8潜水员程序-quickSort(快速排序) is a fast sorting algorithm, which is widely applied in practice. It is used on the principle of divide-and-conquer. quickSort works by partitioning a given array A[p . . r] into two non-empty sub-arrays A[p . . q] and A[q+1 . . r] such that every element in A[p . . q] is less than or equal to every element in A[q+1 . . r]. Then the two sub-arrays are sorted by recursive calls to quickSort. The details of quickSort are described as follows:
1. Choose a pivot value(基准). You may take the value of the first element as
pivot value, but it can be any value, which is in range of sorted values, even if it doesn t present in the array.
2. Partition(划分). Rearrange elements in such a way that all elements which are lesser than the pivot go to the left part of the array, and all elements greater than the pivot go to the right part of the array. Values equal to the pivot can stay in any position of the array.
3. Sort both sub-arrays. Apply quicksort algorithm recursively to the
1.选择一个支点值(基准)。您可以采取的第一个元素的值
枢轴值,但它可以是任何值,这是在排序的值的范围,即使它不存在于阵列中。
2.分区(划分)。重新排列以这样的方式是比所述枢轴更低所有元素去阵列的左侧部分的元素,并且比枢轴更大所有元素去阵列的右侧部分。值等于枢轴可以留在阵列的任何位置。
3.排序两个子阵列。递归地应用快速排序算法的左侧和所述阵列的右侧部分。编写一个函数模板快速排序下Fig.8.15的排序程序的参考,同时也写输入,排序和输出int数组和一个float数组元素的8潜水员程序-quickSort(快速排序) is a fast sorting algorithm, which is widely applied in practice. It is used on the principle of divide-and-conquer. quickSort works by partitioning a given array A[p . . r] into two non-empty sub-arrays A[p . . q] and A[q+1 . . r] such that every element in A[p . . q] is less than or equal to every element in A[q+1 . . r]. Then the two sub-arrays are sorted by recursive calls to quickSort. The details of quickSort are described as follows:
1. Choose a pivot value(基准). You may take the value of the first element as
pivot value, but it can be any value, which is in range of sorted values, even if it doesn t present in the array.
2. Partition(划分). Rearrange elements in such a way that all elements which are lesser than the pivot go to the left part of the array, and all elements greater than the pivot go to the right part of the array. Values equal to the pivot can stay in any position of the array.
3. Sort both sub-arrays. Apply quicksort algorithm recursively to the
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Ex1/main.cpp
Ex1/QuickSort.exe
Ex1
Ex1/QuickSort.exe
Ex1
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.