@@ -37,25 +37,22 @@ Are you studying binary trees for your next exam, assignment or technical interv
3737
3838**Binarytree ** is a Python library which provides a simple API to generate,
3939visualize, inspect and manipulate binary trees. It allows you to skip the
40- tedious work of setting up test data, and dive straight into practising
41- your algorithms! Heaps and BSTs (binary search trees) are also supported.
40+ tedious work of setting up test data, and dive straight into practising your
41+ algorithms. Heaps and BSTs (binary search trees) are also supported.
4242
4343Announcements
4444=============
4545
46- * **Binarytree ** has been completely overhauled in version `3 .0 `_!
46+ * **Binarytree ** version `4 .0 `_ is now out !
4747* Please see the releases _ page for details on the latest updates.
4848
49- .. _ 3 .0 : https://github.com/joowani/binarytree/releases/tag/3 .0.0
49+ .. _ 4 .0 : https://github.com/joowani/binarytree/releases/tag/4 .0.0
5050.. _releases : https://github.com/joowani/binarytree/releases
5151
5252Requirements
5353============
5454
5555- Python 2.7, 3.4, 3.5 or 3.6
56- - Pip _ installer
57-
58- .. _Pip : https://pip.pypa.io
5956
6057Installation
6158============
@@ -66,19 +63,17 @@ To install a stable version from PyPi_:
6663
6764 ~ $ pip install binarytree
6865
69-
7066 To install the latest version directly from GitHub _:
7167
7268.. code-block :: bash
7369
7470 ~ $ pip install -e [email protected] :joowani/binarytree.git@master#egg=binarytree 7571
76- You may need to use ``sudo `` depending on your environment setup .
72+ You may need to use ``sudo `` depending on your environment.
7773
7874.. _PyPi : https://pypi.python.org/pypi/binarytree
7975.. _GitHub : https://github.com/joowani/binarytree
8076
81-
8277Getting Started
8378===============
8479
@@ -93,7 +88,6 @@ By default, **binarytree** uses the following class to represent a node:
9388 self .left = left # Left child
9489 self .right = right # Right child
9590
96-
9791 Generate and pretty-print various types of binary trees:
9892
9993.. code-block :: python
@@ -164,7 +158,6 @@ Use the `binarytree.Node`_ class to build your own trees:
164158 # 4
165159 #
166160
167-
168161 Inspect tree properties:
169162
170163.. code-block :: python
@@ -296,7 +289,6 @@ Use `level-order (breadth-first)`_ indexes to manipulate nodes:
296289 # \
297290 # 2-3
298291
299-
300292 Traverse the trees using different algorithms:
301293
302294.. code-block :: python
@@ -329,19 +321,20 @@ Traverse the trees using different algorithms:
329321 >> > root.levelorder
330322 [Node(1 ), Node(2 ), Node(3 ), Node(4 ), Node(5 )]
331323
324+ >> > list (root) # Equivalent to root.levelorder
325+ [Node(1 ), Node(2 ), Node(3 ), Node(4 ), Node(5 )]
332326
333327 `List representations `_ are also supported:
334328
335- .. _List representations :
336- https://en.wikipedia.org/wiki/Binary_tree#Arrays
337-
329+ .. _List representations : https://en.wikipedia.org/wiki/Binary_tree#Arrays
338330
339331.. code-block :: python
340332
341333 >> > from binarytree import build
342334 >> >
343335 >> > # Build a tree from list representation
344- >> > root = build([7 , 3 , 2 , 6 , 9 , None , 1 , 5 , 8 ])
336+ >> > values = [7 , 3 , 2 , 6 , 9 , None , 1 , 5 , 8 ]
337+ >> > root = build(values)
345338 >> > print (root)
346339 #
347340 # __7
@@ -353,19 +346,16 @@ Traverse the trees using different algorithms:
353346 # 5 8
354347 #
355348 >> > # Convert the tree back to list representation
356- >> > list ( root)
349+ >> > root.values
357350 [7 , 3 , 2 , 6 , 9 , None , 1 , 5 , 8 ]
358351
359-
360-
361352 Check out the documentation _ for more details!
362353
363354.. _documentation : http://binarytree.readthedocs.io/en/latest/index.html
364355
365-
366356Contributing
367357============
368358
369359Please have a look at this page _ before submitting a pull request. Thanks!
370360
371- .. _page : http://binarytree.readthedocs.io/en/latest/contributing.html
361+ .. _page : http://binarytree.readthedocs.io/en/latest/contributing.html
0 commit comments