• 数据结构之shell排序


     #SIZE  10
           //直接插入排序 
       void insert_sort(){
              int i,j;
              int array[SIZE+1];
              array[]={0,12,23,11,55,2,34,18,20,48,22};
              for(i=2;i<=SIZE;i++){
                  array[0]=array[i];
                  j=i-1;
                  while(array[0]<array[j]){
                         array[j+1]=array[j];
                         j--;
                   }
                  array[j+1]=array[0];
                 }
          }
          //折半插入排序
        void insert_binary_sort(){
                   int j,i,low,hight,m;
                   int array[SIZE+1];
                 for(i=2;i<=SIZE;i++){
                     array[0]=array[i];
                     hight=i-1;
                     low=1; 
                    while(low<=hight)
                         {
                            m=(low+hight)/2;
                            if(array[0]<array[m])
                                 hight=m-1;
                            else low=m+1;
                          }
                     for(j=i;j>hight+1;j--)
                        {
                              array[j]=array[j-1];
                        }
                        array[hight+1]=array[0];
                   }
                  
        }
                
            //shell排序,在直接插入排序上进行优化而来
             void shell_sort(){
                 int d,n,j,i;
                 int array[SIZE+1];
                 int d=n;
                 do{
                     d=d/2;
                     for(i=d+1;i<=SIZE;i++)
                       {
                          array[0]=array[i];
                          for(j=i-d;j>0&&array[j]>array[0];j-=d){
                                array[j+d]=array[j];
                              }
                              array[j+d]=array[0];
                        }
                 }while(d!=1);
             }
  • 相关阅读:
    ES monitoring
    my stackoverflow
    ES 监控
    Natural Language Processing 课程,文章,论文
    搜索引擎名著
    https://medium.com/netflix-techblog/linux-performance-analysis-in-60-000-milliseconds-accc10403c55
    MySQL 性能跟踪方法
    JAVA CAS原理深度分析 volatile,偏向锁,轻量级锁
    spark-architecture-shuffle
    Linux performance commands and tool
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/6783349.html
Copyright © 2020-2023  润新知