当前位置:网站首页>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;
}
}
边栏推荐
- Introduction to ES6 promise, new features of ES7 and es8 async and await
- To tell you the truth, ThreadLocal is really not an advanced thing
- lvm-snapshot:基于LVM快照的备份
- New trend of embedded software development: Devops
- 2022-2028 global capsule shell industry research and trend analysis report
- Simple application example of rhai script engine
- Kubernetes ---- pod configuration container start command
- Luogu p1144 shortest circuit count
- 2022-2028 global public address fire alarm system industry research and trend analysis report
- 2022-06-30: what does the following golang code output? A:0; B:2; C: Running error. package main import “fmt“ func main()
猜你喜欢

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

ABAQUS 2022 software installation package and installation tutorial

C WinForm program interface optimization example

2022-2028 global capsule shell industry research and trend analysis report

CTF tool (1) -- archpr -- including installation / use process

20220215 CTF misc buuctf Xiaoming's safe binwalk analysis DD command separate rar file archpr brute force password cracking

In depth understanding of jetpack compose kernel: slottable system

2022-2028 global rotary transmission system industry research and trend analysis report

Makefile notes (Yiwen Institute makefile)

女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
随机推荐
1175. Disposition des nombres premiers / échange de doigts II 104. Nombre de permutations
Random ball size, random motion collision
[untitled]
2022-2028 global encrypted external hard disk industry research and trend analysis report
Ditto set global paste only text shortcuts
Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
2022-2028 global herbal diet tea industry research and trend analysis report
PS2 handle-1 "recommended collection"
Software engineering best practices - project requirements analysis
Error 2059 when Navicat connects to MySQL
Is it safe to choose mobile phone for stock trading account opening in Guangzhou?
2022-2028 global retro glass industry research and trend analysis report
left join左连接匹配数据为NULL时显示指定值
20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
LVM snapshot: preparation of backup based on LVM snapshot
Red Hat将在Project Atomic上运用容器负载服务器
Advanced mathematical modeling
lvm-snapshot:基于LVM快照的备份之准备工作
ABAQUS 2022 software installation package and installation tutorial
五分钟搞懂探索式测试