C language insertion sort implementation source code and demo animation

C language  insertion sort implementation source code and demo animation

void insertion_sort(int arr[], int len){
    int i, j, tmp;
    for (i = 1; i< len; i++){
            tmp = arr[i];
            for (j = i; j > 0 && arr[j-1] > tmp; j--) {
                arr[j] = arr[j-1];
            }
            arr[j] = tmp;
        }
    }
}

Demo animation



Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example