Title Description: Sorts and outputs the n number of inputs.
Problem-solving ideas: In fact, is a very regular sort of problem, but for a review, so the use of fast-line method. Here's a quick sort of code implementation exercise OK.
Fast sorting is a very classic algorithm that allows you to sort a set of numbers in a logarithmic scale.
It is based on the idea of divided treatment, each sequencing divides the original group number into smaller ranges to sort, and there must be a number that will be placed in the final position in each order of the trip.
The process is described in popular language, that is, from the two ends of a group to traverse the middle, while traversing one side of the big on the right side, small put to the left.
Finally, when the Low=high is stuck in the pivot position, the element that begins pivot pivot is plugged back.
Pivot element pivots the last position is its final position, and finally, the hub element as the center of the large group of elements divided into two parts
Recursive call fast function, for the smaller parts continue to sort, divide, and then the smaller grouping of fast, then partition ...
Note: Pivot selection is arbitrary, here to facilitate each selection of the leftmost element as a hub. In fact, each time the selected hub is sorted in a single pass, it is best to divide this set of data from the middle into two parts.
(The elements on the left side of the pivot are not necessarily ordered, but smaller than the pivot element (<=); The elements on the right of the pivot are the same, not necessarily orderly, but larger than pivot elements.) (>=))
For the fast algorithm I started learning is also relatively big head, time is very familiar with. Think of the arithmetic class in junior high school when incredibly still and the teacher said the fast platoon is based on the idea of two points ... I'm so dead.
In the last semester to review the sort of time to deliberately draw a simulation of the little comic, now not around. Wait for the next semester to go back to school and put it here.
#include <stdio.h>void quick_sort (int *a,int l,int h) { if (l
Fast sorting algorithm based on C language