码迷,mamicode.com
首页 > 编程语言 > 详细

面试题目集锦 -- 排序算法

时间:2017-04-30 12:31:12      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:download   lin   集锦   经典   content   简单   试题   targe   sdn   

      面试过程中。免不了会问一些比較基础的问题,而这些基础的问题肯定要说到排序上去。

      我们知道。排序算法包括插入,选择,冒泡。高速,归并,堆排序等等,大多时候,我们在面试的时候,最常问的排序算法是堆,高速和归并排序,其它的几种相对简单,问的较少。那么,我们仅仅须要在面试前把它们都弄懂然后自己在纸上写出来就能够了。在写这些算法的时候,我查了非常多的资料,也看了非常多文章。毕竟排序算法非常经典。所以,在这上面花的时间还挺多的。只是,我发现有些排序算法的实现偏复杂。并且不好理解,于是。我整理并写下了这些经常使用的排序算法,个人感觉还是比較easy理解的。

      当然。我也把算法的实现上传到了这个页面。大家能够去下载(免积分):

http://download.csdn.net/detail/dlutbrucezhang/8071405

      这里。我仅是贴出实现代码的头文件,方便看到这里有哪些排序算法的实现:

#ifndef SORT_ALGORITHM_H
#define SORT_ALGORITHM_H

/*交换函数*/
void swap(int &a, int &b);

/*冒泡排序*/
void BubbleSort(int* array, int n);

/*高速排序*/
int partition(int* array, int low, int high);
void QuickSort(int* array, int low, int high);

/*选择排序*/
void SelectSort(int* array, int n);

/*堆排序*/
void createHeap(int* array, int n);
void adjustHeap(int* array, int i, int n);
void HeapSort(int* array, int n);

/*插入排序*/
void InsertSort(int* array, int n);

/*归并排序*/
void mergeArray(int* array, int first, int mid, int last, int* temp);
void mergeOrder(int* array, int first, int last, int* temp);
void MergeSort(int* array, int n);

/*希尔排序*/
void shellInsert(int* array, int d, int n);
void ShellSort(int* array, int n);

#endif // !SORT_ALGORITHM_H


面试题目集锦 -- 排序算法

标签:download   lin   集锦   经典   content   简单   试题   targe   sdn   

原文地址:http://www.cnblogs.com/wgwyanfs/p/6788911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!