Skip to content

Commit c0586d8

Browse files
committed
Update README.md and docs/index.rst
1 parent 61e1b5f commit c0586d8

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ print(my_heap)
103103
# 0 10 6
104104
#
105105
```
106+
Generate trees with letter values instead of numbers:
107+
108+
```python
109+
from binarytree import tree
110+
111+
my_tree = tree(height=3, is_perfect=False, letters=True)
112+
113+
print(my_tree)
114+
#
115+
# ____H____
116+
# / \
117+
# __E__ F__
118+
# / \ / \
119+
# M G J B
120+
# \ / / / \
121+
# O L D I A
122+
#
123+
```
124+
106125

107126
Build your own trees:
108127

@@ -314,7 +333,8 @@ print(root.values)
314333
```
315334

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

319339
```python
320340
from binarytree import build, build2, Node

docs/overview.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ Generate and pretty-print various types of binary trees:
5858
/ \ /
5959
0 10 6
6060
61+
Generate trees with letter values instead of numbers:
62+
63+
.. code-block:: python
64+
65+
>>> from binarytree import tree
66+
67+
>>> my_tree = tree(height=3, is_perfect=False, letters=True)
68+
69+
>>> print(my_tree)
70+
71+
____H____
72+
/ \
73+
__E__ F__
74+
/ \ / \
75+
M G J B
76+
\ / / / \
77+
O L D I A
6178
6279
Build your own trees:
6380

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

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

280-
.. _indexing properties:
281-
https://en.wikipedia.org/wiki/Binary_tree#Arrays
297+
.. _indexing properties: https://en.wikipedia.org/wiki/Binary_tree#Arrays
298+
.. _Leetcode: https://leetcode.com/
282299

283300
.. doctest::
284301

0 commit comments

Comments
 (0)