Skip to main content

A project to implement various data structures and algorithms in Python.

Project description

DSA Learning Library

CI PyPI Python License

Educational implementations of common data structures and algorithms written in clean, typed, idiomatic Python.

⚠️ This project is currently under active development and is primarily intended for learning and educational purposes.

Motivation

This project started as part of my journey to build strong software engineering fundamentals.

The goal is not only to study data structures and algorithms, but also to apply software engineering practices such as:

  • API design
  • Type hints
  • Testing
  • Documentation
  • Packaging
  • Versioning

This repository serves both as:

  • A learning project
  • A reference implementation for my personal knowledge base

Project Goals

This library aims to be:

  1. Easy to use
  2. Easy to extend
  3. Easy to maintain

The primary objective is clarity and educational value.

Implementations are designed to clearly communicate the underlying ideas behind each data structure and algorithm.

Performance and memory optimizations are considered when they help explain the concepts (for example, path compression in Union-Find), but maximum performance is not the primary goal.

Design Principles

Data Structures Own Their Data

Data structures are responsible for storing and managing their internal state.

Examples:

  • LinkedList.append()
  • BinarySearchTree.insert()
  • Graph.add_edge()

Algorithms Are Standalone

Algorithms operate on data structures but are not part of them.

Examples:

  • breadth_first_search(graph)
  • depth_first_search(graph)
  • dijkstra(graph)
  • topological_sort(graph)

This separation keeps data structures focused and makes algorithms reusable.

Explicit and Readable APIs

Public APIs favor clarity over brevity.

Examples:

breadth_first_search(graph)
depth_first_search(graph)
binary_search(array, target)

instead of abbreviated names.

Strong Typing

All public interfaces use Python type hints.

Pythonic Error Handling

Operations raise exceptions when invalid usage occurs rather than silently returning None.

Educational First

The code prioritizes readability and learning value.

Implementation choices should make the underlying concepts easy to understand.

Project Structure

src/
└── dsa/
    ├── algorithms/
    ├── data_structures/
    └── graph/

Implemented Data Structures

Linear Structures

  • Linked List
  • Doubly Linked List
  • Stack
  • Queue
  • Priority Queue

Trees

  • Binary Search Tree
  • Trie

Graph Structures

  • Graph (Adjacency List)

Disjoint Sets

  • Union-Find

Implemented Algorithms

Graph Algorithms

  • Breadth-First Search (BFS)
  • Depth-First Search (DFS)
  • Topological Sort (Kahn)
  • Topological Sort (DFS)
  • Dijkstra
  • Prim
  • Kruskal

Sorting Algorithms

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort

Searching Algorithms

  • Binary Search

Testing Philosophy

Every implementation should include tests covering:

  • Happy path scenarios
  • Edge cases
  • Empty inputs
  • Invalid inputs

Usage

Installation:

pip install dsa-study

Installation from source:

git clone https://github.com/pablohernandezdo/dsa-study-library.git
cd dsa-study-library
uv sync

Example:

from dsa.data_structures.linked_list import LinkedList

ll = LinkedList([1, 2, 3])

ll.insert_front(0)   # [0, 1, 2, 3]
ll.insert_back(4)    # [0, 1, 2, 3, 4]
ll.find(3)           # 3
ll.delete(2)         # [0, 1, 3, 4]

Future Work

Type System

  • Learn generic types (TypeVar, Generic)
  • Make data structures generic

Graphs

  • Additional graph representations
  • Weighted graph abstractions

Algorithms

  • Dynamic Programming
  • Greedy Algorithms
  • Backtracking
  • String Algorithms

Tooling

  • Automated testing with GitHub Actions
  • PyPI publication
  • API documentation generation

Versioning

This project follows Semantic Versioning.

Releases are tracked through:

  • pyproject.toml
  • Git tags
  • GitHub releases

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_study-0.4.4.tar.gz (33.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_study-0.4.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file dsa_study-0.4.4.tar.gz.

File metadata

  • Download URL: dsa_study-0.4.4.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dsa_study-0.4.4.tar.gz
Algorithm Hash digest
SHA256 2ffb24132d74a26513ee4805fd63beedbd4db9e264e0486c699c95350808f8a0
MD5 ac0819cd6932aae0930150248992d9b4
BLAKE2b-256 530db013541dcd96b29b39c1d23429a85da6d8c3dbea4dcc77571fb282cae4d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsa_study-0.4.4.tar.gz:

Publisher: publish.yml on pablohernandezdo/dsa-study-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dsa_study-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: dsa_study-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dsa_study-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f1fefacd9fde5fb05e7d3a29089c355629254966f44319e23372c42dfae26194
MD5 0d35677f55624526d4e9420373bbd55b
BLAKE2b-256 eadb387fb2123571f91ed51158deacd358bc89517901eacf513db016b194cc70

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsa_study-0.4.4-py3-none-any.whl:

Publisher: publish.yml on pablohernandezdo/dsa-study-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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