Skip to main content

Implementation of various data structures in Python from scratch

Project description

data-structures-python

Data structures

In this library, we implemented some important data structures and seen how they work. We have:

  • Array_new: This was our custom implementation of an array. It provided a way to store a contiguous sequence of elements and likely included basic array operations like initialization and element access. We used it as one of the underlying structures for our Stack implementation.

  • Node: This class served as the fundamental building block for our linked list and tree implementations. Each Node object held a value and references (next and optionally prev for doubly linked lists, left and right for trees) to other nodes in the data structure.

  • LinkedList: This class implemented the linked list data structure, utilizing Node objects. It supported both singly and doubly linked lists and provided methods for inserting, deleting, accessing, searching, reversing, and updating elements within the list. We used it as the underlying structure for our Stack and Queue implementations.

  • Stack: This class implemented the stack data structure, which follows the LIFO principle. It could be initialized with either an Array_new or a LinkedList object as its underlying storage. It provided methods for push (to add elements to the top), pop_stack (to remove and return the top element), peek (to view the top element), isEmpty (to check if the stack is empty), and display_stack (to show the stack's contents).

  • Queue: This class implemented the queue data structure, following the FIFO principle. It used a LinkedList as its underlying storage. It provided methods for enqueue (to add elements to the rear), dequeue (to remove and return the front element), peek (to view the front element), rear (to view the rear element), isNull (to check if the queue is empty), and display_queue (to show the queue's contents).

  • BinaryTree: This class inherited from the Node class and represented a binary tree. Each instance was a node that could have a left and a right child. It included methods for different tree traversals (pre_order, in_order, post_order), searching for nodes (search_node, search_BST for Binary Search Trees), and adding nodes while maintaining the BST property (addnode). It also had methods for building and drawing a graph representation of the tree using networkx and matplotlib (build_graph, draw_graph).

In essence, these classes provide the blueprints and functionalities for creating and manipulating different types of data structures, each designed for specific ways of organizing and accessing data.

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

data_structures_py_jordankbm-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

data_structures_py_jordankbm-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for data_structures_py_jordankbm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6787f5a70592ad98a1c06e938a6808488616bac9277c9db89951a59aabde32fb
MD5 e5e1779436017674e0c1d30d69016f2a
BLAKE2b-256 6c6793f6bff3c343fd9780ffcfb7060f31c10c03433b3376781600b04b2f6b59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_structures_py_jordankbm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d70065340a6e87d6bf95a7c7d835c253f2dcc7bc3286dbb99209030bb2e1ba5
MD5 1978e8abf0f1213b1479246f067d3a31
BLAKE2b-256 06256a3c56b0778abf9b3c5e74d18d26cf7afccac38a0d988fa5be456f8f47d0

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