Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cd56400

Browse files
change variable names
1 parent 9c79fc5 commit cd56400

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

‎README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ IN PROGRESS
44

55
Computer Science algorithms implemented in JavaScript, based mostly on these resources:
66

7-
- [MIT 6.006](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm)
7+
- [MIT 6.006 - Introduction to Algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm)
88
- [Introduction to Algorithms - 3rd Edition](https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press/dp/0262033844)
99

1010
## Usage
@@ -55,14 +55,14 @@ Feel free to navigate around.
5555

5656
[Bubble sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/bubble-sort.js)
5757

58-
[Insertion sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/insertion-sort.js)
59-
6058
[Heap sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/heap-sort.js)
6159

62-
[Selection sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/selection-sort.js)
60+
[Insertion sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/insertion-sort.js)
6361

6462
[Merge sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/merge-sort.js)
6563

64+
[Selection sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/selection-sort.js)
65+
6666
[Quick sort](https://github.com/estevanmaito/algorithms-in-javascript/tree/master/sorting/quick-sort.js)
6767

6868
#### Searching

‎searching/binary-search.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// https://en.wikipedia.org/wiki/Binary_search_algorithm
22

3-
let binarySearch = (targetValue, array) => {
3+
let binarySearch = (targetValue, arr) => {
44
let start = 0,
5-
end = array.length - 1,
5+
end = arr.length - 1,
66
middle
77

88
while (start <= end) {
99
middle = Math.floor((start + end) / 2)
1010

11-
if (targetValue === array[middle]) return middle
12-
else if (targetValue < array[middle]) end = middle - 1
11+
if (targetValue === arr[middle]) return middle
12+
else if (targetValue < arr[middle]) end = middle - 1
1313
else start = middle + 1
1414
}
1515
return -1
@@ -18,11 +18,11 @@ let binarySearch = (targetValue, array ) => {
1818
const test = require('tape')
1919

2020
let generateSortedArray = (range) => {
21-
let array = []
22-
while (array.length < range) {
23-
array.push(array.length + 1)
21+
let arr = []
22+
while (arr.length < range) {
23+
arr.push(arr.length + 1)
2424
}
25-
return array
25+
return arr
2626
}
2727

2828
test('Binary search', assert => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /