{ "info": { "author": "Ramesh RV", "author_email": "rameshrvr@outlook.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "D-ary Heap\n##########\n\n.. image:: https://img.shields.io/badge/d_heap-0.0.2-green.svg\n :target: https://pypi.org/project/d-heap/\n.. image:: https://travis-ci.org/rameshrvr/d-ary_heap.svg?branch=master\n :target: https://travis-ci.org/rameshrvr/d-ary_heap\n\n\nPython functions for working with D-ary Heap (Heap with more than 2 child nodes). For more info about this Data Structure Please gothrough: https://en.wikipedia.org/wiki/D-ary_heap\n\nThis library provides the below Heap specific functions.\n\n*heapify*\n\tConvert list of elements to Heap data structure (MinHeap/MaxHeap)\n\n*add_element*\n\tAdd single/list of elements to Heap\n\n*get_root_value*\n\tReturns root value of the Heap without removing the element\n\tMinimum value for Min Heap, Maximum value for Max Heap\n\n*extract_root*\n\tExtract root element from Heap and reform the Heap\n\n*search_value*\n\tSearches the value in heap and returns index.\n\tif same element is present multiple times, first occurring index is returned\n\n*delete_element_at_index*\n\tRemove the element at the specified index and reform the Heap\n\n\nFor example function invocations, plesae see the tutorial.\n\n.. contents::\n\n\nInstallation\n============\n\ninstall from pypi using pip::\n\n\t$ pip install d_heap\n\nor install from source using::\n\n\t$ git clone https://github.com/rameshrvr/d-ary_heap.git\n\t$ cd d-ary_heap\n\t$ pip install .\n\n\nTutorial\n========\n\n1. Min Heap (Heap where the data in parent node is lesser than the data in child node)\n\n.. code-block:: python\n\t\n\tRameshs-MacBook-Pro:d-ary_heap rameshrv$ python3\n\tPython 3.7.2 (default, Dec 27 2018, 07:35:06) \n\t[Clang 10.0.0 (clang-1000.11.45.5)] on darwin\n\tType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\t>>>\n\t>>> from d_heap import MinHeap, MaxHeap\n\t>>> \n\t>>> array = [4, 3, 6, 8, 11, 1, 5, 14, 10, 7, 2, 12, 9, 13, 15]\n\t>>> \n\t>>> min_heap_4_children = MinHeap(4, array) # Convert array to 4 children Heap\n\t>>> \n\t>>> min_heap_4_children.elements()\n\t[1, 3, 2, 8, 11, 4, 5, 14, 10, 7, 6, 12, 9, 13, 15]\n\t>>> \n\t>>> min_heap_5_children = MinHeap(5, array) # Convert array to 5 children Heap\n\t>>> \n\t>>> min_heap_5_children.elements()\n\t[1, 2, 6, 8, 11, 4, 5, 14, 10, 7, 3, 12, 9, 13, 15]\n\t>>> \n\t>>> min_heap_4_children.add_element(0) # Add single element to Heap\n\t>>> \n\t>>> min_heap_4_children.elements()\n\t[0, 3, 2, 1, 11, 4, 5, 14, 10, 7, 6, 12, 9, 13, 15, 8]\n\t>>> \n\t>>> min_heap_5_children.add_element([0, 24, 17, 55]) # Add list of elements to heap\n\t>>> \n\t>>> min_heap_5_children.elements()\n\t[0, 2, 1, 8, 11, 4, 5, 14, 10, 7, 3, 12, 9, 13, 15, 6, 24, 17, 55]\n\t>>> \n\t>>> min_heap_4_children.extract_root() # Extract root element from Heap and retrun it. In this case its the minimum element\n\t0\n\t>>> \n\t>>> min_heap_4_children.elements()\n\t[1, 3, 2, 8, 11, 4, 5, 14, 10, 7, 6, 12, 9, 13, 15]\n\t>>> \n\t>>> min_heap_4_children.get_root_value() # Returns the root value (minimum value) without removing it from Heap\n\t1\n\t>>> \n\t>>> min_heap_4_children.search_value(5) # Returns index of the searched value. -1 if there is no such value in Heap\n\t6\n\t>>> min_heap_4_children.search_value(7)\n\t9\n\t>>> min_heap_4_children.search_value(21)\n\t-1\n\t>>> \n\t>>> min_heap_4_children.delete_element_at_index(4) # Remove the element at the specified index\n\t>>> \n\t>>> min_heap_4_children.elements()\n\t[1, 3, 2, 8, 15, 4, 5, 14, 10, 7, 6, 12, 9, 13]\n\t>>> \n\n\n\n\n2. Max Heap (Heap where the data in parent node is greater than the data in child node)\n\n.. code-block:: python\n\n\tRameshs-MacBook-Pro:d-ary_heap rameshrv$ python3\n\tPython 3.7.2 (default, Dec 27 2018, 07:35:06) \n\t[Clang 10.0.0 (clang-1000.11.45.5)] on darwin\n\tType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\t>>>\n\t>>> from d_heap import MinHeap, MaxHeap\n\t>>>\n\t>>> array = [4, 3, 6, 8, 11, 1, 5, 14, 10, 7, 2, 12, 9, 13, 15]\n\t>>>\n\t>>> max_heap_4_children = MaxHeap(4, array) # Convert array to 4 children Heap\n\t>>> \n\t>>> max_heap_4_children.elements()\n\t[15, 14, 12, 13, 11, 1, 5, 3, 10, 7, 2, 6, 9, 4, 8]\n\t>>> \n\t>>> max_heap_5_children = MaxHeap(5, array) # Convert array to 5 children Heap\n\t>>> \n\t>>> max_heap_5_children.elements()\n\t[15, 14, 13, 8, 11, 1, 5, 3, 10, 7, 2, 12, 9, 4, 6]\n\t>>> \n\t>>> max_heap_4_children.add_element(21) # Add single element to Heap\n\t>>> \n\t>>> max_heap_4_children.elements()\n\t[21, 14, 12, 15, 11, 1, 5, 3, 10, 7, 2, 6, 9, 4, 8, 13]\n\t>>> \n\t>>> \n\t>>> max_heap_5_children.add_element([21, 14, 27, 35]) # Add list of elements to heap\n\t>>> \n\t>>> max_heap_5_children.elements()\n\t[35, 14, 15, 27, 11, 1, 5, 3, 10, 7, 2, 12, 9, 4, 6, 13, 8, 14, 21]\n\t>>> \n\t>>> max_heap_4_children.extract_root() # Extract root element from Heap and retrun it. In this case its the maximum element\n\t21\n\t>>> \n\t>>> max_heap_4_children.elements()\n\t[15, 14, 12, 13, 11, 1, 5, 3, 10, 7, 2, 6, 9, 4, 8]\n\t>>> \n\t>>> max_heap_4_children.get_root_value() # Returns the root value (maximum value) without removing it from Heap\n\t15\n\t>>> \n\t>>> max_heap_4_children.search_value(5) # Returns index of the searched value. -1 if there is no such value in Heap\n\t6\n\t>>> max_heap_4_children.search_value(11)\n\t4\n\t>>> max_heap_4_children.search_value(21)\n\t-1\n\t>>> \n\t>>> max_heap_4_children.delete_element_at_index(2) # Remove the element at the specified index\n\t>>> \n\t>>> max_heap_4_children.elements()\n\t[15, 14, 9, 13, 11, 1, 5, 3, 10, 7, 2, 6, 8, 4]\n\t>>> \n\n\n\nDevelopment\n===========\n\nAfter checking out the repo, `cd` to the repository. Then, run `pip install .` to install the package locally. You can also run `python (or) python3` for an interactive prompt that will allow you to experiment.\n\nTo install this package onto your local machine, `cd` to the repository then run `pip install .`. To release a new version, update the version number in `setup.py`, and then run `python setup.py register`, which will create a git tag for the version, push git commits and tags, and push the package file to [PyPI](https://pypi.org).\n\n\nContributing\n============\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rameshrvr/d-ary_heap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant] code of conduct.\n\n\nLicense\n========\n\nThe package is available as open source under the terms of the [MIT License].\n\n\nCode of Conduct\n===============\n\nEveryone interacting in the Binary Heap project\u2019s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rameshrvr/d-ary_heap/blob/master/CODE_OF_CONDUCT.md).\n\n\nmisc\n========\n\n:license:\n * MIT License\n\n:authors:\n * Ramesh RV\n * Adithya KS", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rameshrvr/d-ary_heap", "keywords": "d-heap heap python-heap min-heap max-heap", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "d-heap", "package_url": "https://pypi.org/project/d-heap/", "platform": "All", "project_url": "https://pypi.org/project/d-heap/", "project_urls": { "Homepage": "https://github.com/rameshrvr/d-ary_heap" }, "release_url": "https://pypi.org/project/d-heap/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Python functions for working with D-ary Heap (Heap with more than 2 child nodes)", "version": "0.0.2" }, "last_serial": 4786325, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5f5bc91f1e0fc48800676216d76eee1b", "sha256": "885edc513fadfed0bdb39ff6771829667392721318e2ad5060f9c5b9dc486e3a" }, "downloads": -1, "filename": "d_heap-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5f5bc91f1e0fc48800676216d76eee1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5005, "upload_time": "2019-02-06T07:33:53", "url": "https://files.pythonhosted.org/packages/c7/f4/50098315e53b786ab8191d9cee9e3eca3ca75989bfad6fc1969921427495/d_heap-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "0446abe1cdc9178953b52ce1cd73f5eb", "sha256": "588c932b359f729b015e20eec4756915ef4fc530e39fe5911af7b97b70935111" }, "downloads": -1, "filename": "d_heap-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0446abe1cdc9178953b52ce1cd73f5eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5228, "upload_time": "2019-02-06T12:00:37", "url": "https://files.pythonhosted.org/packages/01/54/e62d0ed70474773d0c41f751faaee2ccfd1605a7fd561532a45fa213ed66/d_heap-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0446abe1cdc9178953b52ce1cd73f5eb", "sha256": "588c932b359f729b015e20eec4756915ef4fc530e39fe5911af7b97b70935111" }, "downloads": -1, "filename": "d_heap-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0446abe1cdc9178953b52ce1cd73f5eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5228, "upload_time": "2019-02-06T12:00:37", "url": "https://files.pythonhosted.org/packages/01/54/e62d0ed70474773d0c41f751faaee2ccfd1605a7fd561532a45fa213ed66/d_heap-0.0.2.tar.gz" } ] }