-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
706 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
include README.rst LICENSE | ||
prune tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,25 +37,22 @@ Are you studying binary trees for your next exam, assignment or technical interv | |
|
||
**Binarytree** is a Python library which provides a simple API to generate, | ||
visualize, inspect and manipulate binary trees. It allows you to skip the | ||
tedious work of setting up test data, and dive straight into practising | ||
your algorithms! Heaps and BSTs (binary search trees) are also supported. | ||
tedious work of setting up test data, and dive straight into practising your | ||
algorithms. Heaps and BSTs (binary search trees) are also supported. | ||
|
||
Announcements | ||
============= | ||
|
||
* **Binarytree** has been completely overhauled in version `3.0`_! | ||
* **Binarytree** version `4.0`_ is now out! | ||
* Please see the releases_ page for details on the latest updates. | ||
|
||
.. _3.0: https://github.com/joowani/binarytree/releases/tag/3.0.0 | ||
.. _4.0: https://github.com/joowani/binarytree/releases/tag/4.0.0 | ||
.. _releases: https://github.com/joowani/binarytree/releases | ||
|
||
Requirements | ||
============ | ||
|
||
- Python 2.7, 3.4, 3.5 or 3.6 | ||
- Pip_ installer | ||
|
||
.. _Pip: https://pip.pypa.io | ||
|
||
Installation | ||
============ | ||
|
@@ -66,19 +63,17 @@ To install a stable version from PyPi_: | |
~$ pip install binarytree | ||
To install the latest version directly from GitHub_: | ||
|
||
.. code-block:: bash | ||
~$ pip install -e [email protected]:joowani/binarytree.git@master#egg=binarytree | ||
You may need to use ``sudo`` depending on your environment setup. | ||
You may need to use ``sudo`` depending on your environment. | ||
|
||
.. _PyPi: https://pypi.python.org/pypi/binarytree | ||
.. _GitHub: https://github.com/joowani/binarytree | ||
|
||
|
||
Getting Started | ||
=============== | ||
|
||
|
@@ -93,7 +88,6 @@ By default, **binarytree** uses the following class to represent a node: | |
self.left = left # Left child | ||
self.right = right # Right child | ||
Generate and pretty-print various types of binary trees: | ||
|
||
.. code-block:: python | ||
|
@@ -164,7 +158,6 @@ Use the `binarytree.Node`_ class to build your own trees: | |
# 4 | ||
# | ||
Inspect tree properties: | ||
|
||
.. code-block:: python | ||
|
@@ -296,7 +289,6 @@ Use `level-order (breadth-first)`_ indexes to manipulate nodes: | |
# \ | ||
# 2-3 | ||
Traverse the trees using different algorithms: | ||
|
||
.. code-block:: python | ||
|
@@ -329,19 +321,20 @@ Traverse the trees using different algorithms: | |
>>> root.levelorder | ||
[Node(1), Node(2), Node(3), Node(4), Node(5)] | ||
>>> list(root) # Equivalent to root.levelorder | ||
[Node(1), Node(2), Node(3), Node(4), Node(5)] | ||
`List representations`_ are also supported: | ||
|
||
.. _List representations: | ||
https://en.wikipedia.org/wiki/Binary_tree#Arrays | ||
|
||
.. _List representations: https://en.wikipedia.org/wiki/Binary_tree#Arrays | ||
|
||
.. code-block:: python | ||
>>> from binarytree import build | ||
>>> | ||
>>> # Build a tree from list representation | ||
>>> root = build([7, 3, 2, 6, 9, None, 1, 5, 8]) | ||
>>> values = [7, 3, 2, 6, 9, None, 1, 5, 8] | ||
>>> root = build(values) | ||
>>> print(root) | ||
# | ||
# __7 | ||
|
@@ -353,19 +346,16 @@ Traverse the trees using different algorithms: | |
# 5 8 | ||
# | ||
>>> # Convert the tree back to list representation | ||
>>> list(root) | ||
>>> root.values | ||
[7, 3, 2, 6, 9, None, 1, 5, 8] | ||
Check out the documentation_ for more details! | ||
|
||
.. _documentation: http://binarytree.readthedocs.io/en/latest/index.html | ||
|
||
|
||
Contributing | ||
============ | ||
|
||
Please have a look at this page_ before submitting a pull request. Thanks! | ||
|
||
.. _page: http://binarytree.readthedocs.io/en/latest/contributing.html | ||
.. _page: http://binarytree.readthedocs.io/en/latest/contributing.html |
Oops, something went wrong.