Skip to content

Commit 002b10a

Browse files
authored
docs: fix typos (TheAlgorithms#1283)
* docs: fix typos * fix
1 parent 8cd86b1 commit 002b10a

24 files changed

+47
-47
lines changed

Cache/Memoize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const memoize = (func, cache = new Map()) => {
3030
/**
3131
* Arguments converted to JSON string for use as a key of Map - it's easy to detect collections like -> Object and Array
3232
* If the args input is -> [new Set([1, 2, 3, 4]), {name: 'myName', age: 23}]
33-
* Then the agrsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string
33+
* Then the argsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string
3434
* Now it's ready to be a perfect key for Map
3535
*/
3636
const argsKey = JSON.stringify(args, jsonReplacer)

Ciphers/test/AffineCipher.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Test Affine Cipher', () => {
1919
expect(() => encrypt('null', 4, 1)).toThrow()
2020
})
2121

22-
it('Test - 3 Pass string value to encrypt and ecrypt function', () => {
22+
it('Test - 3 Pass string value to encrypt and decrypt function', () => {
2323
expect(decrypt(encrypt('HELLO WORLD', 5, 8), 5, 8)).toBe('HELLO WORLD')
2424
expect(decrypt(encrypt('ABC DEF', 3, 5), 3, 5)).toBe('ABC DEF')
2525
expect(decrypt(encrypt('Brown fox jump over the fence', 7, 3), 7, 3)).toBe(

Ciphers/test/KeywordShiftedAlphabet.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { encrypt, decrypt } from '../KeywordShiftedAlphabet'
22

3-
test('Hello world! === dcrypt(encrypt(Hello world!))', () => {
3+
test('Hello world! === decrypt(encrypt(Hello world!))', () => {
44
const word = 'Hello world!'
55
const result = decrypt('keyword', encrypt('keyword', word))
66
expect(result).toMatch(word)
77
})
88

9-
test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => {
9+
test('The Algorithms === decrypt(encrypt(The Algorithms))', () => {
1010
const word = 'The Algorithms'
1111
const result = decrypt('keyword', encrypt('keyword', word))
1212
expect(result).toMatch(word)

Ciphers/test/VigenereCipher.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { encrypt, decrypt } from '../VigenereCipher'
22

3-
test('Hello world! === dcrypt(encrypt(Hello world!))', () => {
3+
test('Hello world! === decrypt(encrypt(Hello world!))', () => {
44
const word = 'Hello world!'
55
const result = decrypt(encrypt(word, 'code'), 'code')
66
expect(result).toMatch(word)
77
})
88

9-
test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => {
9+
test('The Algorithms === decrypt(encrypt(The Algorithms))', () => {
1010
const word = 'The Algorithms'
1111
const result = decrypt(encrypt(word, 'code'), 'code')
1212
expect(result).toMatch(word)

Conversions/BinaryToHex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const hexLookup = (bin) => {
2929
}
3030
const binaryToHex = (binaryString) => {
3131
/*
32-
Function for convertung Binary to Hex
32+
Function for converting Binary to Hex
3333
3434
1. The conversion will start from Least Significant Digit (LSB) to the Most Significant Bit (MSB).
3535
2. We divide the bits into sections of 4-bits starting from LSB to MSB.

Conversions/RailwayTimeConversion.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const RailwayTimeConversion = (timeString) => {
2121
return new TypeError('Argument is not a string.')
2222
}
2323
// split the string by ':' character.
24-
const [hour, minute, scondWithShift] = timeString.split(':')
24+
const [hour, minute, secondWithShift] = timeString.split(':')
2525
// split second and shift value.
26-
const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)]
26+
const [second, shift] = [secondWithShift.substr(0, 2), secondWithShift.substr(2)]
2727
// convert shifted time to not-shift time(Railway time) by using the above explanation.
2828
if (shift === 'PM') {
2929
if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` }

Conversions/test/TemperatureConversion.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ describe('Testing Conversion of Rankine to Kelvin', () => {
8080
expect(test1).toBe(6)
8181
})
8282
})
83-
describe('Testing Conversion of Reamur to Celsius', () => {
84-
it('with Reamur value', () => {
83+
describe('Testing Conversion of Reaumur to Celsius', () => {
84+
it('with Reaumur value', () => {
8585
const test1 = tc.reaumurToCelsius(100)
8686
expect(test1).toBe(125)
8787
})
8888
})
89-
describe('Testing Conversion of Reamur to Fahrenheit', () => {
90-
it('with Reamur value', () => {
89+
describe('Testing Conversion of Reaumur to Fahrenheit', () => {
90+
it('with Reaumur value', () => {
9191
const test1 = tc.reaumurToFahrenheit(100)
9292
expect(test1).toBe(257)
9393
})
9494
})
95-
describe('Testing Conversion of Reamur to Kelvin', () => {
95+
describe('Testing Conversion of Reaumur to Kelvin', () => {
9696
it('with Reamur value', () => {
9797
const test1 = tc.reaumurToKelvin(100)
9898
expect(test1).toBe(398)

Data-Structures/Array/LocalMaximomPoint.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Notes:
55
* - works by using divide and conquer
6-
* - the function gets the array A with n Real numbersand returns the local max point index (if more than one exists return the first one)
6+
* - the function gets the array A with n Real numbers and returns the local max point index (if more than one exists return the first one)
77
*
88
* @complexity: O(log(n)) (on average )
99
* @complexity: O(log(n)) (worst case)

Data-Structures/Tree/Trie.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ Trie.prototype.remove = function (word, count) {
8383
if (child.count >= count) child.count -= count
8484
else child.count = 0
8585

86-
// If some occurrences are left we dont delete it or else
87-
// if the object forms some other objects prefix we dont delete it
86+
// If some occurrences are left we don't delete it or else
87+
// if the object forms some other objects prefix we don't delete it
8888
// For checking an empty object
8989
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
9090
if (child.count <= 0 && (Object.keys(child.children).length && child.children.constructor === Object)) {
@@ -110,7 +110,7 @@ Trie.prototype.contains = function (word) {
110110
return true
111111
}
112112

113-
Trie.prototype.findOccurences = function (word) {
113+
Trie.prototype.findOccurrences = function (word) {
114114
// find the node with given prefix
115115
const node = this.findPrefix(word)
116116
// No such word exists

Dynamic-Programming/KadaneAlgo.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Kadane's algorithm is one of the most efficient ways to
22
* calculate the maximum contiguous subarray sum for a given array.
3-
* Below is the implementation of kadanes's algorithm along with
3+
* Below is the implementation of Kadane's algorithm along with
44
* some sample test cases.
55
* There might be a special case in this problem if al the elements
66
* of the given array are negative. In such a case, the maximum negative
@@ -10,14 +10,14 @@
1010
*/
1111

1212
export function kadaneAlgo (array) {
13-
let cummulativeSum = 0
13+
let cumulativeSum = 0
1414
let maxSum = Number.NEGATIVE_INFINITY // maxSum has the least possible value
1515
for (let i = 0; i < array.length; i++) {
16-
cummulativeSum = cummulativeSum + array[i]
17-
if (maxSum < cummulativeSum) {
18-
maxSum = cummulativeSum
19-
} else if (cummulativeSum < 0) {
20-
cummulativeSum = 0
16+
cumulativeSum = cumulativeSum + array[i]
17+
if (maxSum < cumulativeSum) {
18+
maxSum = cumulativeSum
19+
} else if (cumulativeSum < 0) {
20+
cumulativeSum = 0
2121
}
2222
}
2323
return maxSum

Dynamic-Programming/UniquePaths2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const uniquePaths2 = (obstacles) => {
6363
grid[0][j] = 1
6464
}
6565
// Fill the rest of grid by dynamic programming
66-
// using following reccurent formula:
66+
// using following recurrent formula:
6767
// K[i][j] = K[i - 1][j] + K[i][j - 1]
6868
for (let i = 1; i < rows; i++) {
6969
for (let j = 1; j < columns; j++) {

Geometry/Circle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This class represents a circle and can calculate it's perimeter and area
33
* https://en.wikipedia.org/wiki/Circle
44
* @constructor
5-
* @param {number} radius - The radius of the circule.
5+
* @param {number} radius - The radius of the circle.
66
*/
77
export default class Circle {
88
constructor (radius) {

Graphs/BinaryLifting.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Binary Lifting implementation in Javascript
44
* Binary Lifting is a technique that is used to find the kth ancestor of a node in a rooted tree with N nodes
55
* The technique requires preprocessing the tree in O(N log N) using dynamic programming
6-
* The techniqe can answer Q queries about kth ancestor of any node in O(Q log N)
6+
* The technique can answer Q queries about kth ancestor of any node in O(Q log N)
77
* It is faster than the naive algorithm that answers Q queries with complexity O(Q K)
88
* It can be used to find Lowest Common Ancestor of two nodes in O(log N)
99
* Tutorial on Binary Lifting: https://codeforces.com/blog/entry/100826

Graphs/LCABinaryLifting.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Author: Adrito Mukherjee
3-
* Findind Lowest Common Ancestor By Binary Lifting implementation in JavaScript
3+
* Finding Lowest Common Ancestor By Binary Lifting implementation in JavaScript
44
* The technique requires preprocessing the tree in O(N log N) using dynamic programming)
55
* It can be used to find Lowest Common Ancestor of two nodes in O(log N)
66
* Tutorial on Lowest Common Ancestor: https://www.geeksforgeeks.org/lca-in-a-tree-using-binary-lifting-technique

Maths/BinomialCoefficient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* @function findBinomialCoefficient
10-
* @description -> this function returns bonimial coefficient
10+
* @description -> this function returns binomial coefficient
1111
* of two numbers n & k given by n!/((n-k)!k!)
1212
* @param {number} n
1313
* @param {number} k

Maths/CheckKishnamurthyNumber.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const CheckKishnamurthyNumber = (number) => {
3737
sumOfAllDigitFactorial += factorial(lastDigit)
3838
newNumber = Math.floor(newNumber / 10)
3939
}
40-
// if the sumOftheFactorial is equal to the given number it means the number is a Krishnamurthy number.
40+
// if the sumOfAllDigitFactorial is equal to the given number it means the number is a Krishnamurthy number.
4141
return sumOfAllDigitFactorial === number
4242
}
4343

Maths/ExtendedEuclideanGCD.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
33
*
4-
* This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms
4+
* This algorithm plays an important role for modular arithmetic, and by extension for cryptography algorithms
55
*
66
* Basic explanation:
77
* The Extended Euclidean algorithm is a modification of the standard Euclidean GCD algorithm.

Maths/FermatPrimalityTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* 1 / 2^50 = 8.8 * 10^-16 (a pretty small number)
2222
*
2323
* For comparison, the probability of a cosmic ray causing an error to your
24-
* infalible program is around 1.4 * 10^-15. An order of magnitude below!
24+
* infallible program is around 1.4 * 10^-15. An order of magnitude below!
2525
*
2626
* But because nothing is perfect, there's a major flaw to this algorithm, and
2727
* the cause are the so called Carmichael Numbers. These are composite numbers n

Maths/test/MeanAbsoluteDeviation.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('tests for mean absolute deviation', () => {
99
expect(() => meanAbsoluteDeviation('fgh')).toThrow()
1010
})
1111

12-
it('should return the mean absolute devition of an array of numbers', () => {
12+
it('should return the mean absolute deviation of an array of numbers', () => {
1313
const meanAbDev = meanAbsoluteDeviation([2, 34, 5, 0, -2])
1414
expect(meanAbDev).toBe(10.479999999999999)
1515
})

Project-Euler/Problem003.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// https://projecteuler.net/problem=3
22

33
export const largestPrime = (num = 600851475143) => {
4-
let newnumm = num
4+
let newnum = num
55
let largestFact = 0
66
let counter = 2
7-
while (counter * counter <= newnumm) {
8-
if (newnumm % counter === 0) {
9-
newnumm = newnumm / counter
7+
while (counter * counter <= newnum) {
8+
if (newnum % counter === 0) {
9+
newnum = newnum / counter
1010
} else {
1111
counter++
1212
}
1313
}
14-
if (newnumm > largestFact) {
15-
largestFact = newnumm
14+
if (newnum > largestFact) {
15+
largestFact = newnum
1616
}
1717
return largestFact
1818
}

Project-Euler/Problem008.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
const largestAdjacentNumber = (grid, consecutive) => {
44
grid = grid.split('\n').join('')
5-
const splitedGrid = grid.split('\n')
5+
const splitGrid = grid.split('\n')
66
let largestProd = 0
77

8-
for (const row in splitedGrid) {
9-
const currentRow = splitedGrid[row].split('').map(x => Number(x))
8+
for (const row in splitGrid) {
9+
const currentRow = splitGrid[row].split('').map(x => Number(x))
1010

1111
for (let i = 0; i < currentRow.length - consecutive; i++) {
1212
const combine = currentRow.slice(i, i + consecutive)

Project-Euler/Problem023.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
/**
17-
* collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the llst of sums, adds them and returns their sum.
17+
* collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the list of sums, adds them and returns their sum.
1818
* @param {number} [n = 28123]
1919
* @returns {number}
2020
*/

Project-Euler/Problem028.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function problem28 (dim) {
4040
* Third corner: i^2 - 2 * (i - 1)
4141
* Fourth corner: i^2 - 3 * (i - 1)
4242
*
43-
* Doing the sum of each corner and simplifing, we found that the result for each dimension is:
43+
* Doing the sum of each corner and simplifying, we found that the result for each dimension is:
4444
* sumDim = 4 * i^2 + 6 * (1 - i)
4545
*
4646
* In this case I skip the 1x1 dim matrix because is trivial, that's why I start in a 3x3 matrix

Sorts/IntroSort.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @function Intosort (As implemented in STD C++ Lib)
2+
* @function Introsort (As implemented in STD C++ Lib)
33
* The function performs introsort which is used in
44
* C++ Standard LIbrary, the implementation is inspired from]
55
* library routine itself.
@@ -88,7 +88,7 @@ function introsort (array, compare) {
8888
const THRESHOLD = 16
8989
/**
9090
* @constant TUNEMAXDEPTH
91-
* Constant usec to increase or decrease value
91+
* Constant used to increase or decrease value
9292
* of maxDepth
9393
*/
9494
const TUNEMAXDEPTH = 1

0 commit comments

Comments
 (0)