In the interview process, will inevitably ask some of the more basic issues, and these basic questions must be said to sort up.
We know that the sorting algorithm consists of inserting, selecting, bubbling, fast, merging, stacking, and so on, most of the time, when we interview, the most frequently asked sort algorithm is heap, quick and merge sort, other several relatively simple, ask less, then, We just have to figure it out before the interview and write it on paper. In writing these algorithms, I looked at a lot of information, but also read a lot of articles, after all, the sorting algorithm is very classic, so, the time spent on this is quite a lot. However, I found that some sort algorithm implementation is very complex, and difficult to understand, so I sort out and write down these commonly used sorting algorithms, personal feeling is relatively easy to understand.
Of course, I also put the implementation of the algorithm upload to this page, you can download (free points):
http://download.csdn.net/detail/dlutbrucezhang/8071405
here, I just paste out the implementation code of the header file, easy to see here are the implementation of the sorting algorithm:
#ifndef sort_algorithm_h#define sort_algorithm_h/* swap function */void swap (int &a, int &b);/* Bubble sort */void bubblesort (int * array, int n);/* Quick sort */int partition (int* array, int low, int.); void QuickSort (int* array, int low, int. high);/* Select sort * /void selectsort (int* array, int n);/* Heap sort */void createheap (int* array, int n); void Adjustheap (int* array, int i, int n); Vo ID heapsort (int* array, int n);/* Insert sort */void insertsort (int* array, int n);/* Merge sort */void mergearray (int* array, int first, I NT Mid, int last, int* temp), void MergeOrder (int* array, int first, int. last, int* temp), void MergeSort (int* array, int n) ;/* Hill sort */void shellinsert (int* array, int d, int n); void Shellsort (int* array, int n); #endif//! Sort_algorithm_h
Interview Topic Collection--Sorting algorithm