A comprehensive collection of algorithms and data structures implemented in Go (Golang). This repository serves as both a learning resource and a reference implementation for common computer science concepts.
go test -v ./...
- Cache
- LRU (Least Recently Used)
- LFU (Least Frequently Used)
- Trees
- AVL Tree
- Binary Search Tree
- B-Tree
- Red-Black Tree
- Trie
- Segment Tree
- Fenwick Tree
- Lists and Queues
- Linked Lists (Singly, Doubly, Circular)
- Queue
- Stack
- Deque
- Dynamic Array
- Hash Structures
- HashMap
- Set
- Bubble Sort
- Quick Sort
- Merge Sort
- Heap Sort
- Insertion Sort
- Selection Sort
- Shell Sort
- Counting Sort
- Radix Sort
- Bucket Sort
- Tim Sort
- Pancake Sort
- Patience Sort
- Circle Sort
- Cocktail Sort
- Comb Sort
- Cycle Sort
- Exchange Sort
- Pigeonhole Sort
- Stooge Sort
- Binary Search
- Linear Search
- Jump Search
- Interpolation Search
- Ternary Search
- Select K-th Element
- Depth-First Search (DFS)
- Breadth-First Search (BFS)
- Dijkstra's Algorithm
- Bellman-Ford Algorithm
- Floyd-Warshall Algorithm
- Kruskal's Algorithm
- Prim's Algorithm
- Topological Sort
- Kosaraju's Algorithm
- Edmonds-Karp Algorithm
- Graph Coloring Algorithms
- Articulation Points
- Union Find
- Longest Common Subsequence
- Longest Increasing Subsequence
- Longest Palindromic Subsequence
- Knapsack Problem
- Matrix Chain Multiplication
- Rod Cutting
- Coin Change
- Edit Distance
- Word Break
- Burst Balloons
- Knuth-Morris-Pratt (KMP)
- Aho-Corasick
- Boyer-Moore
- Rabin-Karp
- Levenshtein Distance
- Manacher's Algorithm
- String Matching
- Palindrome Check
- Pangram Check
- RSA
- Caesar Cipher
- ROT13
- XOR Cipher
- Diffie-Hellman Key Exchange
- Digital Signature Algorithm (DSA)
- Polybius Cipher
- Rail Fence Cipher
- Greatest Common Divisor (GCD)
- Least Common Multiple (LCM)
- Prime Numbers
- Fibonacci Numbers
- Pascal's Triangle
- Matrix Operations
- Catalan Numbers
- Euler Totient
- Fast Exponentiation
- Binary Operations
- Huffman Coding
- Run-Length Encoding (RLE)
- Clean, well-documented implementations
- Comprehensive test coverage
- Standard Go coding conventions
- Generic implementations where applicable
- Performance-optimized algorithms
- Educational comments and documentation
- Go 1.18 or higher
git clone https://github.com/deeper-x/data_struct_algs.git
cd data_struct_algs
go mod tidy
Each algorithm and data structure is contained in its own package. Import and use them as needed:
import (
"github.com/deeper-x/data_struct_algs/sort"
"github.com/deeper-x/data_struct_algs/search"
)
// Example usage of quicksort
numbers := []int{64, 34, 25, 12, 22, 11, 90}
sorted := sort.QuickSort(numbers)
// Example usage of binary search
index := search.Binary(sorted, 22)
Run all tests:
go test ./...
Run specific package tests:
go test ./sort/...
go test ./search/...
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
├── cache/ # Caching implementations
├── cipher/ # Cryptography algorithms
├── compression/ # Data compression algorithms
├── conversion/ # Data conversion utilities
├── dynamic/ # Dynamic programming solutions
├── graph/ # Graph algorithms
├── math/ # Mathematical algorithms
├── search/ # Search algorithms
├── sort/ # Sorting algorithms
├── strings/ # String manipulation algorithms
└── structure/ # Data structure implementations
This project is licensed under the MIT License - see the LICENSE file for details.
This project was inspired by #TODO
For questions and feedback, please open an issue in the GitHub repository.