当前位置:网站首页>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;
}
}
边栏推荐
- LVM snapshot: preparation of backup based on LVM snapshot
- CentOS installation starts redis
- 2022-2028 global single travel industry research and trend analysis report
- Random ball size, random motion collision
- Teach you how to use Hal library to get started -- become a lighting master
- Advanced mathematical modeling
- [leetcode] [SQL] notes
- Development of wireless U-shaped ultrasonic electric toothbrush
- How do it outsourcing resident personnel position their pain points?
- lvm-snapshot:基于LVM快照的备份
猜你喜欢

The programmer's girlfriend gave me a fatigue driving test

76 page comprehensive solution 2022 for smart Logistics Park (download attached)

20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking

Detailed explanation of conv2d -- use in arrays and images

The programmer's girlfriend gave me a fatigue driving test

Gateway service gateway

MySQL variables, stored procedures and functions

2022-2028 global 3D printing ASA consumables industry research and trend analysis report

Error 2059 when Navicat connects to MySQL

20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
随机推荐
What should I do without 50W bride price
ABAQUS 2022 software installation package and installation tutorial
Can SQL execution be written in tidb dashboard
2022-2028 global 3D printing ASA consumables industry research and trend analysis report
76 page comprehensive solution 2022 for smart Logistics Park (download attached)
Advanced mathematical modeling
网上开华泰证券的股票账户是否安全呢?
CentOS 6.3 x64 PHP 5.2.6 扩展安装OpenSSL出错的解决方法
When we look at the industrial Internet, we always look at it from the opposite of the consumer Internet
6-1 exploit -ftp exploit
2022-2028 global ethylene oxide scrubber industry research and trend analysis report
Why did kubernetes win? The changes in the container circle!
Redis - understand the master-slave replication mechanism
深入理解 Jetpack Compose 内核:SlotTable 系统
Warmup preheating learning rate "suggestions collection"
C /platform:anycpu32bitpererrored can only be used with /t:exe, /t:winexe and /t:appcontainerexe
On the application of cluster analysis in work
What value should testers play in requirements review? Two minutes will stop you from being stupid
CentOS installation starts redis
1175. 质数排列 / 剑指 Offer II 104. 排列的数目