TheAlgorithms /Go
Algorithms and Data Structures implemented in Go for beginners, following best practices.
★ 18,253⑂ 2,828
18,253
stars
+7+10+22
2,828
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions
README
The Algorithms - Go !godocmd ! !update_directory_md Algorithms implemented in Go (for education) The repository is a collection of open-source implementation of a variety of algorithms implemented in Go and licensed under MIT License. Read our Contribution Guidelines before you contribute. List of Algorithms Packages: ahocorasick --- Functions: 1. Advanced: Advanced Function performing the Advanced Aho-Corasick algorithm. Finds and prints occurrences of each pattern. 2. AhoCorasick: AhoCorasick Function performing the Basic Aho-Corasick algorithm. Finds and prints occurrences of each pattern. 3. ArrayUnion: ArrayUnion Concats two arrays of int's into one. 4. BoolArrayCapUp: BoolArrayCapUp Dynamically increases an array size of bool's by 1. 5. BuildAc: Functions that builds Aho Corasick automaton. 6. BuildExtendedAc: BuildExtendedAc Functions that builds extended Aho Corasick automaton. 7. ComputeAlphabet: ComputeAlphabet Function that returns string of all the possible characters in given patterns. 8. ConstructTrie: ConstructTrie Function that constructs Trie as an automaton for a set of reversed & trimmed strings. 9. Contains: Contains Returns 'true' if array of int's 's' contains int 'e', 'false' otherwise. 10. CreateNewState: CreateNewState Automaton function for creating a new state 'state'. 11. CreateTransition: CreateTransition Creates a transition for function σ(state,letter) = end. 12. GetParent: GetParent Function that finds the first previous state of a state and returns it. Used for trie where there is only one parent. 13. GetTransition: GetTransition Returns ending state for transition σ(fromState,overChar), '-1' if there is none. 14. GetWord: GetWord Function that returns word found in text 't' at position range 'begin' to 'end'. 15. IntArrayCapUp: IntArrayCapUp Dynamically increases an array size of int's by 1. 16. StateExists: StateExists Checks if state 'state' exists. Returns 'true' if it does, 'false' otherwise. --- Types 1. Result: No description provided. --- armstrong --- Functions: 1. IsArmstrong: No description provided. --- binary --- Package binary describes algorithms that use binary operations for different calculations. --- Functions: 1. Abs: 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. 2. BitCounter: BitCounter - The function returns the number of set bits for an unsigned integer number 3. FastInverseSqrt: FastInverseSqrt assumes that argument is always positive, and it does not deal with negative numbers. The "magic" number 0x5f3759df is hex for 159