How to write quick sort in C language

The implementation method of quick sort in C language is as follows:

  1. Select the base number: Select a number from the sequence as the base number.

  2. Split the sequence: Reorder the sequence so that all elements smaller than the base number are placed in front of the base number, and all elements larger than the base number are placed after the base number (numbers equal to the base number can go to either side). After this division is completed, repeat steps 1~2 for the two subsequences on the left and right of the reference number until the entire sequence is in order.

The following is the code implemented in C language:

#include<stdio.h>

void quick_sort(int *arr, int left, int right)
{
    int i, j, pivot, temp;
    if (left < right)
    {

Guess you like

Origin blog.csdn.net/weixin_35756892/article/details/129608272