快排分析 ,快排与冒泡排序是相关联的。
template<class T>
bubblesort(T *src,int lne)
{
      
}
前者是通过相邻之间交换的方式来。
而后者是通过一个值得比较来交换的方式。

template <class T>
void quicksort(T *src,int low,int high)
{
    T temp;
    int i = low;
    int k = high;
    if(low >=high) return;
    temp = src[low];

    while(low<high)
    {
        while(low<high&&src[high]>=temp) high--;
        src[low] = src[high];
        while(low<high&&src[low]<=temp) low++;
        src[high] = src[low];
    }
    src[low] = temp;
    quicksort(src,i,low-1);
    quicksort(src,low+1,k);
}


Posted on 2008-06-16 11:40 micheal's tech 阅读(250) 评论(0)  编辑 收藏 引用 所属分类: Algorithm

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理