Skip to content

Commit 954624a

Browse files
author
syedjafer
committed
Resolved Comments
1 parent 6ed6fda commit 954624a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Sorts/BinaryInsertionSort.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ function binarySearch (array, key, start, end) {
4343
}
4444

4545
/**
46-
* Binary Insertion Sort
47-
*
48-
* @param {Array} list List to be sorted.
49-
* @return {Array} The sorted list.
50-
*/
46+
* Binary Insertion Sort
47+
*
48+
* @param {Array} list List to be sorted.
49+
* @return {Array} The sorted list.
50+
*/
5151
export function binaryInsertionSort (array) {
5252
const totalLength = array.length
53-
for (let itr = 1; itr < totalLength; itr += 1) {
54-
const key = array[itr]
55-
const indexPosition = binarySearch(array, key, 0, itr - 1)
56-
array.splice(itr, 1)
53+
for (let i = 1; i < totalLength; i += 1) {
54+
const key = array[i]
55+
const indexPosition = binarySearch(array, key, 0, i - 1)
56+
array.splice(i, 1)
5757
array.splice(indexPosition, 0, key)
5858
}
5959
return array

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy