{"id":31812865,"url":"https://github.com/yoshiohasegawa/python-data-structures","last_synced_at":"2025-10-11T07:44:33.179Z","repository":{"id":62579783,"uuid":"383011082","full_name":"yoshiohasegawa/python-data-structures","owner":"yoshiohasegawa","description":"A Python package that contains common data structures and algorithms, available on PyPi.","archived":false,"fork":false,"pushed_at":"2021-07-12T07:47:06.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T05:20:35.393Z","etag":null,"topics":["data-structures","heap","linked-list","python","queue","stack","tree"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pydatastructs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoshiohasegawa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-05T04:19:08.000Z","updated_at":"2021-07-12T07:44:58.000Z","dependencies_parsed_at":"2022-11-03T21:00:43.277Z","dependency_job_id":null,"html_url":"https://github.com/yoshiohasegawa/python-data-structures","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/yoshiohasegawa/python-data-structures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshiohasegawa%2Fpython-data-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshiohasegawa%2Fpython-data-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshiohasegawa%2Fpython-data-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshiohasegawa%2Fpython-data-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoshiohasegawa","download_url":"https://codeload.github.com/yoshiohasegawa/python-data-structures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshiohasegawa%2Fpython-data-structures/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006628,"owners_count":26084132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","heap","linked-list","python","queue","stack","tree"],"created_at":"2025-10-11T07:44:26.651Z","updated_at":"2025-10-11T07:44:33.172Z","avatar_url":"https://github.com/yoshiohasegawa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePython Data Structures\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eFor all of your data structure needs\u003c/h4\u003e\n\n# Table of Contents\n1. [About](#about)\n2. [Getting Started](#getting-started)\n3. [Data Structures](#data-structures)\n    * [Stack](#stack)\n    * [Queue](#queue)\n    * [Tree](#tree)\n    * [Binary Search Tree](#binary-search-tree)\n    * [Linked List](#linked-list)\n    * [Max Heap](#max-heap)\n    * [Min Heap](#min-heap)\n4. [Contact](#contact)\n\n# About\nA Python package that contains common data structures. Data structures within this package also contain associated search and sorting algorithms. The intention of this package is mostly a learning endeavor but, it may also be used for various build purposes. I hope you find it easy to understand and interact with. If you have any questions or comments, please feel free to [reach out](#contact).\n\n# Getting Started\nFurther information regarding this package can be found on the Python Package Index: [pydatastructs](https://pypi.org/project/pydatastructs/).\n\n## Installation\nTo get started, install the package:\n```console\npip install pydatastructs\n```\n\nThen, import it into your project:\n```python\nfrom pydatastructs import (\n    Stack,\n    Queue,\n    Tree,\n    BinarySearchTree,\n    LinkedList,\n    MaxHeap,\n    MinHeap\n    )\n```\n\n# Data Structures\n\n## Stack\nA list or array based data structure with last-in-first-out (LIFO) properties.\n\n### Methods\n- get()\n- length()\n- is_empty()\n- push()\n- pop()\n- merge_sort()\n\n### Usage\n```python\nfrom pydatastructs import Stack\n\nmy_stack = Stack(collection=[5, 3, 1, 4, 2])\nlength = my_stack.length()\n\nif length \u003c 6:\n    my_stack.push(0)\n\nmy_stack.merge_sort() # [0, 1, 2, 3, 4, 5]\n```\n\n## Queue\nA list or array based data structure with first-in-first-out (FIFO) properties.\n\n### Methods\n- get()\n- length()\n- is_empty()\n- enqueue()\n- dequeue()\n- merge_sort()\n\n### Usage\n```python\nfrom pydatastructs import Queue\n\nmy_queue = Queue(collection=[5, 3, 1, 4, 2])\nqueue_is_empty = my_queue.is_empty\n\nif not queue_is_empty:\n    print(my_queue.dequeue())\n\nmy_queue.merge_sort() # [1, 3, 4, 5]\n```\n\n## Tree\nA node based data structure where each node contains a value property and a children property. The children property is a collection of child nodes. Finally, each node itself is a tree or sub-tree.\n\n### Methods\n- add()\n- contains()\n- depth_first_traversal()\n- breadth_first_traversal()\n\n### Usage\n```python\nfrom pydatastructs import Tree\n\nmy_tree = Tree(value=1)\nmy_tree.add(2)\nmy_tree.add(3)\nmy_tree.children[0].add(4)\nmy_tree.children[0].add(5)\nmy_tree.children[1].add(6)\nmy_tree.children[1].add(7)\n\nresult = []\ndef add_to_result(node: Tree):\n    result.append(node.value)\n\nmy_tree.depth_first_traversal(add_to_result)\nprint(result) # [1, 2, 4, 5, 3, 6, 7]\n              # my_tree: \n              #            1\n              #        /      \\\n              #      2         3\n              #   /    \\     /   \\\n              #  4      5   6     7\n```\n\n## Binary Search Tree\nA node based data structure where each node contains a value property and, a left and right property. The left and right properties point to potential child nodes. The left node's value will always be less than the parent node's value. The right node's value will always be greater than the parent node's value. Finally, each node itself is a tree or sub-tree.\n\n### Methods\n- insert()\n- contains()\n- depth_first_traversal()\n- breadth_first_traversal()\n\n### Usage\n```python\nfrom pydatastructs import BinarySearchTree\n\nmy_binarysearchtree = BinarySearchTree(value=10)\nvalues = [6, 14, 4, 12, 8, 16]\n\nfor val in values:\n    my_binarysearchtree.insert(val)\n\nresult = []\ndef add_to_result(node: BinarySearchTree):\n    result.append(node.value)\n\nmy_binarysearchtree.breadth_first_traversal(add_to_result)\nprint(result) # [10, 6, 14, 4, 8, 12, 16]\n              # my_binarysearchtree: \n              #            10\n              #        /      \\\n              #      6         14\n              #   /    \\     /   \\\n              #  4      8   12     16\n```\n\n## Linked List\nA node based data structure containing a head and tail property. The head points to the root node and, the tail points to the last node in the linked list. Each node has a value property and a next property, which points to the next node in the linked list.\n\n### Methods\n- append()\n- remove_head()\n- find_node()\n\n### Usage\n```python\nfrom pydatastructs import LinkedList\n\nmy_linkedlist = LinkedList(value=1)\nvalues = [2, 3, 4, 5]\n\nfor val in values:\n    my_linkedlist.append(val)\n\nnode = my_linkedlist.find_node(3)\n\nprint(node.next.value) # 4\n```\n\n## Max Heap\nA complete binary tree data structure represented as an array where, every parent node's value is greater than or equal to their child node's values.\n\n### Methods\n- get()\n- insert()\n- remove_max()\n\n### Usage\n```python\nfrom pydatastructs import MaxHeap\n\nmy_maxheap = MaxHeap()\nvalues = [1, 2, 3, 4, 5, 6, 7]\n\nfor val in values:\n    my_maxheap.insert(val)\n\nmy_maxheap.get() # [7, 4, 6, 1, 3, 2, 5]\n                 # my_maxheap: \n                 #            7\n                 #        /      \\\n                 #      4         6\n                 #   /    \\     /   \\\n                 #  1      3   2     5\n```\n\n## Min Heap\nA complete binary tree data structure represented as an array where, every parent node's value is less than or equal to their child node's values.\n\n### Methods\n- get()\n- insert()\n- remove_min()\n\n### Usage\n```python\nfrom pydatastructs import MinHeap\n\nmy_minheap = MinHeap()\nvalues = [7, 6, 5, 4, 3, 2, 1]\n\nfor val in values:\n    my_minheap.insert(val)\n\nmy_minheap.get() # [1, 4, 2, 7, 5, 6, 3]\n                 # my_minheap: \n                 #            1\n                 #        /      \\\n                 #      4         2\n                 #   /    \\     /   \\\n                 #  7      5   6     3\n```\n\n# Contact\nFor support, feedback or, to report a bug, you may contact the maintainer:\n- Yoshio Hasegawa: [GitHub](https://github.com/yoshiohasegawa), [LinkedIn](https://www.linkedin.com/in/yoshiohasegawa/)\n\n## License\nDistributed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshiohasegawa%2Fpython-data-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoshiohasegawa%2Fpython-data-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshiohasegawa%2Fpython-data-structures/lists"}