当前位置:网站首页>bubble sort
bubble sort
2022-06-26 03:48:00 【Just call me ah Jie】
Bubble sort is first from 1 Bit heel 2 A bit more , Move forward if you are older , The maximum value will be placed at the end of the loop once , Cycle twice , The second largest value will be placed in the penultimate number , And so on , Loop the entire list length n You can get a sequence table .
class Solution:
def search(self,list_num):
n =len(list_num)
for j in range(n): # loop n Time , Repeat the maximum value to the back , Until each is sorted
for i in range(n-1): # This loop can get a maximum value after the list
if list_num[i] > list_num[i+1]:
list_num[i] ,list_num[i+1] = list_num[i+1] ,list_num[i]
return list_num
边栏推荐
- Qixia fire department carries out fire safety training on construction site
- Evaluation - analytic hierarchy process
- MySQL stored procedure
- Kotlin learning apply plugin: 'kotlin Android extensions‘
- Open Camera异常分析(一)
- ABP framework Practice Series (II) - Introduction to domain layer
- An easy-to-use tablayout
- When the tiflash function is pushed down, it must be known that it will become a tiflash contributor in ten minutes
- WebRTC系列-网络传输之6-Connections裁剪
- Uni app custom drop-down selection list
猜你喜欢
【好书集锦】从技术到产品
Machine learning notes - trend components of time series
MySQL高级篇第一章(linux下安装MySQL)【下】
Cloud Computing Foundation -0
Some mobile phones open USB debugging, and the solution to installation failure
Oracle技术分享 oracle 19.14升级19.15
Redux thunk simple case, advantages, disadvantages and thinking
ABP framework Practice Series (I) - Introduction to persistence layer
Xiaomi TV's web page and jewelry's web page
Double carbon bonus + great year of infrastructure construction 𞓜 deep ploughing into the field of green intelligent equipment for water conservancy and hydropower
随机推荐
力扣79单词搜索
Evaluation - analytic hierarchy process
神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
Digital twin intelligent water service, breaking through the development dilemma of sponge City
You cannot call Glide. get() in registerComponents(), use the provided Glide instance instead
【Flink】Flink Sort-Shuffle写流程简析
816. 模糊坐标
redux-thunk 简单案例,优缺点和思考
Nebula Graph学习篇3_多线程完成6000w+关系数据迁移
360 second understanding of smartx hyper converged infrastructure
Gradient
用eclipse连mysql数据库出错然后出现图中的话是咋回事呀
ABP framework
[paper notes] learning to grasp with primitive shaped object policies
2022.6.25-----leetcode. Sword finger offer 091
等保备案是等保测评吗?两者是什么关系?
Slide the menu of uni app custom components left and right and click switch to select and display in the middle
ABP framework Practice Series (III) - domain layer in depth
评价——层次分析
【Flink】Flink 批处理模式Map端数据聚合 NormalizedKeySorter