diff --git a/README.md b/README.md index 98b22d0..44cac3b 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/docs/overview.rst b/docs/overview.rst index b1447d6..6c820bc 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -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: @@ -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::