Tag：Sorting algorithm

Time：202136
The content of this article will be updated according to the needs of bloggers. I hope you will pay more attention to it. Direct insertion sort void InsertSort(int r[]) { int n = sizeof(r) / sizeof(r[0]); for(int i = 1; i < n; ++i) { for(int j = i – 1; j >= 0; –j) […]

Time：2020412
The example of this paper shares the specific code of insertion sorting of C + + sorting algorithm for your reference. The specific content is as follows 1. Basic ideas:The unsorted data elements are inserted into the sorted data sequence in order of size. For unsorted data, scan the sorted data sequence from the back […]

Time：2020127
Preface Sorting, for each programming language is to face. Here I’d like to share with you some sorting algorithms implemented by golang and show you how to generate random numbers. Let’s have a look at the detailed introduction. Classical sorting algorithm Algorithm learning is very important. It is an important standard to test the level […]

Time：2019926
Introduction of Sorting Algorithms Sort Algorithms, also known as Sort Algorithms, sort will beA set of data ， In the specified orderConductThe Process of Arrangement 。 Classification of sorting 1) Internal sortingAll data to be processed is loaded intoInternal memory (memory)Sort. 2) External Sorting Method:The amount of data is too large to be loaded into […]

Time：2019824
Time complexity: _(n ^ 2) Bubble sort Copy codeThe code is as follows: def bubble_sort(a) (a.size2).downto(0) do i (0..i).each do j a[j], a[j+1] = a[j+1], a[j] if a[j] > a[j+1] end end return a end Selection sort Copy codeThe code is as follows: def selection_sort(a) b = [] […]

Time：2019413
Algorithmic principles: Compare adjacent elements. If the first one is bigger than the second one, exchange the two.Do the same work for each pair of adjacent elements, from the first pair at the beginning to the last pair at the end. At this point, the last element should be the largest number.Repeat the above steps […]

Time：201945
Basics Insert a record into a sorted table to get an ordered table with one record added. And the most critical point is that it moves all records larger than the current element backwards to empty the place where “oneself” should be inserted. When n1 inserts are completed, the record is an ordered sequence. def […]