Skip to main content

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_search
  • binary_search_iterative
  • binary_search_recursive
  • lower_bound
  • upper_bound
  • find_first_last
  • search_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_sort
  • bubble_sort
  • insertion_sort

Advanced Sorting

  • merge_sort
  • quick_sort
  • heap_sort
  • counting_sort
  • shell_sort
  • radix_sort
  • bucket_sort
  • tim_sort (custom implementation)

Example

from dsa_builder import merge_sort

arr = [5,2,9,1]
print(merge_sort(arr))

๐Ÿ“š Linked List Structures

Supported:

  • SinglyLL
  • DoublyLinkedList
  • CircularLinkedList

Example

from dsa_builder import SinglyLL

ll = SinglyLL()
ll.insert_end(10)
ll.insert_end(20)
print(ll)

๐Ÿงฑ Stack & Queue

Stack

  • Stack
  • LinkedStack

Queue

  • DequeQueue
  • LinkedQueue

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:

  1. Fork the repository
  2. Create a new branch
  3. Add features or fix issues
  4. Update documentation
  5. 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 release
  • 1.1.0 โ€” Added algorithms
  • 1.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsa_builder-1.0.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsa_builder-1.0.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

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

Hashes for dsa_builder-1.0.0.tar.gz
Algorithm Hash digest
SHA256 77dcb74c381fde002c21bc63b9b926d6fefc57d39c3f5ae346b05f4d48256e19
MD5 60dc617e305a697fc6ee488048bcee57
BLAKE2b-256 a58fc6adbb8b59b0b25aad6f1597ddae45c0152fcbe597e2592da6649219bc59

See more details on using hashes here.

File details

Details for the file dsa_builder-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dsa_builder-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdd93f6594b03df6bcc9097b3665b113d673dc49e1492ecb20c9c4a385a43aa5
MD5 1c0917d3b18489fa4da3ed83084ad589
BLAKE2b-256 cc82b7e32fe9849ec59e5e281eeb02c4daac465a9776d9b8a12baf84be3f162b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page