数据结构

来源:互联网 发布:java类的定义格式 编辑:程序博客网 时间:2024/06/01 22:12

一.java常见算法

快速排序

public   void sort(int arr[],int low,int high){
        int l=low;
        int h=high;
        int povit=arr[low];
        while(l<h){
            while(l<h&&arr[h]>povit){
                h--;
            }
            if(l<h){
                int temp=arr[l];
                arr[l]=arr[h];
                arr[h]=temp;
                l++;
            }
            while(l<h&&arr[l]<povit){
                l++;
            }
            if(l<h){
                int tem=arr[l];
                arr[l]=arr[h];
                arr[h]=tem;
                h--;
            }
        }
        if(l>low)
            sort(arr, low, l-1);
        if(h<high)
            sort(arr, l+1, high);
    }

哈希算法


原创粉丝点击