当前位置:网站首页>JS bubble sort and select sort
JS bubble sort and select sort
2022-07-01 00:29:00 【01xm】
Bubbling
for(let i=0;i<arr.length-1;i++){
// Control the number of trips
for(let j=0;j<arr.length-i-1;j++){
// Control the number of exchanges
if(arr[j]>arr[j+1]){
var temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
choice
for(let i=0;i<arr.length;i++){
// Control the number of cycles
let k = i; // Mark , The subscript of the lowest decimal
var min = arr[k] // Let the first be the smallest number
for(let j = i+1;j<arr.length;j++){
// Find the smallest number in the sequence , use k Mark subscript
if(min>arr[j]){
min = arr[j];
k = j;
}
}
if(k!=i){
//arr[i] Is the default minimum number arr[k] Is the actual minimum number
var temp = arr[i];
arr[i] = arr[k]
arr[k] = temp;
}
}
边栏推荐
- 在指南针上买基金安全吗?
- Red hat will apply container load server on project atomic
- Operation record of reinitialization instance of Dameng database
- Simple application example of rhai script engine
- Introduction to ES6 promise, new features of ES7 and es8 async and await
- Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
- Examples of topological sequences
- [untitled]
- [DaVinci developer topic] -37- detail IRV: introduction to inter runnable variable + configuration
- 76 page comprehensive solution 2022 for smart Logistics Park (download attached)
猜你喜欢

Manage edge browser settings (ie mode, homepage binding, etc.) through group policy in the enterprise

Bugku CTF daily one question dark cloud invitation code

6-1 exploit -ftp exploit

left join左连接匹配数据为NULL时显示指定值

How to edit special effects in VR panorama? How to display detailed functions?

MySQL variables, stored procedures and functions

2022-2028 global plant peptone industry research and trend analysis report

When is it appropriate to replace a virtual machine with a virtual machine?

深入理解 Jetpack Compose 内核:SlotTable 系统
![[NLP] [textcnn] text classification](/img/bb/c8fd9f1ed458a88a17b8d5c70d9ce2.png)
[NLP] [textcnn] text classification
随机推荐
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
[designmode] factory pattern
To tell you the truth, ThreadLocal is really not an advanced thing
Ybtoj exchange game [tree chain splitting, line segment tree merging]
网上开华泰证券的股票账户是否安全呢?
On the application of cluster analysis in work
Solutions to errors in installing OpenSSL for CentOS 6.3 x64 PHP 5.2.6 extensions
Gateway service gateway
Design e-commerce seckill system
Redis - how to understand publishing and subscribing
C /platform:anycpu32bitpererrored can only be used with /t:exe, /t:winexe and /t:appcontainerexe
lvm-snapshot:基于LVM快照的备份
2022-2028 global single travel industry research and trend analysis report
The college entrance examination in 2022 is over. Does anyone really think programmers don't need to study after work?
2022-2028 global herbal diet tea industry research and trend analysis report
让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北
女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
2022-2028 global ethylene oxide scrubber industry research and trend analysis report
1175. prime number arrangement / Sword finger offer II 104 Number of permutations