Data structure-bubble sort (Python&java implementation)

Source: Internet
Author: User
1. Core idea of bubbling algorithm
The core idea of bubble sorting is to scan the data list, find the two contiguous data in the order of 22 compare and swap the location, then continue to scan the data, and then repeat the above operations repeatedly until the end of the sorting.
2. Example
We take the 23,15,58,-4,99,0 of this unordered set of numbers as an example: from small to large,
Initial state: 23,15,58, -4,99,0
First sorted results: 15,23,-4,58,0,99
Second sort result: 15,-4,23,0,58,99
Third Order results: -4,15,0,23,58,99
Fourth time sorted results: -4,0,15,23,58,99
Fifth time sorted results: -4,0,15,23,58,99
Sort finished, output final result: -4,0,15,23,58,99
3. Experiment Code
Python implementation

Python test results:

Java Code and test results

Data structure-bubble sort (Python&java implementation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.