Home > Common Problem > body text

Is the basic idea of ​​bubble sorting to compare adjacent data items in a sequence?

藏色散人
Release: 2020-05-12 09:38:07
Original
5900 people have browsed it

Is the basic idea of ​​bubble sorting to compare adjacent data items in a sequence?

Is the basic idea of ​​bubble sorting to compare adjacent data items in a sequence?

The basic idea of ​​bubble sorting is to compare adjacent data items in the sequence, exchange them if there is a reverse order, and repeat until they are in order.

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

It repeatedly visits the column of elements to be sorted, compares two adjacent elements in turn, and swaps them if the order (such as from large to small, first letter from Z to A) is wrong. The work of visiting elements is repeated until no adjacent elements need to be exchanged, which means that the element column has been sorted.

The name of this algorithm comes from the fact that smaller elements will slowly "float" to the top of the sequence through exchange (in ascending or descending order), just like the carbon dioxide bubbles in carbonated drinks will eventually float to the top. , hence the name "bubble sort".

The above is the detailed content of Is the basic idea of ​​bubble sorting to compare adjacent data items in a sequence?. 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