We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d0ed0af + d596e1d commit 07f5ecfCopy full SHA for 07f5ecf
README.md
@@ -10,6 +10,8 @@ Each algorithm and data structure have its own separate README
10
with related explanations and links for further reading and YouTube
11
videos.
12
13
+Read this in other languages: [Chinese](https://github.com/trekhleb/javascript-algorithms/blob/master/README.zh-CN.md)
14
+
15
## Data Structures
16
17
Data structure is a particular way of organizing and storing data in a computer so that it can
@@ -190,7 +192,7 @@ Below is the list of some of the most used Big O notations and their performance
190
192
| **O(1)** | 1 | 1 | 1 |
191
193
| **O(log N)** | 3 | 6 | 9 |
194
| **O(N)** | 10 | 100 | 1000 |
-| **O(N log N)** | 30 | 60 | 9000 |
195
+| **O(N log N)** | 30 | 600 | 9000 |
196
| **O(N^2)** | 100 | 10000 | 1000000 |
197
| **O(2^N)** | 1024 | 1.26e+29 | 1.07e+301 |
198
| **O(N!)** | 3628800 | 9.3e+157 | 4.02e+2567 |
README.zh-CN.md
src/algorithms/search/binary-search/binarySearch.js
@@ -22,7 +22,7 @@ export default function binarySearch(sortedArray, seekElement, comparatorCallbac
22
}
23
24
// Decide which half to choose for seeking next: left or right one.
25
- if (comparator.lessThen(sortedArray[middleIndex], seekElement)) {
+ if (comparator.lessThan(sortedArray[middleIndex], seekElement)) {
26
// Go to the right half of the array.
27
startIndex = middleIndex + 1;
28
} else {
src/algorithms/sorting/bubble-sort/BubbleSort.js
@@ -18,7 +18,7 @@ export default class BubbleSort extends Sort {
18
this.callbacks.visitingCallback(array[j]);
19
20
// Swap elements if they are in wrong order.
21
- if (this.comparator.lessThen(array[j + 1], array[j])) {
+ if (this.comparator.lessThan(array[j + 1], array[j])) {
const tmp = array[j + 1];
array[j + 1] = array[j];
array[j] = tmp;
src/algorithms/sorting/insertion-sort/InsertionSort.js
@@ -15,7 +15,7 @@ export default class InsertionSort extends Sort {
// If this is the case then swap that elements.
while (
array[currentIndex - 1] &&
- this.comparator.lessThen(array[currentIndex], array[currentIndex - 1])
+ this.comparator.lessThan(array[currentIndex], array[currentIndex - 1])
) {
// Call visiting callback.
this.callbacks.visitingCallback(array[currentIndex - 1]);
src/algorithms/sorting/merge-sort/MergeSort.js
@@ -31,7 +31,7 @@ export default class MergeSort extends Sort {
31
let minimumElement = null;
32
33
// Find minimum element of two arrays.
34
- if (this.comparator.lessThenOrEqual(leftArray[0], rightArray[0])) {
+ if (this.comparator.lessThanOrEqual(leftArray[0], rightArray[0])) {
35
minimumElement = leftArray.shift();
36
37
minimumElement = rightArray.shift();
src/algorithms/sorting/quick-sort/QuickSort.js
@@ -27,7 +27,7 @@ export default class QuickSort extends Sort {
if (this.comparator.equal(currentElement, pivotElement)) {
29
centerArray.push(currentElement);
30
- } else if (this.comparator.lessThen(currentElement, pivotElement)) {
+ } else if (this.comparator.lessThan(currentElement, pivotElement)) {
leftArray.push(currentElement);
rightArray.push(currentElement);
src/algorithms/sorting/selection-sort/SelectionSort.js
@@ -16,7 +16,7 @@ export default class SelectionSort extends Sort {
- if (this.comparator.lessThen(array[j], array[minIndex])) {
+ if (this.comparator.lessThan(array[j], array[minIndex])) {
minIndex = j;
src/algorithms/sorting/shell-sort/ShellSort.js
@@ -20,7 +20,7 @@ export default class ShellSort extends Sort {
this.callbacks.visitingCallback(array[currentIndex]);
// Compare and swap array elements if needed.
- if (this.comparator.lessThen(array[gapShiftedIndex], array[currentIndex])) {
+ if (this.comparator.lessThan(array[gapShiftedIndex], array[currentIndex])) {
const tmp = array[currentIndex];
array[currentIndex] = array[gapShiftedIndex];
array[gapShiftedIndex] = tmp;
src/algorithms/uncategorized/knight-tour/knightTour.js
@@ -4,7 +4,7 @@
4
* @return {number[][]}
5
*/
6
function getPossibleMoves(chessboard, position) {
7
- // Generate all knight moves (event those that goes beyond the board).
+ // Generate all knight moves (even those that go beyond the board).
8
const possibleMoves = [
9
[position[0] - 1, position[1] - 2],
[position[0] - 2, position[1] - 1],
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments