Skip to content

Commit

Permalink
Update README.md and docs/index.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed Mar 24, 2022
1 parent 61e1b5f commit c0586d8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ print(my_heap)
# 0 10 6
#
```
Generate trees with letter values instead of numbers:

```python
from binarytree import tree

my_tree = tree(height=3, is_perfect=False, letters=True)

print(my_tree)
#
# ____H____
# / \
# __E__ F__
# / \ / \
# M G J B
# \ / / / \
# O L D I A
#
```


Build your own trees:

Expand Down Expand Up @@ -314,7 +333,8 @@ print(root.values)
```

Binarytree supports another representation which is more compact but without
the [indexing properties](https://en.wikipedia.org/wiki/Binary_tree#Arrays):
the [indexing properties](https://en.wikipedia.org/wiki/Binary_tree#Arrays)
(this method is often used in [Leetcode](https://leetcode.com/)):

```python
from binarytree import build, build2, Node
Expand Down
23 changes: 20 additions & 3 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ Generate and pretty-print various types of binary trees:
/ \ /
0 10 6
Generate trees with letter values instead of numbers:

.. code-block:: python
>>> from binarytree import tree
>>> my_tree = tree(height=3, is_perfect=False, letters=True)
>>> print(my_tree)
____H____
/ \
__E__ F__
/ \ / \
M G J B
\ / / / \
O L D I A
Build your own trees:

Expand Down Expand Up @@ -275,10 +292,10 @@ Convert to `List representations`_:
[7, 3, 2, 6, 9, None, 1, 5, 8]

Binarytree supports another representation which is more compact but without
the `indexing properties`_:
the `indexing properties`_ (this method is often used in Leetcode_):

.. _indexing properties:
https://en.wikipedia.org/wiki/Binary_tree#Arrays
.. _indexing properties: https://en.wikipedia.org/wiki/Binary_tree#Arrays
.. _Leetcode: https://leetcode.com/

.. doctest::

Expand Down

0 comments on commit c0586d8

Please sign in to comment.