Skip to content

Commit 1589263

Browse files
committed
fixed some spellings
1 parent 199d263 commit 1589263

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+80
-80
lines changed

Backtracking/SumOfSubset.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Given an ordered set W of non-negative integers and a value K,
66
* determine all possible subsets from the given set W whose sum
7-
* of its elemets equals to the given value K.
7+
* of its elements equals to the given value K.
88
*
99
* More info: https://www.geeksforgeeks.org/subset-sum-backtracking-4/
1010
*/
@@ -53,7 +53,7 @@ const sumOfSubset = (set, subset, setindex, sum, targetSum) => {
5353
targetSum
5454
)
5555

56-
// Concat the recursive result with current result arary
56+
// Concat the recursive result with current result array
5757
results = [...results, ...subsetResult]
5858
})
5959

Bit-Manipulation/BinaryCountSetBits.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
license: GPL-3.0 or later
44
55
This script will find number of 1's
6-
in binary representain of given number
6+
in binary representation of given number
77
88
*/
99

1010
function BinaryCountSetBits (a) {
1111
'use strict'
12-
// convert number into binary representation and return number of set bits in binary representaion
12+
// convert number into binary representation and return number of set bits in binary representation
1313
return a.toString(2).split('1').length - 1
1414
}
1515

Ciphers/KeyFinder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function keyFinder (str) { // str is used to get the input of encrypted string
4848
// console.log( k + outStrElement + wordBank[i] );//debug
4949

5050
// this part need to be optimize with the calculation of the number of occurrence of word's probabilities
51-
// linked list will be used in the next stage of development to calculate the number of occurace of the key
51+
// linked list will be used in the next stage of development to calculate the number of occurrence of the key
5252
if (wordBank[i] === outStrElement) {
5353
return k // return the key number if founded
5454
}

Conversions/DateDayDifference.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const DateDayDifference = (date1, date2) => {
2222
if (typeof date1 !== 'string' && typeof date2 !== 'string') {
2323
return new TypeError('Argument is not a string.')
2424
}
25-
// extarct the first date
25+
// extract the first date
2626
const [firstDateDay, firstDateMonth, firstDateYear] = date1.split('/').map((ele) => Number(ele))
27-
// extarct the second date
27+
// extract the second date
2828
const [secondDateDay, secondDateMonth, secondDateYear] = date2.split('/').map((ele) => Number(ele))
2929
// check the both data are valid or not.
3030
if (firstDateDay < 0 || firstDateDay > 31 ||

Conversions/DateToDay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const DateToDay = (date) => {
4444
if (typeof date !== 'string') {
4545
return new TypeError('Argument is not a string.')
4646
}
47-
// extarct the date
47+
// extract the date
4848
const [day, month, year] = date.split('/').map((x) => Number(x))
4949
// check the data are valid or not.
5050
if (day < 0 || day > 31 || month > 12 || month < 0) {

Conversions/RailwayTimeConversion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
want some changes in hour value.
66
77
Input Formate -> 07:05:45PM
8-
Output Fromate -> 19:05:45
8+
Output Formate -> 19:05:45
99
1010
Problem & Explanation Source : https://www.mathsisfun.com/time.html
1111
*/

Conversions/TitleCaseConversion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @returns {String}
99
*/
1010
const TitleCaseConversion = (inputString) => {
11-
// Extact all space seprated string.
11+
// Extract all space separated string.
1212
const stringCollections = inputString.split(' ').map(word => {
1313
let firstChar = ''
1414
// Get a character code by the use charCodeAt method.

Data-Structures/Linked-List/CycleDetection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function main () {
1111
Note:
1212
* While Solving the problem in given link below, don't use main() function.
1313
* Just use only the code inside main() function.
14-
* The purpose of using main() function here is to aviod global variables.
14+
* The purpose of using main() function here is to avoid global variables.
1515
1616
Link for the Problem: https://leetcode.com/problems/linked-list-cycle/
1717
*/

Data-Structures/Linked-List/RotateListRight.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function main () {
1010
Note:
1111
* While Solving the problem in given link below, don't use main() function.
1212
* Just use only the code inside main() function.
13-
* The purpose of using main() function here is to aviod global variables.
13+
* The purpose of using main() function here is to avoid global variables.
1414
1515
Link for the Problem: https://leetcode.com/problems/rotate-list/
1616
*/

Data-Structures/Tree/AVLTree.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let utils;
3737
*/
3838
const AVLTree = (function () {
3939
function _avl (comp) {
40-
/** @public compartor function */
40+
/** @public comparator function */
4141
this._comp = undefined
4242
if (comp !== undefined) {
4343
this._comp = comp
@@ -119,7 +119,7 @@ const AVLTree = (function () {
119119
node._right = rightRotate(node._right)
120120
return leftRotate(node) // Right Left
121121
}
122-
return leftRotate(node) // Rigth Right
122+
return leftRotate(node) // Right Right
123123
}
124124
// implement avl tree insertion
125125
const insert = function (root, val, tree) {
@@ -202,7 +202,7 @@ const AVLTree = (function () {
202202
return true
203203
}
204204
/**
205-
* TO check is a particluar element exists or not
205+
* TO check is a particular element exists or not
206206
* @param {any} _val
207207
* @returns {Boolean} exists or not
208208
*/

Data-Structures/Tree/Trie.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Trie () {
1414
this.root = new TrieNode(null, null)
1515
}
1616

17-
// Recursively finds the occurence of all words in a given node
17+
// Recursively finds the occurrence of all words in a given node
1818
Trie.findAllWords = function (root, word, output) {
1919
if (root === null) return
2020
if (root.count > 0) {
@@ -79,11 +79,11 @@ Trie.prototype.remove = function (word, count) {
7979
child = child.children[key]
8080
}
8181

82-
// Delete no of occurences specified
82+
// Delete no of occurrences specified
8383
if (child.count >= count) child.count -= count
8484
else child.count = 0
8585

86-
// If some occurences are left we dont delete it or else
86+
// If some occurrences are left we dont delete it or else
8787
// if the object forms some other objects prefix we dont delete it
8888
// For checking an empty object
8989
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object

Dynamic-Programming/KadaneAlgo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function KadaneAlgo (array) {
1010
}
1111
}
1212
return maxSum
13-
// This function returns largest sum contigous sum in a array
13+
// This function returns largest sum contiguous sum in a array
1414
}
1515
function main () {
1616
const myArray = [1, 2, 3, 4, -6]

Dynamic-Programming/SieveOfEratosthenes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function sieveOfEratosthenes (n) {
22
/*
33
* Calculates prime numbers till a number n
44
* :param n: Number upto which to calculate primes
5-
* :return: A boolean list contaning only primes
5+
* :return: A boolean list containing only primes
66
*/
77
const primes = new Array(n + 1)
88
primes.fill(true) // set all as true initially
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { longestPalindromeSubsequence } from '../LongestPalindromicSubsequence'
22

33
describe('LongestPalindromicSubsequence', () => {
4-
it('expects to return 1 as longest pallindromic subsequence', () => {
4+
it('expects to return 1 as longest palindromic subsequence', () => {
55
expect(longestPalindromeSubsequence('abcdefgh')).toBe(1)
66
})
77

8-
it('expects to return 4 as longest pallindromic subsequence', () => {
8+
it('expects to return 4 as longest palindromic subsequence', () => {
99
expect(longestPalindromeSubsequence('bbbab')).toBe(4)
1010
})
1111

12-
it('expects to return 2 as longest pallindromic subsequence', () => {
12+
it('expects to return 2 as longest palindromic subsequence', () => {
1313
expect(longestPalindromeSubsequence('cbbd')).toBe(2)
1414
})
1515

16-
it('expects to return 7 as longest pallindromic subsequence', () => {
16+
it('expects to return 7 as longest palindromic subsequence', () => {
1717
expect(longestPalindromeSubsequence('racexyzcxar')).toBe(7)
1818
})
1919
})

Geometry/ConvexHullGraham.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function convexHull (points) {
3333
points.sort(compare)
3434
const p1 = points[0]; const p2 = points[pointsLen - 1]
3535

36-
// Divide Hull in two halfs
36+
// Divide Hull in two halves
3737
const upperPoints = []; const lowerPoints = []
3838

3939
upperPoints.push(p1)

Graphs/Dijkstra.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Author: Samarth Jain
33
* Dijkstra's Algorithm implementation in JavaScript
44
* Dijkstra's Algorithm calculates the minimum distance between two nodes.
5-
* It is used to find the shortes path.
5+
* It is used to find the shortest path.
66
* It uses graph data structure.
77
*/
88

Graphs/NumberOfIslands.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
https://dev.to/rattanakchea/amazons-interview-question-count-island-21h6
33
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
44
5-
two a dimensial grid map
6-
each element is going to represent a peice of land
5+
a two dimensional grid map
6+
each element is going to represent a piece of land
77
1 is land,
88
0 is water
99
output a number which is the number of islands

Hashes/SHA1.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
const CHAR_SIZE = 8
1010

1111
/**
12-
* Adds padding to binary/hex string represention
12+
* Adds padding to binary/hex string representation
1313
*
14-
* @param {string} str - string represention (binary/hex)
14+
* @param {string} str - string representation (binary/hex)
1515
* @param {int} bits - total number of bits wanted
16-
* @return {string} - string represention padding with empty (0) bits
16+
* @return {string} - string representation padding with empty (0) bits
1717
*
1818
* @example
1919
* pad("10011", 8); // "00010011"

Hashes/SHA256.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const K = [
2020
]
2121

2222
/**
23-
* Adds padding to binary/hex string represention
23+
* Adds padding to binary/hex string representation
2424
*
25-
* @param {string} str - string represention (binary/hex)
25+
* @param {string} str - string representation (binary/hex)
2626
* @param {int} bits - total number of bits wanted
27-
* @return {string} - string represention padding with empty (0) bits
27+
* @return {string} - string representation padding with empty (0) bits
2828
*
2929
* @example
3030
* pad("10011", 8); // "00010011"
@@ -56,7 +56,7 @@ function chunkify (str, size) {
5656
}
5757

5858
/**
59-
* Rotates string represention of bits to th left
59+
* Rotates string representation of bits to th left
6060
*
6161
* @param {string} bits - string representation of bits
6262
* @param {int} turns - number of rotations to make

Linear-Algebra/src/la_lib.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let LinearAlgebra;
2626
if (N === comps.length) {
2727
this.components = comps
2828
} else {
29-
throw new Error('Vector: invalide size!')
29+
throw new Error('Vector: invalid size!')
3030
}
3131
}
3232
} // end of constructor

Maths/BinaryExponentiationRecursive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Modified from:
33
https://github.com/TheAlgorithms/Python/blob/master/maths/binary_exponentiation.py
44
5-
Explaination:
5+
Explanation:
66
https://en.wikipedia.org/wiki/Exponentiation_by_squaring
77
*/
88

Maths/CheckKishnamurthyNumber.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
Problem statement and Explanation : https://www.geeksforgeeks.org/check-if-a-number-is-a-krishnamurthy-number-or-not-2/
33
4-
krishnamurthy number is a number the sum of the all fectorial of the all dights is equal to the number itself.
4+
krishnamurthy number is a number the sum of the all factorial of the all dights is equal to the number itself.
55
145 => 1! + 4! + 5! = 1 + 24 + 120 = 145
66
*/
77

8-
// factorail utility method.
8+
// factorial utility method.
99
const factorial = (n) => {
1010
let fact = 1
1111
while (n !== 0) {
@@ -18,7 +18,7 @@ const factorial = (n) => {
1818
/**
1919
* krishnamurthy number is a number the sum of the factorial of the all dights is equal to the number itself.
2020
* @param {Number} number a number for checking is krishnamurthy number or not.
21-
* @returns return correspond boolean vlaue, if the number is krishnamurthy number return `true` else return `false`.
21+
* @returns return correspond boolean value, if the number is krishnamurthy number return `true` else return `false`.
2222
* @example 145 => 1! + 4! + 5! = 1 + 24 + 120 = 145
2323
*/
2424
const CheckKishnamurthyNumber = (number) => {

Maths/DigitSum.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const digitSum = (num) => {
55
// sum will store sum of digits of a number
66
let sum = 0
7-
// while will run untill num become 0
7+
// while will run until num become 0
88
while (num) {
99
sum += num % 10
1010
num = parseInt(num / 10)

Maths/ModularBinaryExponentiationRecursive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Modified from:
33
https://github.com/TheAlgorithms/Python/blob/master/maths/binary_exp_mod.py
44
5-
Explaination:
5+
Explanation:
66
https://en.wikipedia.org/wiki/Exponentiation_by_squaring
77
*/
88

Maths/PiApproximationMonteCarlo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Wikipedia: https://en.wikipedia.org/wiki/Monte_Carlo_method
2-
// Video Explaination: https://www.youtube.com/watch?v=ELetCV_wX_c
2+
// Video Explanation: https://www.youtube.com/watch?v=ELetCV_wX_c
33

44
const piEstimation = (iterations = 100000) => {
55
let circleCounter = 0

Maths/SieveOfEratosthenes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const sieveOfEratosthenes = (n) => {
22
/*
33
* Calculates prime numbers till a number n
44
* :param n: Number upto which to calculate primes
5-
* :return: A boolean list contaning only primes
5+
* :return: A boolean list containing only primes
66
*/
77
const primes = new Array(n + 1)
88
primes.fill(true) // set all as true initially

Maths/SumOfDigits.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function sumOfDigitsUsingString (number) {
1717
}
1818

1919
/*
20-
The input is divided by 10 in each iteraction, till the input is equal to 0
20+
The input is divided by 10 in each iteration, till the input is equal to 0
2121
The sum of all the digits is returned (The res variable acts as a collector, taking the remainders on each iteration)
2222
*/
2323
function sumOfDigitsUsingLoop (number) {

Maths/test/Fibonacci.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import {
66
FibonacciMatrixExpo
77
} from '../Fibonacci'
88

9-
describe('Fibonanci', () => {
10-
it('should return an array of numbers for FibonnaciIterative', () => {
9+
describe('Fibonacci', () => {
10+
it('should return an array of numbers for FibonacciIterative', () => {
1111
expect(FibonacciIterative(5)).toEqual(
1212
expect.arrayContaining([1, 1, 2, 3, 5])
1313
)
1414
})
1515

16-
it('should return an array of numbers for FibonnaciRecursive', () => {
16+
it('should return an array of numbers for FibonacciRecursive', () => {
1717
expect(FibonacciRecursive(5)).toEqual(
1818
expect.arrayContaining([1, 1, 2, 3, 5])
1919
)
2020
})
2121

22-
it('should return number for FibonnaciRecursiveDP', () => {
22+
it('should return number for FibonacciRecursiveDP', () => {
2323
expect(FibonacciRecursiveDP(5)).toBe(5)
2424
})
2525

@@ -29,7 +29,7 @@ describe('Fibonanci', () => {
2929
)
3030
})
3131

32-
it('should return number for FibonnaciMatrixExpo', () => {
32+
it('should return number for FibonacciMatrixExpo', () => {
3333
expect(FibonacciMatrixExpo(0)).toBe(0)
3434
expect(FibonacciMatrixExpo(1)).toBe(1)
3535
expect(FibonacciMatrixExpo(2)).toBe(1)

Project-Euler/Problem014.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const getCollatzSequenceLength = (num, seqLength) => {
3333

3434
const findLongestCollatzSequence = () => {
3535
let startingPointForLargestSequence = 1
36-
let largestSequnceLength = 1
36+
let largestSequenceLength = 1
3737
for (let i = 2; i < 1000000; i++) {
3838
const currentSequenceLength = getCollatzSequenceLength(i, 1)
39-
if (currentSequenceLength > largestSequnceLength) {
39+
if (currentSequenceLength > largestSequenceLength) {
4040
startingPointForLargestSequence = i
41-
largestSequnceLength = currentSequenceLength
41+
largestSequenceLength = currentSequenceLength
4242
}
4343
}
4444
return startingPointForLargestSequence

0 commit comments

Comments
 (0)