Algorithms and Data Structures implemented in Go for beginners, following best practices.
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.
Advanced
: Advanced Function performing the Advanced Aho-Corasick algorithm. Finds and prints occurrences of each pattern.AhoCorasick
: AhoCorasick Function performing the Basic Aho-Corasick algorithm. Finds and prints occurrences of each pattern.ArrayUnion
: ArrayUnion Concats two arrays of int’s into one.BoolArrayCapUp
: BoolArrayCapUp Dynamically increases an array size of bool’s by 1.BuildAc
: Functions that builds Aho Corasick automaton.BuildExtendedAc
: BuildExtendedAc Functions that builds extended Aho Corasick automaton.ComputeAlphabet
: ComputeAlphabet Function that returns string of all the possible characters in given patterns.ConstructTrie
: ConstructTrie Function that constructs Trie as an automaton for a set of reversed & trimmed strings.Contains
: Contains Returns ‘true’ if array of int’s ‘s’ contains int ‘e’, ‘false’ otherwise.CreateNewState
: CreateNewState Automaton function for creating a new state ‘state’.CreateTransition
: CreateTransition Creates a transition for function σ(state,letter) = end.GetParent
: GetParent Function that finds the first previous state of a state and returns it. Used for trie where there is only one parent.GetTransition
: GetTransition Returns ending state for transition σ(fromState,overChar), ‘-1’ if there is none.GetWord
: GetWord Function that returns word found in text ‘t’ at position range ‘begin’ to ‘end’.IntArrayCapUp
: IntArrayCapUp Dynamically increases an array size of int’s by 1.StateExists
: StateExists Checks if state ‘state’ exists. Returns ‘true’ if it does, ‘false’ otherwise.Result
: No description provided.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.BitCounter
: BitCounter - The function returns the number of set bits for an unsigned integer numberFastInverseSqrt
: FastInverseSqrt assumes that argument is always positive, and it does not deal with negative numbers. The “magic” number 0x5f3759df is hex for 1597463007 in decimals. The math.Float32bits is alias to *(*uint32)(unsafe.Pointer(&f)) and math.Float32frombits is to *(*float32)(unsafe.Pointer(&b)).IsPowerOfTwo
: 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.IsPowerOfTwoLeftShift
: 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 * 2LogBase2
: LogBase2 Finding the exponent of n = 2**x using bitwise operations (logarithm in base 2 of n) See moreMeanUsingAndXor
: MeanUsingAndXor This function finds arithmetic mean using “AND” and “XOR” operationsMeanUsingRightShift
: MeanUsingRightShift This function finds arithmetic mean using right shiftReverseBits
: ReverseBits This function initialized the result by 0 (all bits 0) and process the given number starting from its least significant bit. If the current bit is 1, set the corresponding most significant bit in the result and finally move on to the next bit in the input number. Repeat this till all its bits are processed.SequenceGrayCode
: SequenceGrayCode The function generates an “Gray code” sequence of length nSqrt
: No description provided.XorSearchMissingNumber
: XorSearchMissingNumber This function finds a missing number in a sequenceNewLRU
: NewLRU represent initiate lru cache with capacityNewLFU
: NewLFU represent initiate lfu cache with capacityGet
: Get the value by key from LFU cachePut
: Put the key and value in LFU cacheDecrypt
: Decrypt decrypts by left shift of “key” each character of “input”Encrypt
: Encrypt encrypts by right shift of “key” each character of “input”FuzzCaesar
: No description provided.CRC8
: CRC8 calculates CRC8 checksum of the given data.Luhn
: Luhn validates the provided data using the Luhn algorithm.CRCModel
: No description provided.BipartiteCheck
: basically tries to color the graph in two colors if each edge connects 2 differently colored nodes the graph can be considered bipartiteGraph
: No description provided.Start
: Start …Combinations
: No description provided.HuffDecode
: HuffDecode recursively decodes the binary code in, by traversing the Huffman compression tree pointed by root. current stores the current node of the traversing algorithm. out stores the current decoded string.HuffEncode
: HuffEncode encodes the string in by applying the mapping defined by codes.HuffEncoding
: HuffEncoding recursively traverses the Huffman tree pointed by node to obtain the map codes, that associates a rune with a slice of booleans. Each code is prefixed by prefix and left and right children are labelled with the booleans false and true, respectively.HuffTree
: HuffTree returns the root Node of the Huffman tree by compressing listfreq. The compression produces the most optimal code lengths, provided listfreq is ordered, i.e.: listfreq[i] <= listfreq[j], whenever i < j.Node
: No description provided.
SymbolFreq
: No description provided.
SymbolCountOrd
: SymbolCountOrd computes sorted symbol-frequency list of input messageBase64Decode
: Base64Decode decodes the received input base64 string into a byte slice. The implementation follows the RFC4648 standard, which is documented at https://datatracker.ietf.org/doc/html/rfc4648#section-4Base64Encode
: Base64Encode encodes the received input bytes slice into a base64 string. The implementation follows the RFC4648 standard, which is documented at https://datatracker.ietf.org/doc/html/rfc4648#section-4BinaryToDecimal
: BinaryToDecimal() function that will take Binary number as string, and return its Decimal equivalent as integer.DecimalToBinary
: DecimalToBinary() function that will take Decimal number as int, and return its Binary equivalent as string.FuzzBase64Encode
: No description provided.HEXToRGB
: HEXToRGB splits an RGB input (e.g. a color in hex format; 0xIntToRoman
: IntToRoman converts an integer value to a roman numeral string. An error is returned if the integer is not between 1 and 3999.RGBToHEX
: RGBToHEX does exactly the opposite of HEXToRGB: it combines the three components red, green and blue to an RGB value, which can be converted to e.g. HexReverse
: Reverse() function that will take string, and returns the reverse of that string.RomanToInt
: RomanToInt converts a roman numeral string to an integer. Roman numerals for numbers outside the range 1 to 3,999 will return an error. Nil or empty string return 0 with no error thrown.New
: New returns a new DoublyEndedQueue.DoublyEndedQueue
: No description provided.GenerateMutualKey
: GenerateMutualKey : generates a mutual key that can be used by only alice and bob mutualKey = (shareKey^prvKey)%primeNumberGenerateShareKey
: GenerateShareKey : generates a key using client private key , generator and primeNumber this key can be made public shareKey = (g^key)%primeNumberAbbreviation
: Returns true if it is possible to make a equals b (if b is an abbreviation of a), returns false otherwiseBin2
: Bin2 functionCoinChange
: CoinChange finds the number of possible combinations of coins of different values which can get to the target amount.CutRodDp
: CutRodDp solve the same problem using dynamic programmingCutRodRec
: CutRodRec solve the problem recursively: initial approachEditDistanceDP
: EditDistanceDP is an optimised implementation which builds on the ideas of the recursive implementation. We use dynamic programming to compute the DP table where dp[i][j] denotes the edit distance value of first[0…i-1] and second[0…j-1]. Time complexity is O(m * n) where m and n are lengths of the strings, first and second respectively.EditDistanceRecursive
: EditDistanceRecursive is a naive implementation with exponential time complexity.IsSubsetSum
: No description provided.Knapsack
: Knapsack solves knapsack problem return maxProfitLongestCommonSubsequence
: LongestCommonSubsequence functionLongestIncreasingSubsequence
: LongestIncreasingSubsequence returns the longest increasing subsequence where all elements of the subsequence are sorted in increasing orderLongestIncreasingSubsequenceGreedy
: LongestIncreasingSubsequenceGreedy is a function to find the longest increasing subsequence in a given array using a greedy approach. The dynamic programming approach is implemented alongside this one. Worst Case Time Complexity: O(nlogn) Auxiliary Space: O(n), where n is the length of the array(slice). Reference: https://www.geeksforgeeks.org/construction-of-longest-monotonically-increasing-subsequence-n-log-n/LpsDp
: LpsDp functionLpsRec
: LpsRec functionMatrixChainDp
: MatrixChainDp functionMatrixChainRec
: MatrixChainRec functionMax
: Max function - possible duplicateNthCatalanNumber
: NthCatalan returns the n-th Catalan Number Complexity: O(n²)NthFibonacci
: NthFibonacci returns the nth Fibonacci NumberTrapRainWater
: Calculate the amount of trapped rainwater between bars represented by an elevation map using dynamic programming.DynamicArray
: No description provided.Iterative
: Iterative returns the iteratively brute forced factorial of nRecursive
: Recursive This function recursively computes the factorial of a numberUsingTree
: UsingTree This function finds the factorial of a number using a binary treeFormula
: Formula This function calculates the n-th fibonacci number using the formula Attention! Tests for large values fall due to rounding error of floating point numbers, works well, only on small numbersMatrix
: Matrix This function calculates the n-th fibonacci number using the matrix method. SeeRecursive
: Recursive calculates the n-th fibonacci number recursively by adding the previous two Fibonacci numbers. This algorithm is extremely slow for bigger numbers, but provides a simpler implementation.Extended
: Extended simple extended gcdExtendedIterative
: ExtendedIterative finds and returns gcd(a, b), x, y satisfying ax + by = gcd(a, b).ExtendedRecursive
: ExtendedRecursive finds and returns gcd(a, b), x, y satisfying ax + by = gcd(a, b).Iterative
: Iterative Faster iterative version of GcdRecursive without holding up too much of the stackRecursive
: Recursive finds and returns the greatest common divisor of a given integer.TemplateBenchmarkExtendedGCD
: No description provided.TemplateBenchmarkGCD
: No description provided.TemplateTestExtendedGCD
: No description provided.TemplateTestGCD
: No description provided.GeneticString
: GeneticString generates PopulationItem based on the imputed target string, and a set of possible runes to build a string with. In order to optimise string generation additional configurations can be provided with Conf instance. Empty instance of Conf (&Conf{}) can be provided, then default values would be set. Link to the same algorithm implemented in python: https://github.com/TheAlgorithms/Python/blob/master/genetic_algorithm/basic_string.pyConf
: No description provided.
PopulationItem
: No description provided.
Result
: No description provided.
Distance
: Distance calculates the shortest distance between two points.EuclideanDistance
: EuclideanDistance returns the Euclidean distance between points in any n
dimensional Euclidean space.IsParallel
: IsParallel checks if two lines are parallel or not.IsPerpendicular
: IsPerpendicular checks if two lines are perpendicular or not.PointDistance
: PointDistance calculates the distance of a given Point from a given line. The slice should contain the coefficiet of x, the coefficient of y and the constant in the respective order.Section
: Section calculates the Point that divides a line in specific ratio. DO NOT specify the ratio in the form m:n, specify it as r, where r = m / n.Slope
: Slope calculates the slope (gradient) of a line.YIntercept
: YIntercept calculates the Y-Intercept of a line from a specific Point.EuclideanPoint
: No description provided.
Line
: No description provided.
Point
: No description provided.
ArticulationPoint
: ArticulationPoint is a function to identify articulation points in a graph. The function takes the graph as an argument and returns a boolean slice which indicates whether a vertex is an articulation point or not. Worst Case Time Complexity: O(|V| + |E|) Auxiliary Space: O(|V|) reference: https://en.wikipedia.org/wiki/Biconnected_component and https://cptalks.quora.com/Cut-Vertex-Articulation-pointBreadthFirstSearch
: BreadthFirstSearch is an algorithm for traversing and searching graph data structures. It starts at an arbitrary node of a graph, and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level. Worst-case performance O(|V|+|E|)=O(b{d})}O(|V|+|E|)=O(b{d}) Worst-case space complexity O(|V|)=O(b{d})}O(|V|)=O(b{d}) reference: https://en.wikipedia.org/wiki/Breadth-first_searchDepthFirstSearch
: No description provided.DepthFirstSearchHelper
: No description provided.FloydWarshall
: FloydWarshall Returns all pair’s shortest path using Floyd Warshall algorithmGetIdx
: No description provided.KruskalMST
: No description provided.PrimMST
: Computes the minimum spanning tree of a weighted undirected graphLowestCommonAncestor
: For each node, we will precompute its ancestor above him, its ancestor two nodes above, its ancestor four nodes above, etc. Let’s call jump[j][u]
is the 2^j
-th ancestor above the node u
with u
in range [0, numbersVertex)
, j
in range [0,MAXLOG)
. These information allow us to jump from any node to any ancestor above it in O(MAXLOG)
time.New
: Constructor functions for graphs (undirected by default)NewTree
: No description provided.NewUnionFind
: Initialise a new union find data structure with s nodesNotExist
: No description provided.Topological
: Topological assumes that graph given is valid and that its possible to get a topological ordering. constraints are array of []int{a, b}, representing an edge going from a to bEdmond-Karp
: Computes the maximum possible flow between a pair of s-t vertices in a weighted graphEdge
: No description provided.
Graph
: No description provided.
Item
: No description provided.
Query
: No description provided.
Tree
: No description provided.
TreeEdge
: No description provided.
UnionFind
: No description provided.
WeightedGraph
: No description provided.
New
: New returns a randomly generated global unique identifier.Make
: Make creates a new HashMap instance with input size and capacityNew
: New return new HashMap instanceHashMap
: No description provided.New
: New gives a new heap object.NewAny
: NewAny gives a new heap object. element can be anything, but must provide less function.Heap
: No description provided.Kmp
: Kmp Function kmp performing the Knuth-Morris-Pratt algorithm.args
: No description provided.Lcm
: Lcm returns the lcm of two numbers using the fact that lcm(a,b) * gcd(a,b) = | a * b |JosephusProblem
: https://en.wikipedia.org/wiki/Josephus_problem This is a struct-based solution for Josephus problem.NewCyclic
: Create new list.NewDoubly
: No description provided.NewNode
: Create new node.NewSingly
: NewSingly returns a new instance of a linked listCyclic
: No description provided.
Doubly
: No description provided.
Node
: No description provided.
Singly
: No description provided.
testCase
: No description provided.
Abs
: Abs returns absolute valueAliquotSum
: This function returns s(n) for given numberCombinations
: C is Binomial Coefficient function This function returns C(n, k) for given n and kCos
: Cos returns the cosine of the radian argument x. See more Based on the idea of Bhaskara approximation of cos(x)DefaultPolynomial
: DefaultPolynomial is the commonly used polynomial g(x) = (x^2 + 1) mod nFindKthMax
: 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.FindKthMin
: 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.IsAutomorphic
: No description provided.IsKrishnamurthyNumber
: IsKrishnamurthyNumber returns if the provided number n is a Krishnamurthy number or not.IsPerfectNumber
: Checks if inNumber is a perfect numberIsPowOfTwoUseLog
: 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.Lerp
: Lerp or Linear interpolation This function will return new value in ‘t’ percentage between ‘v0’ and ‘v1’LiouvilleLambda
: Lambda is the liouville function This function returns λ(n) for given numberMean
: No description provided.Median
: No description provided.Mode
: No description provided.Mu
: Mu is the Mobius function This function returns μ(n) for given numberPhi
: Phi is the Euler totient function. This function computes the number of numbers less then n that are coprime with n.PollardsRhoFactorization
: PollardsRhoFactorization is an implementation of Pollard’s rho factorization algorithm using the default parameters x = y = 2PronicNumber
: PronicNumber returns true if argument passed to the function is pronic and false otherwise.Sin
: Sin returns the sine of the radian argument x. See moreSumOfProperDivisors
: Returns the sum of proper divisors of inNumber.IsValid
: IsValid checks if the input matrix has consistent row lengths.New
: NewMatrix creates a new Matrix based on the provided arguments.NewFromElements
: NewFromElements creates a new Matrix from the given elements.Matrix
: No description provided.Bitwise
: Bitwise computes using bitwise operator the maximum of all the integer input and returns itInt
: Int is a function which returns the maximum of all the integers provided as arguments.MaxSubarraySum
: MaxSubarraySum returns the maximum subarray sumBitwise
: Bitwise This function returns the minimum integer using bit operationsInt
: Int is a function which returns the minimum of all the integers provided as arguments.Exponentiation
: Exponentiation returns base^exponent % modInverse
: Inverse Modular functionMultiply64BitInt
: Multiply64BitInt Checking if the integer multiplication overflowsIsBalanced
: 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.IsPalindrome
: No description provided.IsPalindromeRecursive
: No description provided.Parenthesis
: Parenthesis algorithm checks if every opened parenthesis is closed correctly. When parcounter is less than 0 when a closing parenthesis is detected without an opening parenthesis that surrounds it and parcounter will be 0 if all open parenthesis are closed correctly.GenerateTriangle
: GenerateTriangle This function generates a Pascal’s triangle of n linesGenerate
: Generate returns a newly generated passwordGenerateElementSet
: No description provided.Heaps
: Heap’s Algorithm for generating all permutations of n objectsNextPermutation
: A solution to find next permutation of an integer array in constant memoryMonteCarloPi
: No description provided.MonteCarloPiConcurrent
: MonteCarloPiConcurrent approximates the value of pi using the Monte Carlo method. Unlike the MonteCarloPi function (first version), this implementation uses goroutines and channels to parallelize the computation. More details on the Monte Carlo method available at https://en.wikipedia.org/wiki/Monte_Carlo_method. More details on goroutines parallelization available at https://go.dev/doc/effective_go#parallel.Spigot
: No description provided.FuzzPolybius
: No description provided.NewPolybius
: NewPolybius returns a pointer to object of Polybius. If the size of “chars” is longer than “size”, “chars” are truncated to “size”.Polybius
: No description provided.IterativePower
: IterativePower is iterative O(logn) function for pow(x, y)RecursivePower
: RecursivePower is recursive O(logn) function for pow(x, y)RecursivePower1
: RecursivePower1 is recursive O(n) function for pow(x, y)UsingLog
: No description provided.Factorize
: Factorize is a function that computes the exponents of each prime in the prime factorization of nGenerate
: Generate returns a int slice of prime numbers up to the limitGenerateChannel
: Generate generates the sequence of integers starting at 2 and sends it to the channel ch
MillerRabinDeterministic
: MillerRabinDeterministic is a Deterministic version of the Miller-Rabin test, which returns correct results for all valid int64 numbers.MillerRabinProbabilistic
: MillerRabinProbabilistic is a probabilistic test for primality of an integer based of the algorithm devised by Miller and Rabin.MillerRandomTest
: MillerRandomTest This is the intermediate step that repeats within the miller rabin primality test for better probabilitic chances of receiving the correct result with random witnesses.MillerTest
: MillerTest tests whether num is a strong probable prime to a witness. Formally: a^d ≡ 1 (mod n) or a(2r * d) ≡ -1 (mod n), 0 <= r <= sMillerTestMultiple
: MillerTestMultiple is like MillerTest but runs the test for multiple witnesses.OptimizedTrialDivision
: OptimizedTrialDivision checks primality of an integer using an optimized trial division method. The optimizations include not checking divisibility by the even numbers and only checking up to the square root of the given number.Sieve
: Sieve Sieving the numbers that are not prime from the channel - basically removing them from the channelsTrialDivision
: TrialDivision tests whether a number is prime by trying to divide it by the numbers less than it.Twin
: This function returns twin prime for given number returns (n + 2) if both n and (n + 2) are prime -1 otherwiseDistance
: Distance calculates the distance between to vectors with the Pythagoras theoremVector
: No description provided.BackQueue
: BackQueue return the Back valueDeQueue
: DeQueue it will be removed the first value that added into the listEnQueue
: EnQueue it will be added new value into our listFrontQueue
: FrontQueue return the Front valueIsEmptyQueue
: IsEmptyQueue check our list is empty or notLenQueue
: LenQueue will return the length of the queue listFuzzRot13
: No description provided.Decrypt
: Decrypt decrypts encrypted rune slice based on the RSA algorithmEncrypt
: Encrypt encrypts based on the RSA algorithm - uses modular exponentitation in math directoryFuzzRsa
: No description provided.BoyerMoore
: Implementation of boyer moore string search O(l) where l=len(text)Naive
: Implementation of naive string search O(n*m) where n=len(txt) and m=len(pattern)NewSegmentTree
: No description provided.SegmentTree
: No description provided.New
: New gives new set.Hash
: Hash hashes the input message using the sha256 hashing function, and return a 32 byte array. The implementation follows the RGC6234 standard, which is documented at https://datatracker.ietf.org/doc/html/rfc6234BinaryInsertion
: No description provided.Bogo
: No description provided.Bubble
: Bubble is a simple generic definition of Bubble sort algorithm.Bucket
: Bucket sorts a slice. It is mainly useful when input is uniformly distributed over a range.Cocktail
: Cocktail sort is a variation of bubble sort, operating in two directions (beginning to end, end to beginning)Comb
: Comb is a simple sorting algorithm which is an improvement of the bubble sorting algorithm.Count
: No description provided.Cycle
: Cycle sort is an in-place, unstable sorting algorithm that is particularly useful when sorting arrays containing elements with a small range of values. It is theoretically optimal in terms of the total number of writes to the original array.Exchange
: No description provided.HeapSort
: No description provided.ImprovedSimple
: ImprovedSimple is a improve SimpleSort by skipping an unnecessary comparison of the first and last. This improved version is more similar to implementation of insertion sortInsertion
: No description provided.Merge
: Merge Perform merge sort on a sliceMergeIter
: No description provided.Pancake
: Pancake sorts a slice using flip operations, where flip refers to the idea of reversing the slice from index 0
to i
.ParallelMerge
: ParallelMerge Perform merge sort on a slice using goroutinesPartition
: No description provided.Patience
: No description provided.Pigeonhole
: Pigeonhole sorts a slice using pigeonhole sorting algorithm. NOTE: To maintain time complexity O(n + N), this is the reason for having only Integer constraint instead of Ordered.Quicksort
: Quicksort Sorts the entire arrayQuicksortRange
: QuicksortRange Sorts the specified range within the arrayRadixSort
: No description provided.Selection
: No description provided.Shell
: No description provided.Simple
: No description provided.MaxHeap
: No description provided.NewSqrtDecomposition
: Create a new SqrtDecomposition instance with the parameters as specified by SqrtDecomposition comment Assumptions: - len(elements) > 0SqrtDecomposition
: No description provided.NewStack
: NewStack creates and returns a new stack.Array
: No description provided.
Node
: No description provided.
SList
: No description provided.
Stack
: No description provided.
CountChars
: CountChars counts the number of a times a character has occurred in the provided string argument and returns a map with rune
as keys and the count as value.IsIsogram
: No description provided.IsSubsequence
: Returns true if s is subsequence of t, otherwise return false.Decrypt
: No description provided.Encrypt
: No description provided.FuzzTransposition
: No description provided.NewAVL
: NewAVL creates a novel AVL treeNewBinarySearch
: NewBinarySearch creates a novel Binary-Search treeNewRB
: NewRB creates a new Red-Black TreeAVL
: No description provided.
AVLNode
: No description provided.
BSNode
: No description provided.
BinarySearch
: No description provided.
RB
: No description provided.
RBNode
: No description provided.
NewNode
: NewNode creates a new Trie node with initialized children map.Node
: No description provided.Decrypt
: Decrypt decrypts with Xor encryptionEncrypt
: Encrypt encrypts with Xor encryption after converting each character to byte The returned value might not be readable because there is no guarantee which is within the ASCII range If using other type such as string, []int, or some other types, add the statements for converting the type to []byte.FuzzXOR
: No description provided.Encrypt
: Encrypt encrypts a message using rail fence cipherDecrypt
: decrypt decrypts a message using rail fence cipherTestEncrypt
Test function for EncryptTestDecrypt
Test function for Decrypt