当前位置: 首页 > news >正文

做网站充值系统seo技术是干什么的

做网站充值系统,seo技术是干什么的,农村自建房设计网站,怎么建立一个自己的网站【算法解释】 快速排序的核心思想是:(这里排序是从小到大----从大到小也是类似的) 找出一个pivot(关键点),然后以关键点为标准,对数组各个位置进行比较,让关键点左边的数字都少于或…

【算法解释】

快速排序的核心思想是:(这里排序是从小到大----从大到小也是类似的)

找出一个pivot(关键点),然后以关键点为标准,对数组各个位置进行比较,让关键点左边的数字都少于或等于关键点,关键点右边的都大于或等于关键点,

然后划分成为两半---关键点左边(不包含关键点)数组及关键点右边(不包含关键点),递归应用划分两半的过程,到了数组个数为1或2的时候就结束。

这个过程就是快速排序。

【下面对相关过程进行说明】



譬如:

一个数组:

[java] view plaincopy
  1. 4  7  15  9  6  8  5  7  6  1  11  3  10    

我们按照数组index=7的元素即【7】来划分左右两边的数组,左边数组小于7,右边数组大于7,然后可以得到:

每次交换后的结果:

[java] view plaincopy
  1. 交换结果:4   6   15   9   7   8   5   7   6   1   11   3   10     
  2. 交换结果:4   6   5   9   7   8   15   7   6   1   11   3   10     
  3. 交换结果:4   6   5   6   7   8   15   7   9   1   11   3   10     
  4. 交换结果:4   6   5   6   1   8   15   7   9   7   11   3   10     
  5. 交换结果:4   6   5   6   1   3   15   7   9   7   11   8   10     
  6. 当前循环结果:  
  7. 4   6   5   6   1   3   7   15   9   7   11   8   10     

那么下面将数组分成两部分再来排序,分别为:

3---6及7到最后,如此递归,

详情可以看

JULY的快速排序算法解释。


下面我将自己写写改改的程序拿出来,见笑了,顺便贴出整个交换过程:

[java] view plaincopy
  1. package TestCase.algorithm;  
  2.   
  3. public class QuickSort {  
  4.     private int _debugLevel=0;  
  5.   
  6.     public static void main(String[] args){  
  7.     int[] _toBeSorted=new int[]{9,8,7,6,14,15,1,1,1,8,5,7,9,8,5,4,3,2,1};  
  8.         QuickSort _qsort=new QuickSort(_toBeSorted) ;  
  9.         _qsort.doQuickSort();  
  10.         //--  
  11.         //得到结果  
  12.         System.out.println();  
  13.         System.out.println("最后结果=============================");  
  14.         _qsort.debugPrint();  
  15.   
  16.   
  17.     }  
  18.   
  19.     private int[] _originArr;  
  20.     public QuickSort(int[] originArray){  
  21.         _originArr=originArray;  
  22.     }  
  23.   
  24.     public int[] doQuickSort(){  
  25.   
  26.   
  27.         if(_originArr==null||_originArr.length<=0){  
  28.             return _originArr;  
  29.         }  
  30.         //--  
  31.         System.out.println("需要排序的数组:");  
  32.         debugPrint();  
  33.         System.out.println("");  
  34.        doPartion( (int)Math.ceil((double)_originArr.length/2),0,_originArr.length-1);  
  35.   
  36.   
  37.         return _originArr;  
  38.     }  
  39.   
  40.     public void doPartion(int pivotLocation,int leftLocation,int rightLocation){  
  41.   
  42.         int _pivot=_originArr[pivotLocation];  
  43.         if(leftLocation>=rightLocation){  
  44.   
  45.             return;  
  46.         }  
  47.         //--假如是两个参数,直接比较。  
  48.         System.out.println("【主元位置:“"+pivotLocation+"---"+_pivot+"”数组左界:“"+leftLocation+"”,数组右界“"+rightLocation+"”】");  
  49.         if(leftLocation+1==rightLocation){  
  50.             if(_originArr[leftLocation]>_originArr[rightLocation]){  
  51.                 int thetmp1=_originArr[leftLocation] ;  
  52.                 _originArr[rightLocation]=thetmp1;  
  53.                 _originArr[leftLocation]=thetmp1;  
  54.   
  55.                 debugPrint(leftLocation,rightLocation);  
  56.                 return;  
  57.             }  
  58.             return;  
  59.         }  
  60.   
  61.   
  62.         int less_loc=leftLocation;//边界,少于主元的位置  
  63.         int more_loc=-1;//边界,大于主元的位置  
  64.   
  65.         for(int cindex=leftLocation;cindex<=rightLocation;cindex++){  
  66.   
  67.   
  68.   
  69.             if(_originArr[cindex]<_pivot){  
  70.   
  71.   
  72.                 if(more_loc!=-1){  
  73.                     //--交换  
  74.                     int tmp1= _originArr[less_loc];  
  75.                     _originArr[less_loc]=_originArr[cindex] ;  
  76.                     _originArr[cindex]=tmp1;  
  77.                      more_loc=cindex;  
  78.   
  79.   
  80.                     System.out.print("交换结果:");  
  81.                     debugPrint(leftLocation,rightLocation);  
  82.                     System.out.println();  
  83.                 }  
  84.                   less_loc++;  
  85.   
  86.   
  87.   
  88.             }  
  89.             else if(_originArr[cindex]>=_pivot){  
  90.                 more_loc=cindex;  
  91.             }  
  92.   
  93.   
  94.   
  95.   
  96.   
  97.   
  98.   
  99.         }  
  100.   
  101.         //--假如less——loc-1=leftLocation,那么实际上该pivot很不幸,是最小的。  
  102.         if(less_loc==leftLocation){  
  103.             int tmp1=_originArr[leftLocation];  
  104.             _originArr[leftLocation]=_pivot;  
  105.             _originArr[pivotLocation]=tmp1;  
  106.             less_loc=leftLocation+1;  
  107.         }  
  108.         //假如最后的less_loc小于pivot节点,那么需要交换。  
  109.         else if(less_loc<pivotLocation){  
  110.             _originArr[pivotLocation]=_originArr[less_loc];  
  111.             _originArr[less_loc]=_pivot;  
  112.   
  113.         }  
  114.         //--  
  115.         System.out.println("当前循环结果:");  
  116.         debugPrint(leftLocation,rightLocation);  
  117.         System.out.println("");  
  118.   
  119.         if(less_loc>1){  
  120.             //--左边的递归  
  121.             int newRightLocation=less_loc-1;  
  122.               int middlePivotLoc=   (int) Math.ceil((float)(newRightLocation+leftLocation)/2);  
  123.             doPartion(middlePivotLoc,leftLocation,newRightLocation);  
  124.   
  125.         }  
  126.   
  127.         if(less_loc-2<rightLocation){  
  128.             int newLeftLocation=less_loc;  
  129.            int newMPivotLoc=(int)Math.ceil((float)(newLeftLocation+rightLocation)/2);  
  130.             doPartion(newMPivotLoc,newLeftLocation,rightLocation);  
  131.   
  132.   
  133.         }  
  134.   
  135.   
  136.     }  
  137.   
  138.     public void debugPrint(){  
  139.         for (int ii:_originArr){  
  140.             System.out.print(""+ii+"  ");  
  141.         }  
  142.   
  143.     }  
  144.   
  145.     public  void debugPrint(int left,int right){  
  146.         for(int ii=left;ii<=right;ii++){  
  147.             System.out.print(_originArr[ii]+"   ");  
  148.         }  
  149.   
  150.     }  
  151.   
  152. }  
