Skip to content

Commit 93434be

Browse files
authored
fix: spellcheck (TheAlgorithms#527)
1 parent 251f340 commit 93434be

File tree

4 files changed

+24
-55
lines changed

4 files changed

+24
-55
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
9191

9292
1. [`Abs`](./math/binary/abs.go#L10): Abs returns absolute value using binary operation Principle of operation: 1) Get the mask by right shift by the base 2) Base is the size of an integer variable in bits, for example, for int32 it will be 32, for int64 it will be 64 3) For negative numbers, above step sets mask as 1 1 1 1 1 1 1 1 and 0 0 0 0 0 0 0 0 for positive numbers. 4) Add the mask to the given number. 5) XOR of mask + n and mask gives the absolute value.
9393
2. [`BitCounter`](./math/binary/bitcounter.go#L11): BitCounter - The function returns the number of set bits for an unsigned integer number
94-
3. [`IsPowerOfTwo`](./math/binary/checkisnumberpoweroftwo.go#L19): IsPowerOfTwo This function uses the fact that powers of 2 are represented like 10...0 in binary, and numbers one less than the power of 2 are represented like 11...1. Therefore, using the and function: 10...0 & 01...1 00...0 -> 0 This is also true for 0, which is not a power of 2, for which we have to add and extra condition.
95-
4. [`IsPowerOfTwoLeftShift`](./math/binary/checkisnumberpoweroftwo.go#L26): IsPowerOfTwoLeftShift This function takes advantage of the fact that left shifting a number by 1 is equivalent to multiplying by 2. For example, binary 00000001 when shifted by 3 becomes 00001000, which in decimal system is 8 or = 2 * 2 * 2
94+
3. [`IsPowerOfTwo`](./math/binary/checkisnumberpoweroftwo.go#L21): IsPowerOfTwo This function uses the fact that powers of 2 are represented like 10...0 in binary, and numbers one less than the power of 2 are represented like 11...1. Therefore, using the and function: 10...0 & 01...1 00...0 -> 0 This is also true for 0, which is not a power of 2, for which we have to add and extra condition.
95+
4. [`IsPowerOfTwoLeftShift`](./math/binary/checkisnumberpoweroftwo.go#L28): IsPowerOfTwoLeftShift This function takes advantage of the fact that left shifting a number by 1 is equivalent to multiplying by 2. For example, binary 00000001 when shifted by 3 becomes 00001000, which in decimal system is 8 or = 2 * 2 * 2
9696
5. [`LogBase2`](./math/binary/logarithm.go#L7): LogBase2 Finding the exponent of n = 2**x using bitwise operations (logarithm in base 2 of n) [See more](https://en.wikipedia.org/wiki/Logarithm)
9797
6. [`MeanUsingAndXor`](./math/binary/arithmeticmean.go#L12): MeanUsingAndXor This function finds arithmetic mean using "AND" and "XOR" operations
9898
7. [`MeanUsingRightShift`](./math/binary/arithmeticmean.go#L17): MeanUsingRightShift This function finds arithmetic mean using right shift
@@ -238,7 +238,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
238238

239239
---
240240

241-
##### Package diffiehellman implements Deffie Hellman Key Exchange Algorithm for more information watch : https://www.youtube.com/watch?v=NmM9HA2MQGI
241+
##### Package diffiehellman implements Diffie-Hellman Key Exchange Algorithm for more information watch : https://www.youtube.com/watch?v=NmM9HA2MQGI
242242

243243
---
244244
##### Functions:
@@ -501,7 +501,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
501501

502502
---
503503

504-
##### Package linkedlist demonstates different implementations on linkedlists.
504+
##### Package linkedlist demonstrates different implementations on linkedlists.
505505

506506
---
507507
##### Functions:
@@ -552,8 +552,11 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
552552
3. [`FindKthMax`](./math/kthnumber.go#L11): FindKthMax returns the kth large element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. NOTE: The `nums` slice gets mutated in the process.
553553
4. [`FindKthMin`](./math/kthnumber.go#L19): FindKthMin returns kth small element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. NOTE: The `nums` slice gets mutated in the process.
554554
5. [`IsPowOfTwoUseLog`](./math/checkisnumberpoweroftwo.go#L10): IsPowOfTwoUseLog This function checks if a number is a power of two using the logarithm. The limiting degree can be from 0 to 63. See alternatives in the binary package.
555-
6. [`Phi`](./math/eulertotient.go#L5): Phi is the Euler totient function. This function computes the number of numbers less then n that are coprime with n.
556-
7. [`Sin`](./math/sin.go#L9): Sin returns the sine of the radian argument x. [See more](https://en.wikipedia.org/wiki/Sine_and_cosine)
555+
6. [`Mean`](./math/mean.go#L7): No description provided.
556+
7. [`Median`](./math/median.go#L12): No description provided.
557+
8. [`Mode`](./math/mode.go#L19): No description provided.
558+
9. [`Phi`](./math/eulertotient.go#L5): Phi is the Euler totient function. This function computes the number of numbers less then n that are coprime with n.
559+
10. [`Sin`](./math/sin.go#L9): Sin returns the sine of the radian argument x. [See more](https://en.wikipedia.org/wiki/Sine_and_cosine)
557560

558561
---
559562
</details><details>
@@ -623,7 +626,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
623626
---
624627
##### Functions:
625628

626-
1. [`IsBalanced`](./other/nested/nestedbrackets.go#L20): IsBalanced returns true if provided input string is properly nested. Input is a sequence of brackets: '(', ')', '[', ']', '{', '}'. A sequence of brackets `s` is considered properly nested if any of the following conditions are true: - `s` is empty; - `s` has the form (U) or [U] or {U} where U is a properly nested string; - `s` has the form VW where V and W are properly nested strings. For example, the string "()()[()]" is properly nested but "[(()]" is not. **Note** Providing characters other then brackets would return false, despite brackets sequence in the string. Make sure to filter input before usage.
629+
1. [`IsBalanced`](./other/nested/nestedbrackets.go#L20): IsBalanced returns true if provided input string is properly nested. Input is a sequence of brackets: '(', ')', '[', ']', '{', '}'. A sequence of brackets `s` is considered properly nested if any of the following conditions are true: - `s` is empty; - `s` has the form (U) or [U] or {U} where U is a properly nested string; - `s` has the form VW where V and W are properly nested strings. For example, the string "()()[()]" is properly nested but "[(()]" is not. **Note** Providing characters other then brackets would return false, despite brackets sequence in the string. Make sure to filter input before usage.
627630

628631
---
629632
</details><details>
@@ -765,7 +768,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
765768

766769
##### Functions:
767770

768-
1. [`Distance`](./math/pythagoras/pythagoras.go#L15): Distance calculates the distance between to vectors with the Pythagoras theorem
771+
1. [`Distance`](./math/pythagoras/pythagoras.go#L15): Distance calculates the distance between to vectors with the Pythagoras theorem
769772

770773
---
771774
##### Types
@@ -868,7 +871,7 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
868871

869872
---
870873

871-
##### Package sort a package for demonstrating sorting algorithms in Go
874+
##### Package sort a package for demonstrating sorting algorithms in Go Package sort Patience sorting is a sorting algorithm inspired by the card game patience. For more details check out those links below here: GeeksForGeeks article : https://www.geeksforgeeks.org/patience-sorting/ Wikipedia article: https://en.wikipedia.org/wiki/Patience_sorting authors [guuzaa](https://github.com/guuzaa) see patiencesort.go
872875

873876
---
874877
##### Functions:
@@ -883,13 +886,14 @@ Read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
883886
8. [`Merge`](./sort/mergesort.go#L40): Merge Perform merge sort on a slice
884887
9. [`MergeIter`](./sort/mergesort.go#L54): No description provided.
885888
10. [`Partition`](./sort/quicksort.go#L12): No description provided.
886-
11. [`Pigeonhole`](./sort/pigeonholesort.go#L12): Pigeonhole sorts a slice using pigeonhole sorting algorithm.
887-
12. [`Quicksort`](./sort/quicksort.go#L39): Quicksort Sorts the entire array
888-
13. [`QuicksortRange`](./sort/quicksort.go#L26): QuicksortRange Sorts the specified range within the array
889-
14. [`RadixSort`](./sort/radixsort.go#L35): No description provided.
890-
15. [`Selection`](./sort/selectionsort.go#L5): No description provided.
891-
16. [`Shell`](./sort/shellsort.go#L5): No description provided.
892-
17. [`Simple`](./sort/simplesort.go#L13): No description provided.
889+
11. [`Patience`](./sort/patiencesort.go#L13): No description provided.
890+
12. [`Pigeonhole`](./sort/pigeonholesort.go#L12): Pigeonhole sorts a slice using pigeonhole sorting algorithm.
891+
13. [`Quicksort`](./sort/quicksort.go#L39): Quicksort Sorts the entire array
892+
14. [`QuicksortRange`](./sort/quicksort.go#L26): QuicksortRange Sorts the specified range within the array
893+
15. [`RadixSort`](./sort/radixsort.go#L35): No description provided.
894+
16. [`Selection`](./sort/selectionsort.go#L5): No description provided.
895+
17. [`Shell`](./sort/shellsort.go#L5): No description provided.
896+
18. [`Simple`](./sort/simplesort.go#L13): No description provided.
893897

894898
---
895899
##### Types

other/password/generator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Generate(minLength int, maxLength int) string {
2525

2626
newPassword := make([]byte, intLength)
2727
randomData := make([]byte, intLength+intLength/4)
28-
clen := byte(len(chars))
28+
charLen := byte(len(chars))
2929
maxrb := byte(256 - (256 % len(chars)))
3030
i := 0
3131
for {
@@ -36,7 +36,7 @@ func Generate(minLength int, maxLength int) string {
3636
if c >= maxrb {
3737
continue
3838
}
39-
newPassword[i] = chars[c%clen]
39+
newPassword[i] = chars[c%charLen]
4040
i++
4141
if i == intLength {
4242
return string(newPassword)

structure/linkedlist/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// Package linkedlist demonstates different implementations on linkedlists.
1+
// Package linkedlist demonstrates different implementations on linkedlists.
22
package linkedlist

structure/trie/trie_bench_test.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,15 @@ import (
66
"testing"
77
)
88

9-
// CAUTION : make sure to limit the benchamrks to 3000 iterations,
9+
// CAUTION : make sure to limit the benchmarks to 3000 iterations,
1010
// or removal will mostly process an empty Trie, giving absurd results.
1111

12-
// go test -v -bench=. -benchmem -benchtime=3000x
13-
14-
// === RUN TestTrieInsert
15-
// --- PASS: TestTrieInsert (0.00s)
16-
// === RUN TestTrieRemove
17-
// --- PASS: TestTrieRemove (0.00s)
18-
// === RUN ExampleNode
19-
// --- PASS: ExampleNode (0.00s)
20-
// goos: linux
21-
// goarch: amd64
22-
// pkg: github.com/TheAlgorithms/Go/structure/trie
23-
// BenchmarkTrie_Insert
24-
// BenchmarkTrie_Insert-8 3000 1559881 ns/op 1370334 B/op 25794 allocs/op
25-
// BenchmarkTrie_Find_non_existant
26-
// BenchmarkTrie_Find_non_existant-8 3000 59.1 ns/op 0 B/op 0 allocs/op
27-
// BenchmarkTrie_Find_existant
28-
// BenchmarkTrie_Find_existant-8 3000 238 ns/op 0 B/op 0 allocs/op
29-
// BenchmarkTrie_Remove_lazy
30-
// BenchmarkTrie_Remove_lazy-8 3000 126 ns/op 0 B/op 0 allocs/op
31-
// BenchmarkTrie_Remove_and_Compact
32-
// BenchmarkTrie_Remove_and_Compact-8 3000 213945 ns/op 0 B/op 0 allocs/op
33-
// PASS
34-
// ok github.com/TheAlgorithms/Go/structure/trie 5.355s
35-
3612
func BenchmarkTrie_Insert(b *testing.B) {
37-
38-
// prepare random words for insertion
3913
insert := make([]string, 3000)
4014
for i := 0; i < len(insert); i++ {
4115
insert[i] = fmt.Sprintf("%f", rand.Float64())
4216
}
4317

44-
// Reset timer and run benchmark for insertion
4518
b.ResetTimer()
4619
for i := 0; i < b.N; i++ {
4720
n := NewNode()
@@ -51,63 +24,55 @@ func BenchmarkTrie_Insert(b *testing.B) {
5124

5225
func BenchmarkTrie_Find_non_existant(b *testing.B) {
5326

54-
// prepare random words for insertion
5527
insert := make([]string, 3000)
5628
for i := 0; i < len(insert); i++ {
5729
insert[i] = fmt.Sprintf("%f", rand.Float64())
5830
}
5931
n := NewNode()
6032
n.Insert(insert...)
6133

62-
// Reset timer and run benchmark for finding non existing
6334
b.ResetTimer()
6435
for i := 0; i < b.N; i++ {
6536
n.Find("0.3213213244346546546546565465465") // does not exists
6637
}
6738
}
6839

6940
func BenchmarkTrie_Find_existant(b *testing.B) {
70-
// prepare and insert random words
7141
insert := make([]string, 3000)
7242
for i := 0; i < len(insert); i++ {
7343
insert[i] = fmt.Sprintf("%f", rand.Float64())
7444
}
7545
n := NewNode()
7646
n.Insert(insert...)
7747

78-
// Reset timer and run benchmark for finding existing words
7948
b.ResetTimer()
8049
for i := 0; i < b.N; i++ {
8150
n.Find(insert[i%3000]) // always exists !
8251
}
8352
}
8453

8554
func BenchmarkTrie_Remove_lazy(b *testing.B) {
86-
// prepare and insert random words
8755
insert := make([]string, 3000)
8856
for i := 0; i < len(insert); i++ {
8957
insert[i] = fmt.Sprintf("%f", rand.Float64())
9058
}
9159
n := NewNode()
9260
n.Insert(insert...)
9361

94-
// Reset timer and run benchmark for lazily removing words
9562
b.ResetTimer()
9663
for i := 0; i < b.N; i++ {
9764
n.Remove(insert[i%3000]) // exists, at least until removed ...
9865
}
9966
}
10067

10168
func BenchmarkTrie_Remove_and_Compact(b *testing.B) {
102-
// prepare and insert random words
10369
insert := make([]string, 3000)
10470
for i := 0; i < len(insert); i++ {
10571
insert[i] = fmt.Sprintf("%f", rand.Float64())
10672
}
10773
n := NewNode()
10874
n.Insert(insert...)
10975

110-
// Reset timer and run benchmark for removing words and immediately compacting
11176
b.ResetTimer()
11277
for i := 0; i < b.N; i++ {
11378
n.Remove(insert[i%3000])

0 commit comments

Comments
 (0)