- Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathShell Sort.html
More file actions
Latest commit
30 lines (29 loc) · 714 Bytes
/
Copy pathShell Sort.html
File metadata and controls
30 lines (29 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
functionshellSort(arr){
letlen=arr.length,
gap=Math.floor(len/2);
while(gap>0){
for(leti=gap;i<len;i++){
for(letj=i;j-gap>=0;j-=gap){
if(arr[j-gap]>arr[j]){
[arr[j-gap],arr[j]]=[arr[j],arr[j-gap]]
}else{
break;
}
}
}
gap=gap>>1
}
returnarr
}
shellSort([8,9,1,7,2,3,5,4,6,0])
</script>
</body>
</html>