下面是这个程序的运行结果:

[java] view plaincopy
  1. 需要排序的数组:  
  2. 9  8  7  6  14  15  1  1  1  8  5  7  9  8  5  4  3  2  1    
  3. 【主元位置:“10---5”数组左界:“0”,数组右界“18”】  
  4. 交换结果:1   8   7   6   14   15   9   1   1   8   5   7   9   8   5   4   3   2   1     
  5. 交换结果:1   1   7   6   14   15   9   8   1   8   5   7   9   8   5   4   3   2   1     
  6. 交换结果:1   1   1   6   14   15   9   8   7   8   5   7   9   8   5   4   3   2   1     
  7. 交换结果:1   1   1   4   14   15   9   8   7   8   5   7   9   8   5   6   3   2   1     
  8. 交换结果:1   1   1   4   3   15   9   8   7   8   5   7   9   8   5   6   14   2   1     
  9. 交换结果:1   1   1   4   3   2   9   8   7   8   5   7   9   8   5   6   14   15   1     
  10. 交换结果:1   1   1   4   3   2   1   8   7   8   5   7   9   8   5   6   14   15   9     
  11. 当前循环结果:  
  12. 1   1   1   4   3   2   1   5   7   8   8   7   9   8   5   6   14   15   9     
  13. 【主元位置:“3---4”数组左界:“0”,数组右界“6”】  
  14. 交换结果:1   1   1   3   4   2   1     
  15. 交换结果:1   1   1   3   2   4   1     
  16. 交换结果:1   1   1   3   2   1   4     
  17. 当前循环结果:  
  18. 1   1   1   3   2   1   4     
  19. 【主元位置:“3---3”数组左界:“0”,数组右界“5”】  
  20. 交换结果:1   1   1   2   3   1     
  21. 交换结果:1   1   1   2   1   3     
  22. 当前循环结果:  
  23. 1   1   1   2   1   3     
  24. 【主元位置:“2---1”数组左界:“0”,数组右界“4”】  
  25. 当前循环结果:  
  26. 1   1   1   2   1     
  27. 【主元位置:“3---2”数组左界:“1”,数组右界“4”】  
  28. 交换结果:1   1   1   2     
  29. 当前循环结果:  
  30. 1   1   1   2     
  31. 【主元位置:“2---1”数组左界:“1”,数组右界“3”】  
  32. 当前循环结果:  
  33. 1   1   1     
  34. 【主元位置:“3---1”数组左界:“2”,数组右界“3”】  
  35. 【主元位置:“13---8”数组左界:“7”,数组右界“18”】  
  36. 交换结果:5   7   7   8   8   9   8   5   6   14   15   9     
  37. 交换结果:5   7   7   5   8   9   8   8   6   14   15   9     
  38. 交换结果:5   7   7   5   6   9   8   8   8   14   15   9     
  39. 当前循环结果:  
  40. 5   7   7   5   6   8   9   8   8   14   15   9     
  41. 【主元位置:“9---7”数组左界:“7”,数组右界“11”】  
  42. 交换结果:5   5   7   7   6     
  43. 交换结果:5   5   6   7   7     
  44. 当前循环结果:  
  45. 5   5   6   7   7     
  46. 【主元位置:“8---5”数组左界:“7”,数组右界“9”】  
  47. 当前循环结果:  
  48. 5   5   6     
  49. 【主元位置:“9---6”数组左界:“8”,数组右界“9”】  
  50. 【主元位置:“11---7”数组左界:“10”,数组右界“11”】  
  51. 【主元位置:“15---8”数组左界:“12”,数组右界“18”】  
  52. 当前循环结果:  
  53. 8   9   8   8   14   15   9     
  54. 【主元位置:“16---14”数组左界:“13”,数组右界“18”】  
  55. 交换结果:9   8   8   9   15   14     
  56. 当前循环结果:  
  57. 9   8   8   9   15   14     
  58. 【主元位置:“15---8”数组左界:“13”,数组右界“16”】  
  59. 当前循环结果:  
  60. 8   8   9   9     
  61. 【主元位置:“15---9”数组左界:“14”,数组右界“16”】  
  62. 当前循环结果:  
  63. 8   9   9     
  64. 【主元位置:“16---9”数组左界:“15”,数组右界“16”】  
  65. 【主元位置:“18---14”数组左界:“17”,数组右界“18”】  
  66. 15   15     
  67. 最后结果=============================  
  68. 1  1  1  1  2  3  4  5  5  6  7  7  8  8  8  9  9  15  15    

