From f0e8c99a5a4bed3420e91487baea21a358edcdf0 Mon Sep 17 00:00:00 2001 From: Deta Open Source <2080315360@qq.com> Date: Sun, 28 Jun 2020 14:48:50 +0800 Subject: [PATCH] Create LYG6DWithDoubleQuickSort4D --- LYG6DWithDoubleQuickSort4D | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 LYG6DWithDoubleQuickSort4D diff --git a/LYG6DWithDoubleQuickSort4D b/LYG6DWithDoubleQuickSort4D new file mode 100644 index 0000000..60e25ec --- /dev/null +++ b/LYG6DWithDoubleQuickSort4D @@ -0,0 +1,58 @@ +package org.tinos.deta.statistic; +//基于算法导论快排4衍生极速小高峰缺陷过滤理论快速排序第6代 线性数字数组排序法函数Java完整版本实现。 +//思想:算法导论快排4理论,罗瑶光小高峰过滤理论,增加 催化波动算子duplication 思想。 +//实现:罗瑶光 +//时间:20140101~ 20200628 +public class LYG6DWithDoubleQuickSort4D{ + int range; + int deeps; + public double[] sort(double[] array, int range, int deeps) { + this.range= range; + this.deeps= deeps; + processDouble(array, 0, array.length- 1, 0); + return array; + } + + private void processDouble(double[] array, int leftPoint, int rightPoint, int deep) { + if(leftPoint< rightPoint){ + int c= rightPoint- leftPoint; + if(!(c> this.range|| deep> this.deeps)) {//增加了deep + int j; + for(int i= 1+ leftPoint; i<= leftPoint+ c; i++){ + j= i; + while(j>= 1+ leftPoint){ + if(array[j]< array[j- 1]){ + double temp= array[j]; + array[j]= array[j- 1]; + array[j- 1]= temp; + } + j--; + } + } + return; + } + int pos= partition(array, leftPoint, rightPoint); + processDouble(array, leftPoint, pos- 1, deep+ 1); + processDouble(array, pos+ 1, rightPoint, deep+ 1); + } + } + + private int partition(double[] array, int leftPoint, int rightPoint) { + double x= array[leftPoint]< array[rightPoint]? array[leftPoint]: array[rightPoint]; + int leftPointReflection= leftPoint; + while(leftPointReflection< rightPoint){ + while(!(array[leftPointReflection++]> x|| leftPointReflection> rightPoint)) { + } + while(array[rightPoint--]> x){ + } + if(--leftPointReflection< ++rightPoint){ + double temp= array[rightPoint]; + array[rightPoint]= array[leftPointReflection]; + array[leftPointReflection]= temp; + } + } + array[leftPoint]= array[rightPoint]; + array[rightPoint]= x; + return rightPoint; + } +}