{ "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": "Binary Heap\n###########\n\n.. image:: https://img.shields.io/badge/binary_heap-1.0.4-green.svg\n :target: https://pypi.org/project/binary-heap/\n.. image:: https://travis-ci.org/rameshrvr/binary_heap.svg?branch=master\n :target: https://travis-ci.org/rameshrvr/binary_heap\n\n\nPython library which helps in forming Binary Heaps (Min, Max) using list data structure.\nThis library provides the below Heap specific functions.\n\n*heap_sort*\n\tSort the given list of elements using Heap Sort Algorithm\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 binary_heap\n\nor easy_install::\n\n\t$ easy_install binary_heap\n\nor install from source using::\n\n\t$ git clone https://github.com/rameshrvr/binary_heap.git\n\t$ cd binary_heap\n\t$ pip install .\n\n\nTutorial\n========\n\n1. Heap Sort (Sort the list using heap sort algorithm)\n\n.. code-block:: python\n\n\tRameshs-MBP:binary_heap ramesh_rv$ python3\n\tPython 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) \n\t[Clang 6.0 (clang-600.0.57)] on darwin\n\tType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\t>>>\n\t>>> from binary_heap import heap_sort\n\t>>>\n\t>>> data = [4, 1, 3, 2, 16, 9, 10, 14, 8, 7]\n\t>>>\n\t>>> heap_sort(data) # Returns sorted list in ascending order\n\t[1, 2, 3, 4, 7, 8, 9, 10, 14, 16]\n\t>>> \n\t>>> heap_sort(data, reverse=True) # Returns sorted list in decsnding order\n\t[16, 14, 10, 9, 8, 7, 4, 3, 2, 1]\n\t>>> \n\n\n\n2. 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-MBP:binary_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 binary_heap import MinHeap\n\t>>>\n\t>>> min_heap = MinHeap([4, 3, 6, 8, 11]) # Create an object for Min Heap\n\t>>>\n\t>>> min_heap.length() # Returns size of the heap\n\t5\n\t>>> min_heap.elements()\n\t[3, 4, 6, 8, 11]\n\t>>>\n\t>>> min_heap.add_element(1) # Add a single element to Heap\n\t>>>\n\t>>> min_heap.elements()\n\t[1, 4, 3, 8, 11, 6]\n\t>>>\n\t>>> min_heap.add_element([1, 14, 7, 5]) # Add list of elements to Heap\n\t>>>\n\t>>> min_heap.elements()\n\t[1, 4, 1, 7, 5, 6, 3, 14, 8, 11]\n\t>>>\n\t>>> min_heap.extract_root() # Extract root element from Heap and retrun it. In this case its the minimum element\n\t1\n\t>>>\n\t>>> min_heap.elements()\n\t[1, 4, 3, 7, 5, 6, 11, 14, 8]\n\t>>>\n\t>>> min_heap.get_root_value() # Returns the root value (minimum value) without removing it from Heap\n\t1\n\t>>>\n\t>>> min_heap.search_value(value=5) # Returns index of the searched value. -1 if there is no such value in Heap\n\t4\n\t>>> min_heap.search_value(value=7)\n\t3\n\t>>> min_heap.search_value(value=16)\n\t-1\n\t>>>\n\t>>> min_heap.delete_element_at_index(3) # Remove the element at the specified index\n\t>>>\n\t>>> min_heap.elements()\n\t[1, 4, 3, 8, 5, 6, 11, 14]\n\t>>> \n\n\n\n3. 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-MBP:binary_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 binary_heap import MaxHeap\n\t>>>\n\t>>> max_heap = MaxHeap([4, 3, 6, 8, 11]) # Create an object for Max Heap\n\t>>>\n\t>>> max_heap.elements() # Returns size of the heap\n\t[11, 8, 6, 4, 3]\n\t>>>\n\t>>> max_heap.add_element(13) # Add a single element to Heap\n\t>>>\n\t>>> max_heap.elements()\n\t[13, 8, 11, 4, 3, 6]\n\t>>>\n\t>>> max_heap.add_element([1, 14, 7, 5]) # Add list of elements to Heap\n\t>>>\n\t>>> max_heap.elements()\n\t[14, 13, 11, 8, 5, 6, 1, 4, 7, 3]\n\t>>>\n\t>>> max_heap.extract_root() # Extract root element from Heap and retrun it. In this case its the maximum element\n\t14\n\t>>>\n\t>>> max_heap.elements()\n\t[13, 8, 11, 7, 5, 6, 1, 4, 3]\n\t>>>\n\t>>> max_heap.get_root_value() # Returns the root value (maximum value) without removing it from Heap\n\t13\n\t>>> \n\t>>> max_heap.search_value(value=11) # Returns index of the searched value. -1 if there is no such value in Heap\n\t2\n\t>>> max_heap.search_value(value=1)\n\t6\n\t>>> max_heap.search_value(value=14)\n\t-1\n\t>>>\n\t>>> max_heap.delete_element_at_index(3) # Remove the element at the specified index\n\t>>>\n\t>>> max_heap.elements()\n\t[13, 8, 11, 4, 5, 6, 1, 3]\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/binary_heap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\nLicense\n========\n\nThe package is available as open source under the terms of the [GPL-3.0 License](https://opensource.org/licenses/GPL-3.0).\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/binary_heap/blob/master/CODE_OF_CONDUCT.md).\n\n\nmisc\n========\n\n:license:\n * GPL-3.0\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/binary_heap", "keywords": "binary-heap heap python-heap min-heap max-heap heap-sort", "license": "GNU General Public License v3.0", "maintainer": "", "maintainer_email": "", "name": "binary-heap", "package_url": "https://pypi.org/project/binary-heap/", "platform": "All", "project_url": "https://pypi.org/project/binary-heap/", "project_urls": { "Homepage": "https://github.com/rameshrvr/binary_heap" }, "release_url": "https://pypi.org/project/binary-heap/1.0.4/", "requires_dist": null, "requires_python": "", "summary": "Python functions for working with Binary Heap", "version": "1.0.4" }, "last_serial": 5670516, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "67fd62597c915711b28f61dce05b3136", "sha256": "d2396b3795855c6b9fbc5fe9cdf250920f52869d80158e5e43206ea7e248f3a2" }, "downloads": -1, "filename": "binary_heap-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "67fd62597c915711b28f61dce05b3136", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17437, "upload_time": "2019-01-28T12:50:17", "url": "https://files.pythonhosted.org/packages/41/cc/357d98760f275adef2f886e34604e486749738cc6650dec936eaeae86884/binary_heap-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b67d41e6c35e0ada4d75972e688ade0", "sha256": "5c5b35aa4c56b808db04d369ae6cf19737077bf25a6f73be693e45158373af2e" }, "downloads": -1, "filename": "binary_heap-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3b67d41e6c35e0ada4d75972e688ade0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3987, "upload_time": "2019-01-28T12:50:19", "url": "https://files.pythonhosted.org/packages/12/d4/276be5c2b13fdd11cf65e09c6a213f07920bcc47b619fc5f0364a659f350/binary_heap-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "426881b7b1140430016b522515afe0e9", "sha256": "6dd892e8d5581434483cb65d9d944f12c01fb79de1410ac8e8a2131857708a7f" }, "downloads": -1, "filename": "binary_heap-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "426881b7b1140430016b522515afe0e9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17469, "upload_time": "2019-01-28T13:07:53", "url": "https://files.pythonhosted.org/packages/46/61/19edb98cbc68d2b05dde1d6e48c2f7083b695df0c991c14b7b31cc005d1f/binary_heap-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf297459cd5ff4352f6da59998d54e15", "sha256": "a7518a9cb642b336e027d9826acb934abc73c5916043745614c235a7eacdfc71" }, "downloads": -1, "filename": "binary_heap-1.0.1.tar.gz", "has_sig": false, "md5_digest": "cf297459cd5ff4352f6da59998d54e15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4036, "upload_time": "2019-01-28T13:07:54", "url": "https://files.pythonhosted.org/packages/58/6d/6615f2830b0968a11dc5076e01a75e2463fe3592d7a29bf71c02bdfa55d9/binary_heap-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "0932b2e42e0dd33864d0fa7102820353", "sha256": "27974fcd585180f7dd405ef08b102e5e3cc0a90613431442e2661badccbf4c63" }, "downloads": -1, "filename": "binary_heap-1.0.2.tar.gz", "has_sig": false, "md5_digest": "0932b2e42e0dd33864d0fa7102820353", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4891, "upload_time": "2019-02-03T05:15:00", "url": "https://files.pythonhosted.org/packages/2f/f0/8800a9c09e120e0ec152319c8a5deecee8aa21956a0900f31c6083d319ee/binary_heap-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "61a30c61709995f3e98f42f746f3793c", "sha256": "bc1ddc613ce1f932a6bedf42be2dc97c2b249164da925a5386f540f72f6aebb3" }, "downloads": -1, "filename": "binary_heap-1.0.3.tar.gz", "has_sig": false, "md5_digest": "61a30c61709995f3e98f42f746f3793c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4975, "upload_time": "2019-02-04T08:48:18", "url": "https://files.pythonhosted.org/packages/42/72/9a70f14e2949abc66c42a5ac2f562c450eb098dede244993c269576f5aae/binary_heap-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "86752c877344baff5fe9956fc24de3d4", "sha256": "b9c1d183d56b53952964fbc494c2d67a62e88de5b49f8fc2feefbb148964a166" }, "downloads": -1, "filename": "binary_heap-1.0.4.tar.gz", "has_sig": false, "md5_digest": "86752c877344baff5fe9956fc24de3d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5560, "upload_time": "2019-08-13T07:20:47", "url": "https://files.pythonhosted.org/packages/8b/d7/e3019130cfa4547af260b91c7b2be90d9e2d472c22aa616d5431b01602bb/binary_heap-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "86752c877344baff5fe9956fc24de3d4", "sha256": "b9c1d183d56b53952964fbc494c2d67a62e88de5b49f8fc2feefbb148964a166" }, "downloads": -1, "filename": "binary_heap-1.0.4.tar.gz", "has_sig": false, "md5_digest": "86752c877344baff5fe9956fc24de3d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5560, "upload_time": "2019-08-13T07:20:47", "url": "https://files.pythonhosted.org/packages/8b/d7/e3019130cfa4547af260b91c7b2be90d9e2d472c22aa616d5431b01602bb/binary_heap-1.0.4.tar.gz" } ] }