update insertion-sort codes (#36555)
add markdown identifier to code language JavaScript and Java
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
7164d9a797
commit
31536daf5e
@ -98,7 +98,7 @@ The algorithm shown below is a slightly optimized version to avoid swapping the
|
|||||||
|
|
||||||
Here is a detailed implementation in JavaScript:
|
Here is a detailed implementation in JavaScript:
|
||||||
|
|
||||||
```
|
```js
|
||||||
function insertion_sort(A) {
|
function insertion_sort(A) {
|
||||||
var len = array_length(A);
|
var len = array_length(A);
|
||||||
var i = 1;
|
var i = 1;
|
||||||
@ -135,7 +135,7 @@ A quick implementation in Swift is shown below :
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
The Java example is shown below:
|
The Java example is shown below:
|
||||||
```
|
```java
|
||||||
public int[] insertionSort(int[] arr)
|
public int[] insertionSort(int[] arr)
|
||||||
for (j = 1; j < arr.length; j++) {
|
for (j = 1; j < arr.length; j++) {
|
||||||
int key = arr[j]
|
int key = arr[j]
|
||||||
|
Reference in New Issue
Block a user