What is Bubble Sort?

Basic idea: Bubble sort, similar to the bubble in water, the larger number sink, the smaller number slowly float up intuitive expression: that is, in the array sort, sort from small to large

Algorithm description

Starting with the first number, compare each of the two adjacent numbers, placing the smaller one on the left and the larger one on the right. Over and over again n times, n is the length of the array minus 1

It doesn’t help to describe too much, just look at the picture

<img src=”https://noxussj.top:3000/21/1.gif”></img>

Code demo

I think this should not be necessary, as long as you know the logic of the algorithm

Sort Resources – Bubble Sort

additional

  • This article is published through multiple platforms of “We Media” and will not be maintained after publication. If you have any objection to the content, you can discuss it in the GitHub below
  • The ongoing maintenance / 500 + face questions before update/notes 】 https://github.com/noxussj/In…
  • [3D city modeling using three. JS (Zhuhai City)] https://3d.noxussj.top/