Skip to main content

A pedagogical Python package implementing core data structures from scratch

Project description

Ejah Data Structures Python Package

Ejah Data Structures is a Python package that provides various data structures with common operations such as insert, delete, search, and traverse. This package includes implementations of the following data structures: Array, Binary Search Tree, Binary Graph Search, Singly Linked List, Queue, and Stack.

Installation

To install the Ejah Data Structures Python package, ensure you have Python installed on your system. You can install the package using pip:

pip install ejah-data-structures

Make sure you run this command within a Python environment.

Clone the Repository

To clone this repository to your local machine, follow these steps:

  1. Run the following command on your terminal to clone the repository:

    git clone https://github.com/EjahDil/data-structures-python.git
    
  2. Navigate into the project directory:

    cd data-structures-python
    

Features

This package includes the following data structures, each with its own module containing methods for insert, delete, search, traverse, and more:

Array

The Array class provides a dynamic array implementation with operations to insert, delete, search, and traverse the array.

Methods

  • Insert(index, value): Adds an element at a specified index.
  • Delete(index): Removes an element from a given index.
  • Search(value): Searches for an element and returns its index.
  • Traverse(): Returns all elements in the array.
  • Length(): Returns the number of elements in the array.
  • Is Empty(): Checks if the array is empty.

Binary Graph Search

The BinaryGraphSearch class allows for binary search on a sorted list of data. This class implements both the search operation and the insert operation to maintain the list in sorted order.

Methods

  • Search(target): Searches for a target element using binary search.
  • Insert(value): Inserts a value into the list while maintaining the sorted order.
  • In-order Traversal(): Simulates an in-order traversal of the binary tree (which is essentially the sorted list).

Binary Search Tree

The BinarySearchTree class implements a binary search tree, which allows for efficient searching, insertion, and traversal of nodes in sorted order.

Methods

  • Insert(data): Inserts a node with the given data.
  • Search(data): Searches for a node with the specified data.
  • In-order Traversal(): Returns the nodes in sorted order (in-order traversal).

Singly Linked List

The SinglyLinkedList class provides a basic singly linked list implementation.

Methods

  • Insert(data): Adds a new node at the end of the list.
  • Delete(data): Removes a node with the specified value.
  • Search(data): Searches for a node containing a specific value.
  • Traverse(): Returns a list of all nodes' data.

Queue

The Queue class implements a FIFO (First-In-First-Out) structure, which is useful for scenarios like task scheduling.

Methods

  • Enqueue(item): Adds an item to the end of the queue.
  • Dequeue(): Removes and returns the front item from the queue.
  • Peek(): Returns the front item without removing it.
  • Is Empty(): Checks if the queue is empty.

Stack

The Stack class implements a LIFO (Last-In-First-Out) structure, which is essential for undo operations, function calls, and parsing expressions.

Methods

  • Push(item): Adds an item to the top of the stack.
  • Pop(): Removes and returns the top item from the stack.
  • Peek(): Returns the top item without removing it.
  • Is Empty(): Checks if the stack is empty.

Usage After installation, you can start using the package by importing the classes directly into your Python code.

Usage

After installation, you can start using the package by importing the classes directly into your Python code.

from ejah_data_structures import Array, Queue, Stack, SinglyLinkedList, BinaryGraphSearch, BinarySearchTree

Documentation

For detailed usage and installation instructions, please refer to the documentation.

You can find examples, code explanations, and additional information on how to use the package in the documentation.

Contribute

If you'd like to contribute to this project, please visit the GitHub repository and submit issues, pull requests, or suggestions.

Feel free to fork the project and make improvements or add new features to enhance its usefulness.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

ejahdilandatastruct-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

ejahdilandatastruct-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file ejahdilandatastruct-0.1.0.tar.gz.

File metadata

  • Download URL: ejahdilandatastruct-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ejahdilandatastruct-0.1.0.tar.gz
Algorithm Hash digest
SHA256 138a35be6f4ead1f7135742c051a2058d8a3f04d1e6df7ffd0e16ea138500424
MD5 d6d3ad7b8aba3d9345444a921990f671
BLAKE2b-256 fab886381e53c7e04d8ae9725be79f5c27379d83a5eb5092340c208c5527cb02

See more details on using hashes here.

File details

Details for the file ejahdilandatastruct-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ejahdilandatastruct-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 402abbd1a9ac99c5471792a0e9a6e5f70ceea34b24a046301416bc7e4c099f56
MD5 4d89bcf06df2b33ffc8cfc6a4ae0464a
BLAKE2b-256 2425d8556c2168b6ce8ab04f575d13e35231bf77a414503ff8c7347ce2f83ec2

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