Bubbling algorithm, sparse array

Bubble sort algorithm

Two-layer loop, bubbling on the outer layer

Algorithm details

  1. Compare two adjacent elements in the array, if the former is greater than the latter, exchange positions
  2. Each comparison will produce a maximum or minimum value
  3. The next round can be sorted one less time
  4. Loop until the end

Sparse array

Processing method

  • How many rows and columns in the record array, and how many different values
  • Record the elements, ranks and values ​​with different values ​​in a small-scale array, thereby reducing the size of the array

Insert picture description here
Insert picture description here
(Quoted from "The Mad God Says")

Guess you like

Origin blog.csdn.net/weixin_44048668/article/details/108690069