Interview Topic Collection--Sorting algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.