Skip to content

code-shoily/ex_algo

Repository files navigation

ExAlgo

ExAlgo is a curated collection of data structures and algorithms implemented in Elixir. This project represents an exploration of classic algorithmic patterns through the lens of functional programming and Elixir's unique primitives.

The primary goal is to serve as an educational resource for implementing algorithms in a functional context. It also serves as a repository for utility algorithms useful for challenges like Advent of Code.

Note

While these implementations are verified with comprehensive tests, many of these algorithms have specialized, production-ready libraries available in the Hex ecosystem. This project is intended for learning and reference rather than as a replacement for established libraries.

Table of Contents

Development

Download this repo and get the dependencies with mix deps.get. Go to iex -S mix to try out the algorithms in the REPL.

Testing

  • mix test - Run all tests
  • mix coveralls - Run tests with coverage report
  • mix coveralls.html - Generate HTML coverage report (opens in browser at cover/excoveralls.html)
  • mix coveralls.detail - Show detailed coverage per file

Documentation

  • mix docs - Generate documentation
  • Documentation will be available at doc/index.html

Detailed Documentation

Comprehensive API documentation is available via ex_doc. After running mix docs, open doc/index.html in your browser to explore detailed documentation for all modules, including usage examples and type specifications.

Catalogue

Graph

Name Implementation Test Benchmark Link Note
Inductive Graph Model model.ex Yes No Core Inductive Data Structure
DFS traversal.ex Yes No Inductive Depth-First Search
BFS traversal.ex Yes No Inductive Breadth-First Search
Topological Sort algorithms.ex Yes No Inductive Kahn's Algorithm
Dijkstra's Algorithm algorithms.ex Yes No Shortest Path
Prim's MST algorithms.ex Yes No Minimum Spanning Tree
Kosaraju's SCC algorithms.ex Yes No Strongly Connected Components
Connected Components analysis.ex Yes No Undirected Components
Tarjan's Connectivity analysis.ex Yes No Bridges & Articulation Points
Functional Transformations transform.ex Yes No Higher-order ops (map/filter)
Graph Visualizer visualizer.ex Yes No Mermaid & Inspect support

Heap

Name Implementation Test Benchmark Link Note
Leftist Heap leftist_heap.ex Yes No
Pairing Heap pairing_heap.ex Yes No

List

Name Implementation Test Benchmark Link Note
Linked List linked_list.ex Yes No
Circular List circular_list.ex Yes No
BidirectionalList bidirectional_list.ex Yes No WIP
Maximum Subarray Sum algorithms.ex Yes No Kadane's Algorithm

Queue

Name Implementation Test Benchmark Link Note
Queue queue.ex Yes No

Search

Name Implementation Test Benchmark Link Note
Binary Search binary_search.ex Yes No

Set

Name Implementation Test Benchmark Link Note
Disjoint Set disjoint_set.ex Yes No

Sort

Name Implementation Test Benchmark Link Note
Sort Interface sort.ex No No Universal sorting facade
Bubble Sort exchange.ex Yes No
Insertion Sort insertion.ex Yes No
Merge Sort merge.ex Yes No
Pigeonhole Sort distribution.ex Yes No
Quick Sort exchange.ex Yes No
Selection Sort selection.ex Yes No

Stack

Name Implementation Test Benchmark Link Note
Stack stack.ex Yes No
Min-Max Stack min_max_stack.ex Yes No

String

Name Implementation Test Benchmark Link Note

Tree

Name Implementation Test Benchmark Link Note
Binary Search Tree binary_search_tree.ex Yes No
Tree Traversals traversal.ex Yes No

Counting

Name Implementation Test Benchmark Link Note
Permutations combinatorics.ex::permutations Yes No Naive
Combinations combinatorics.ex::combinations Yes No Naive

Trie

Name Implementation Test Benchmark Link Note
Prefix Trie prefix_trie.ex Yes No Functional map-based Trie

Dynamic Programming

Name Implementation Test Benchmark Link Note
Subset Sum subset_sum.ex Yes No FIXME: Not all subsets are listed. Need to work on that.

Numbers

Name Implementation Test Benchmark Link Note
Chinese Remainder Theorem chinese_remainder.ex Yes No
Catalan Numbers (Recursive) catalan.ex::recursive Yes No
Catalan Numbers (Dynamic) catalan.ex::dp Yes No
Divisors arithmetics.ex::divisors Yes No

AI Usage Note

Parts of this repository, including refactoring for academic alignment, documentation enhancements, and several algorithmic implementations (such as the Inductive Graph suite and Prefix Trie), were developed or refined in collaboration with an AI coding assistant (Antigravity). This partnership helped ensure consistent documentation standards, rigorous testing, and adherence to functional programming best practices.

About

Data Structures and Algorithms implemented with Elixir

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages