Introduce something about C++ Classic Algorithm Implementation

# C++ Classic Algorithm Implementation

This article was original written by Jin Tian, welcome re-post, but please keep this copyright info, thanks, any question could be asked via wechat: jintianiloveu

## Preface

this series is the many implementation of C++ classic algorithm, such as quick sort, binary search, Red-black tree. Let’s start the fucking jurney of algorithm!

## Algorithm 1. 快速排序

ok, this the simplest but classic algorithm, we were given a vector, then we send it into a quick_sort function, you should return a vector with sorted seqeunces. Here is the thoughts:

1. 首先随机拿出一个元素作为基准，比如v(通常会选取最左边的元素)，然后进行一下partition操作，该操作需要两个指针i, j，一个指向开头一个指向结尾，每次i++, j–,每次对比左边指针指向的数比v大就继续，遇到比v小的就调换i和j所指向的元素；
2. 经过一次partition操作之后，应该在基准值左边的都是大于它的，右边的都是小于它的；
3. 对左右两段在分别重复1，2，直到每段元素的个数为1为止；