Skip to content

Commit

Permalink
fixed some spellings
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav-bohr committed Oct 5, 2021
1 parent 199d263 commit 1589263
Show file tree
Hide file tree
Showing 41 changed files with 80 additions and 80 deletions.
4 changes: 2 additions & 2 deletions Backtracking/SumOfSubset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Given an ordered set W of non-negative integers and a value K,
* determine all possible subsets from the given set W whose sum
* of its elemets equals to the given value K.
* of its elements equals to the given value K.
*
* More info: https://www.geeksforgeeks.org/subset-sum-backtracking-4/
*/
Expand Down Expand Up @@ -53,7 +53,7 @@ const sumOfSubset = (set, subset, setindex, sum, targetSum) => {
targetSum
)

// Concat the recursive result with current result arary
// Concat the recursive result with current result array
results = [...results, ...subsetResult]
})

Expand Down
4 changes: 2 additions & 2 deletions Bit-Manipulation/BinaryCountSetBits.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
license: GPL-3.0 or later
This script will find number of 1's
in binary representain of given number
in binary representation of given number
*/

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

Expand Down
2 changes: 1 addition & 1 deletion Ciphers/KeyFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function keyFinder (str) { // str is used to get the input of encrypted string
// console.log( k + outStrElement + wordBank[i] );//debug

// this part need to be optimize with the calculation of the number of occurrence of word's probabilities
// linked list will be used in the next stage of development to calculate the number of occurace of the key
// linked list will be used in the next stage of development to calculate the number of occurrence of the key
if (wordBank[i] === outStrElement) {
return k // return the key number if founded
}
Expand Down
4 changes: 2 additions & 2 deletions Conversions/DateDayDifference.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const DateDayDifference = (date1, date2) => {
if (typeof date1 !== 'string' && typeof date2 !== 'string') {
return new TypeError('Argument is not a string.')
}
// extarct the first date
// extract the first date
const [firstDateDay, firstDateMonth, firstDateYear] = date1.split('/').map((ele) => Number(ele))
// extarct the second date
// extract the second date
const [secondDateDay, secondDateMonth, secondDateYear] = date2.split('/').map((ele) => Number(ele))
// check the both data are valid or not.
if (firstDateDay < 0 || firstDateDay > 31 ||
Expand Down
2 changes: 1 addition & 1 deletion Conversions/DateToDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const DateToDay = (date) => {
if (typeof date !== 'string') {
return new TypeError('Argument is not a string.')
}
// extarct the date
// extract the date
const [day, month, year] = date.split('/').map((x) => Number(x))
// check the data are valid or not.
if (day < 0 || day > 31 || month > 12 || month < 0) {
Expand Down
2 changes: 1 addition & 1 deletion Conversions/RailwayTimeConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
want some changes in hour value.
Input Formate -> 07:05:45PM
Output Fromate -> 19:05:45
Output Formate -> 19:05:45
Problem & Explanation Source : https://www.mathsisfun.com/time.html
*/
Expand Down
2 changes: 1 addition & 1 deletion Conversions/TitleCaseConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @returns {String}
*/
const TitleCaseConversion = (inputString) => {
// Extact all space seprated string.
// Extract all space separated string.
const stringCollections = inputString.split(' ').map(word => {
let firstChar = ''
// Get a character code by the use charCodeAt method.
Expand Down
2 changes: 1 addition & 1 deletion Data-Structures/Linked-List/CycleDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function main () {
Note:
* While Solving the problem in given link below, don't use main() function.
* Just use only the code inside main() function.
* The purpose of using main() function here is to aviod global variables.
* The purpose of using main() function here is to avoid global variables.
Link for the Problem: https://leetcode.com/problems/linked-list-cycle/
*/
Expand Down
2 changes: 1 addition & 1 deletion Data-Structures/Linked-List/RotateListRight.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function main () {
Note:
* While Solving the problem in given link below, don't use main() function.
* Just use only the code inside main() function.
* The purpose of using main() function here is to aviod global variables.
* The purpose of using main() function here is to avoid global variables.
Link for the Problem: https://leetcode.com/problems/rotate-list/
*/
Expand Down
6 changes: 3 additions & 3 deletions Data-Structures/Tree/AVLTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let utils;
*/
const AVLTree = (function () {
function _avl (comp) {
/** @public compartor function */
/** @public comparator function */
this._comp = undefined
if (comp !== undefined) {
this._comp = comp
Expand Down Expand Up @@ -119,7 +119,7 @@ const AVLTree = (function () {
node._right = rightRotate(node._right)
return leftRotate(node) // Right Left
}
return leftRotate(node) // Rigth Right
return leftRotate(node) // Right Right
}
// implement avl tree insertion
const insert = function (root, val, tree) {
Expand Down Expand Up @@ -202,7 +202,7 @@ const AVLTree = (function () {
return true
}
/**
* TO check is a particluar element exists or not
* TO check is a particular element exists or not
* @param {any} _val
* @returns {Boolean} exists or not
*/
Expand Down
6 changes: 3 additions & 3 deletions Data-Structures/Tree/Trie.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function Trie () {
this.root = new TrieNode(null, null)
}

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

// Delete no of occurences specified
// Delete no of occurrences specified
if (child.count >= count) child.count -= count
else child.count = 0

// If some occurences are left we dont delete it or else
// If some occurrences are left we dont delete it or else
// if the object forms some other objects prefix we dont delete it
// For checking an empty object
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
Expand Down
2 changes: 1 addition & 1 deletion Dynamic-Programming/KadaneAlgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function KadaneAlgo (array) {
}
}
return maxSum
// This function returns largest sum contigous sum in a array
// This function returns largest sum contiguous sum in a array
}
function main () {
const myArray = [1, 2, 3, 4, -6]
Expand Down
2 changes: 1 addition & 1 deletion Dynamic-Programming/SieveOfEratosthenes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function sieveOfEratosthenes (n) {
/*
* Calculates prime numbers till a number n
* :param n: Number upto which to calculate primes
* :return: A boolean list contaning only primes
* :return: A boolean list containing only primes
*/
const primes = new Array(n + 1)
primes.fill(true) // set all as true initially
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { longestPalindromeSubsequence } from '../LongestPalindromicSubsequence'

describe('LongestPalindromicSubsequence', () => {
it('expects to return 1 as longest pallindromic subsequence', () => {
it('expects to return 1 as longest palindromic subsequence', () => {
expect(longestPalindromeSubsequence('abcdefgh')).toBe(1)
})

it('expects to return 4 as longest pallindromic subsequence', () => {
it('expects to return 4 as longest palindromic subsequence', () => {
expect(longestPalindromeSubsequence('bbbab')).toBe(4)
})

it('expects to return 2 as longest pallindromic subsequence', () => {
it('expects to return 2 as longest palindromic subsequence', () => {
expect(longestPalindromeSubsequence('cbbd')).toBe(2)
})

it('expects to return 7 as longest pallindromic subsequence', () => {
it('expects to return 7 as longest palindromic subsequence', () => {
expect(longestPalindromeSubsequence('racexyzcxar')).toBe(7)
})
})
2 changes: 1 addition & 1 deletion Geometry/ConvexHullGraham.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function convexHull (points) {
points.sort(compare)
const p1 = points[0]; const p2 = points[pointsLen - 1]

// Divide Hull in two halfs
// Divide Hull in two halves
const upperPoints = []; const lowerPoints = []

upperPoints.push(p1)
Expand Down
2 changes: 1 addition & 1 deletion Graphs/Dijkstra.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Author: Samarth Jain
* Dijkstra's Algorithm implementation in JavaScript
* Dijkstra's Algorithm calculates the minimum distance between two nodes.
* It is used to find the shortes path.
* It is used to find the shortest path.
* It uses graph data structure.
*/

Expand Down
4 changes: 2 additions & 2 deletions Graphs/NumberOfIslands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
https://dev.to/rattanakchea/amazons-interview-question-count-island-21h6
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.
two a dimensial grid map
each element is going to represent a peice of land
a two dimensional grid map
each element is going to represent a piece of land
1 is land,
0 is water
output a number which is the number of islands
Expand Down
6 changes: 3 additions & 3 deletions Hashes/SHA1.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
const CHAR_SIZE = 8

/**
* Adds padding to binary/hex string represention
* Adds padding to binary/hex string representation
*
* @param {string} str - string represention (binary/hex)
* @param {string} str - string representation (binary/hex)
* @param {int} bits - total number of bits wanted
* @return {string} - string represention padding with empty (0) bits
* @return {string} - string representation padding with empty (0) bits
*
* @example
* pad("10011", 8); // "00010011"
Expand Down
8 changes: 4 additions & 4 deletions Hashes/SHA256.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const K = [
]

/**
* Adds padding to binary/hex string represention
* Adds padding to binary/hex string representation
*
* @param {string} str - string represention (binary/hex)
* @param {string} str - string representation (binary/hex)
* @param {int} bits - total number of bits wanted
* @return {string} - string represention padding with empty (0) bits
* @return {string} - string representation padding with empty (0) bits
*
* @example
* pad("10011", 8); // "00010011"
Expand Down Expand Up @@ -56,7 +56,7 @@ function chunkify (str, size) {
}

/**
* Rotates string represention of bits to th left
* Rotates string representation of bits to th left
*
* @param {string} bits - string representation of bits
* @param {int} turns - number of rotations to make
Expand Down
2 changes: 1 addition & 1 deletion Linear-Algebra/src/la_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let LinearAlgebra;
if (N === comps.length) {
this.components = comps
} else {
throw new Error('Vector: invalide size!')
throw new Error('Vector: invalid size!')
}
}
} // end of constructor
Expand Down
2 changes: 1 addition & 1 deletion Maths/BinaryExponentiationRecursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Modified from:
https://github.com/TheAlgorithms/Python/blob/master/maths/binary_exponentiation.py
Explaination:
Explanation:
https://en.wikipedia.org/wiki/Exponentiation_by_squaring
*/

Expand Down
6 changes: 3 additions & 3 deletions Maths/CheckKishnamurthyNumber.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Problem statement and Explanation : https://www.geeksforgeeks.org/check-if-a-number-is-a-krishnamurthy-number-or-not-2/
krishnamurthy number is a number the sum of the all fectorial of the all dights is equal to the number itself.
krishnamurthy number is a number the sum of the all factorial of the all dights is equal to the number itself.
145 => 1! + 4! + 5! = 1 + 24 + 120 = 145
*/

// factorail utility method.
// factorial utility method.
const factorial = (n) => {
let fact = 1
while (n !== 0) {
Expand All @@ -18,7 +18,7 @@ const factorial = (n) => {
/**
* krishnamurthy number is a number the sum of the factorial of the all dights is equal to the number itself.
* @param {Number} number a number for checking is krishnamurthy number or not.
* @returns return correspond boolean vlaue, if the number is krishnamurthy number return `true` else return `false`.
* @returns return correspond boolean value, if the number is krishnamurthy number return `true` else return `false`.
* @example 145 => 1! + 4! + 5! = 1 + 24 + 120 = 145
*/
const CheckKishnamurthyNumber = (number) => {
Expand Down
2 changes: 1 addition & 1 deletion Maths/DigitSum.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const digitSum = (num) => {
// sum will store sum of digits of a number
let sum = 0
// while will run untill num become 0
// while will run until num become 0
while (num) {
sum += num % 10
num = parseInt(num / 10)
Expand Down
2 changes: 1 addition & 1 deletion Maths/ModularBinaryExponentiationRecursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Modified from:
https://github.com/TheAlgorithms/Python/blob/master/maths/binary_exp_mod.py
Explaination:
Explanation:
https://en.wikipedia.org/wiki/Exponentiation_by_squaring
*/

Expand Down
2 changes: 1 addition & 1 deletion Maths/PiApproximationMonteCarlo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Wikipedia: https://en.wikipedia.org/wiki/Monte_Carlo_method
// Video Explaination: https://www.youtube.com/watch?v=ELetCV_wX_c
// Video Explanation: https://www.youtube.com/watch?v=ELetCV_wX_c

const piEstimation = (iterations = 100000) => {
let circleCounter = 0
Expand Down
2 changes: 1 addition & 1 deletion Maths/SieveOfEratosthenes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const sieveOfEratosthenes = (n) => {
/*
* Calculates prime numbers till a number n
* :param n: Number upto which to calculate primes
* :return: A boolean list contaning only primes
* :return: A boolean list containing only primes
*/
const primes = new Array(n + 1)
primes.fill(true) // set all as true initially
Expand Down
2 changes: 1 addition & 1 deletion Maths/SumOfDigits.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function sumOfDigitsUsingString (number) {
}

/*
The input is divided by 10 in each iteraction, till the input is equal to 0
The input is divided by 10 in each iteration, till the input is equal to 0
The sum of all the digits is returned (The res variable acts as a collector, taking the remainders on each iteration)
*/
function sumOfDigitsUsingLoop (number) {
Expand Down
10 changes: 5 additions & 5 deletions Maths/test/Fibonacci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import {
FibonacciMatrixExpo
} from '../Fibonacci'

describe('Fibonanci', () => {
it('should return an array of numbers for FibonnaciIterative', () => {
describe('Fibonacci', () => {
it('should return an array of numbers for FibonacciIterative', () => {
expect(FibonacciIterative(5)).toEqual(
expect.arrayContaining([1, 1, 2, 3, 5])
)
})

it('should return an array of numbers for FibonnaciRecursive', () => {
it('should return an array of numbers for FibonacciRecursive', () => {
expect(FibonacciRecursive(5)).toEqual(
expect.arrayContaining([1, 1, 2, 3, 5])
)
})

it('should return number for FibonnaciRecursiveDP', () => {
it('should return number for FibonacciRecursiveDP', () => {
expect(FibonacciRecursiveDP(5)).toBe(5)
})

Expand All @@ -29,7 +29,7 @@ describe('Fibonanci', () => {
)
})

it('should return number for FibonnaciMatrixExpo', () => {
it('should return number for FibonacciMatrixExpo', () => {
expect(FibonacciMatrixExpo(0)).toBe(0)
expect(FibonacciMatrixExpo(1)).toBe(1)
expect(FibonacciMatrixExpo(2)).toBe(1)
Expand Down
6 changes: 3 additions & 3 deletions Project-Euler/Problem014.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const getCollatzSequenceLength = (num, seqLength) => {

const findLongestCollatzSequence = () => {
let startingPointForLargestSequence = 1
let largestSequnceLength = 1
let largestSequenceLength = 1
for (let i = 2; i < 1000000; i++) {
const currentSequenceLength = getCollatzSequenceLength(i, 1)
if (currentSequenceLength > largestSequnceLength) {
if (currentSequenceLength > largestSequenceLength) {
startingPointForLargestSequence = i
largestSequnceLength = currentSequenceLength
largestSequenceLength = currentSequenceLength
}
}
return startingPointForLargestSequence
Expand Down
Loading

0 comments on commit 1589263

Please sign in to comment.