Home > Common Problem > body text

What are exchange sortings?

藏色散人
Release: 2020-06-30 09:35:17
Original
4649 people have browsed it

Exchange sorting includes bubble sorting and quick sorting. Bubble sorting is a simpler sorting algorithm in the field of computer science. The time complexity is "O(N2)", while quick sorting is An improvement on bubble sorting, the time complexity is "O(Nlog2N)".

What are exchange sortings?

Exchange sort

  • Bubble sort

Bubble Sort is a relatively simple sorting algorithm in the field of computer science.

When sorting a sequence to be sorted with N elements, a total of N-1 loops are performed. In the k-th loop, the elements from the 1st to the N-kth are compared from front to back, and the two adjacent elements are compared each time. If the former element is greater than the latter element, the two exchange positions, otherwise they remain Position unchanged

Time complexity:O(N2)

  • Quick sort

Quick Sorting (Quicksort) is an improvement on bubble sort.

Divide the unsorted elements into two subsequences based on a "pivot" as a benchmark. The records of one subsequence are greater than the pivot, while the records of the other subsequence are smaller than the pivot, and then recursively These two subsequences are sorted in a similar way

Time complexity:O(Nlog2N)

The above is the detailed content of What are exchange sortings?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template