This repository contains a set of self-contained implementations of several common algorithms and data structures in different programming languages. The implementation of these algorithms/data structures is not to be intended as a reference and most of these implementations are far from being generic and written well enough to consider their inclusion in any production system. Also, the list of both algorithms and data structures here is not meant to be complete, this is mostly a list of things I already implemented and items I have on my todo list.
Additionally, there are also some interview questions and solutions for each programming language. The description of the interview question is in the file itself.
Note: some of the Java implementations require Java 8
C | C++ | Java | Go | Python | Ruby | ||
---|---|---|---|---|---|---|---|
Caches | LRU Cache | ✓ | |||||
Dictionaries | Open addressing | ✓ | |||||
Chained lists | ✓ | ||||||
Binary Search Tree | ✓ | ✓ | ✓ | ✓ | |||
Lists | Singly Linked List | ✓ | ✓ | ✓ | |||
Doubly Linked List | ✓ | ||||||
Array List | ✓ | ||||||
Skip List | ✓ | ||||||
Math | Sparse Vector | ✓ | ✓ | ||||
90° Matrix Rotation | ✓ | ||||||
GCD | ✓ | ✓ | |||||
Optimization | Simulated Annealing | ✓ | |||||
Sets | Union Find | ✓ | ✓ | ✓ | |||
Sorting and Search | Bubble Sort | ✓ | ✓ | ✓ | ✓ | ✓ | |
Selection Sort | ✓ | ✓ | ✓ | ✓ | ✓ | ||
Insertion Sort | ✓ | ✓ | ✓ | ✓ | ✓ | ||
Merge Sort | ✓ | ✓ | ✓ | ✓ | |||
Quick Sort | ✓ | ✓ | ✓ | ✓ | |||
Heap Sort | ✓ | ✓ | ✓ | ||||
Binary Search | ✓ | ✓ | |||||
Trees | Heap | P | ✓ | ✓ | |||
Trie | ✓ | ||||||
AVL Tree | |||||||
Red/Black Tree | |||||||
Quad Tree | |||||||
Graphs | Matrix-based graph | ✓ | |||||
BFS | ✓ | ||||||
DFS | ✓ |
Legend:
- ✓ everything is working
- P incomplete/partial implementation