A complete Python library for Data Structures, Algorithms, Graphs, Searching, Sorting & Utilities โ beginner-friendly, production-ready.
Project description
๐ฆ dsa_builder
A complete Python library for Data Structures, Algorithms, Graphs, Searching, Sorting & Utilities โ beginner-friendly, production-ready.
๐ง What is dsa_builder?
dsa_builder is a lightweight yet complete Python package designed for:
- Students learning Data Structures & Algorithms
- Developers who want reusable DSA utilities
- Interview preparation
- Teaching / classroom demos
- Research prototypes
- Quick scripting requiring fast DSA helpers
It includes search algorithms, sorting algorithms, graph algorithms, stacks, queues, linked lists, pathfinding, cycle detection, MST, SCC, and more.
It also includes Rich-powered automatic pretty-printing, so all print() outputs from the package or user code are formatted in rich, readable style without importing anything manually.
โญ Key Features
โ Complete DSA Suite
- Stacks (array & linked)
- Queues (deque & linked)
- Singly, doubly, circular linked lists
- Searching: linear, binary, bounds, rotated array search
- Sorting: basic, intermediate, advanced (merge, quick, heap, counting, radix, timsort)
- Graph class + advanced algorithms
- Dijkstra, Bellman-Ford, DFS, BFS
- MST: Kruskal, Prim
- SCC (Kosaraju)
- Cycle detection with cycle path
- Shortest path reconstruction
โ Automatic Rich Output (No Import Needed)
print() automatically becomes Rich's colorful pretty printer.
Example:
print({"a": 1, "b": [1,2,3]})
Prints beautifully formatted output without importing Rich manually.
โ Modern Python API
Every module is accessible through:
from dsa_builder import *
or specifically:
from dsa_builder import Graph, merge_sort, binary_search_iterative
โ Easy to Extend
All modules are independent, readable, and documented. New data structures or algorithms can be added easily.
๐ Directory Structure
dsa_builder/
โ
โโโ __init__.py
โโโ rich_print.py
โโโ stack.py
โโโ queue.py
โโโ linked_list.py
โโโ search.py
โโโ sorting.py
โโโ graph.py
โโโ graph_algorithms.py
โโโ complexity.py
โโโ main.py (example usage)
๐ง Installation
pip install dsa_builder
(If publishing later, you will replace with the real PyPI command.)
๐ Getting Started
1. Import the library
import dsa_builder
Everything prints in Rich style automatically.
2. Graph Example
from dsa_builder import Graph
g = Graph(directed=False)
g.add_edge("A", "B")
g.add_edge("B", "C")
print(g.to_adj_list())
Output (auto-rich):
{
"A": [("B", 1.0)],
"B": [("A", 1.0), ("C", 1.0)],
"C": [("B", 1.0)],
}
๐ Searching Algorithms
Supported:
linear_searchbinary_search_iterativebinary_search_recursivelower_boundupper_boundfind_first_lastsearch_in_rotated_array
Example
from dsa_builder import binary_search_iterative
nums = [1,3,5,7,9]
print(binary_search_iterative(nums, 7)) # 3
๐ข Sorting Algorithms
Supported sorts include:
Basic Sorting
selection_sortbubble_sortinsertion_sort
Advanced Sorting
merge_sortquick_sortheap_sortcounting_sortshell_sortradix_sortbucket_sorttim_sort(custom implementation)
Example
from dsa_builder import merge_sort
arr = [5,2,9,1]
print(merge_sort(arr))
๐ Linked List Structures
Supported:
SinglyLLDoublyLinkedListCircularLinkedList
Example
from dsa_builder import SinglyLL
ll = SinglyLL()
ll.insert_end(10)
ll.insert_end(20)
print(ll)
๐งฑ Stack & Queue
Stack
StackLinkedStack
Queue
DequeQueueLinkedQueue
Example:
from dsa_builder import Stack
s = Stack()
s.push(10)
s.push(20)
print(s.pop()) # 20
๐ Graph Algorithms
Included Algorithms:
| Algorithm | Purpose |
|---|---|
| BFS | traversal / shortest unweighted |
| DFS | traversal / cycle detection |
| Dijkstra | shortest path (positive weights) |
| Bellman-Ford | negative weights + cycle detection |
| Prim MST | minimum spanning tree |
| Kruskal MST | minimum spanning tree |
| SCC | strongly connected components |
| detect_cycle_directed | detects cycle & returns cycle path |
| reconstruct_path | recreate shortest path from parent map |
Example: Dijkstra
from dsa_builder import Graph, shortest_path_dijkstra, reconstruct_path
g = Graph(directed=True, weighted=True)
g.add_edge("s","a",1)
g.add_edge("a","b",2)
g.add_edge("s","b",5)
dist, parent = shortest_path_dijkstra(g, "s")
print(dist) # {'s':0, 'a':1, 'b':3}
print(reconstruct_path(parent, "s", "b")) # ['s','a','b']
๐ Complexity Module
complexity.py provides easy lookup tables:
from dsa_builder import COMPLEXITY_SORT
print(COMPLEXITY_SORT["merge_sort"]) # O(n log n)
๐จ Auto Rich Printing Behavior
This package overrides Pythonโs print globally:
Inside rich_print.py:
import builtins
from rich import print as rich_print
builtins.print = rich_print
Once import dsa_builder happens:
- All
print()inside the package = Rich - All
print()inside user code = Rich - No extra imports needed
๐งช Example Project (main.py)
Your included main.py demonstrates combining DSA operations:
from dsa_builder import Graph, merge_sort, binary_search_iterative
g = Graph(directed=False)
g.add_edge(1,2)
g.add_edge(2,3)
print("Adjacency List:", g.to_adj_list())
print("Sorted:", merge_sort([9,1,3,7]))
print("Search:", binary_search_iterative([1,3,5,7], 5))
๐ Contributing
Pull requests are welcome. To contribute:
- Fork the repository
- Create a new branch
- Add features or fix issues
- Update documentation
- Submit PR
All code should follow PEP8 and include tests where appropriate.
๐ License
MIT License โ simple and open. You may freely use, modify, or distribute this library.
๐ Versioning
We follow Semantic Versioning:
MAJOR.MINOR.PATCH
Example:
1.0.0โ Initial release1.1.0โ Added algorithms1.1.1โ Bug fixes
๐ Final Notes
dsa_builder aims to be:
- beginner-friendly
- powerful
- easy to extend
- rich-printed by default
- fully modular
Itโs a perfect starting point for learning, building projects, interview prep, and classroom use.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsa_builder-1.0.0.tar.gz.
File metadata
- Download URL: dsa_builder-1.0.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77dcb74c381fde002c21bc63b9b926d6fefc57d39c3f5ae346b05f4d48256e19
|
|
| MD5 |
60dc617e305a697fc6ee488048bcee57
|
|
| BLAKE2b-256 |
a58fc6adbb8b59b0b25aad6f1597ddae45c0152fcbe597e2592da6649219bc59
|
File details
Details for the file dsa_builder-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dsa_builder-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdd93f6594b03df6bcc9097b3665b113d673dc49e1492ecb20c9c4a385a43aa5
|
|
| MD5 |
1c0917d3b18489fa4da3ed83084ad589
|
|
| BLAKE2b-256 |
cc82b7e32fe9849ec59e5e281eeb02c4daac465a9776d9b8a12baf84be3f162b
|