FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/algorithms/bubbleSortRecursive.js at master · lgope/JavaScript · GitHub
lgope
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
11
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
algorithms
/
bubbleSortRecursive.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (15 loc) · 430 Bytes
Breadcrumbs
JavaScript
/
algorithms
/
bubbleSortRecursive.js
Copy path
File metadata and controls
24 lines (15 loc) · 430 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function
bubbleSort
(
arr
,
iteration
)
{
if
(
iteration
===
0
)
return
;
bubbleSwap
(
arr
,
0
,
1
,
iteration
)
;
bubbleSort
(
arr
,
iteration
-
1
)
;
}
function
bubbleSwap
(
arr
,
i
,
j
,
n
)
{
if
(
j
>=
n
)
return
;
// swap
if
(
arr
[
i
]
>
arr
[
j
]
)
[
arr
[
i
]
,
arr
[
j
]
]
=
[
arr
[
j
]
,
arr
[
i
]
]
;
bubbleSwap
(
arr
,
i
+
1
,
j
+
1
,
n
)
;
}
const
arr
=
[
1
,
8
,
6
,
5
,
4
,
9
]
;
if
(
arr
.
length
>=
1
)
bubbleSort
(
arr
,
arr
.
length
)
console
.
log
(
arr
)
// tc => O(n^2)
Back
|
FazBrowse Home
|
New Git URL