看,虽然完全没有高手的风格,但是还是可以自娱自乐。

http://www.lbrq.cn/news/2388781.html

相关文章:

  • 网站建设运营策划方案百度一下免费下载安装
  • 做loge的网站拉新app推广接单平台
  • 做网站 传视频 用什么笔记本好电商网页
  • 企业网站建设公司注意哪些问题网上接单平台有哪些
  • 无极app定制开发公司网站模板中国十大营销策划公司排名
  • 网站快捷按钮以什么方式做小江seo
  • 外贸网站免费模板百度seo关键词报价
  • 深圳做网站联雅朔州网站seo
  • 工程建设领域专项治理工作网站长沙网络营销哪家平台专业
  • 沙漠风网站开发怎样武汉刚刚发生的新闻
  • 现在做网站到底需要多少钱网站seo检测
  • 信用网站建设成效建网站哪个平台好
  • 科学小制作西安百度快照优化
  • 如何做平台软件seo产品是什么意思
  • 做flash音乐网站的开题报告bing搜索引擎下载
  • 将台地区网站建设腾讯域名
  • 海口网站建设咨询石家庄
  • 做网站霸屏公司销售好做吗seo内容优化是什么
  • 淘客网站怎么做淘口令建站系统哪个比较好
  • 宁津做网站公司今日时事新闻
  • 西宁高端网站制作公司seo的方式有哪些
  • 易讯企业建站系统2022年app拉新推广项目
  • 网站开发课程百度云泉州seo网站排名
  • 网站导航怎么做的济南市新闻最新消息
  • 电子印章在线制作生成器免费seo的内容主要有哪些方面
  • 哈尔滨网站建设代理商网站入口百度
  • 设计公司网站源码网站推广的营销策划方案
  • 西安网站建设网络营销师报名入口
  • 临沂做商城网站友情链接软件
  • 电子商务网站建设与管理的感受东莞网站推广策划
  • 如何实现电脑自动关机与定时任务管理
  • Spring AI 项目实战(十九):Spring Boot + AI + Vue3 + OSS + DashScope 构建多模态视觉理解平台(附完整源码)
  • Word快速文本对齐程序开发经验:从需求分析到实现部署
  • Kubernetes Pod深度理解
  • 2025外卖江湖:巨头争霸,谁主沉浮?
  • FLTK UI窗口关闭时延时卡顿问题全流程分析与优化实战