Skip to main content

Package providing recursive and iterative binary tree generators.

Project description

This is a package providing recursive and iterative binary tree generators. Each nodes' values are generated using provided functions. (By default, the leaf values are equal to the root value.) Don't take it too seriously. This package was made mainly as educational project.

Installation

pip install binarytrees_nv

Usage

from binarytrees_nv import gen_bin_tree_iterative, gen_bin_tree_recursive

height: int = 4

# recursive
recursive_tree = gen_bin_tree_recursive(height)
# or iterative
iterative_tree = gen_bin_tree_iterative(height)

print(recursive_tree)
print(iterative_tree)


# Custom functions for leaf values
def left_function(x):
    return x ** 2

def right_function(x):
    return x - 2

custom_tree = gen_bin_tree_iterative(height, left_function=left_function, right_function=right_function)

print(custom_tree)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binarytrees_nv-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

binarytrees_nv-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file binarytrees_nv-0.1.0.tar.gz.

File metadata

  • Download URL: binarytrees_nv-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for binarytrees_nv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef83f7a73525405d2774344909cac3acd62eda1b49b10f700214daf61682fd21
MD5 24c775509f2c1b49f9e82e2196916cc8
BLAKE2b-256 3ef1dbc042eff28bb6eaaec812abfef804002d52db0b7dddeefcd756a4fd1ecb

See more details on using hashes here.

File details

Details for the file binarytrees_nv-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for binarytrees_nv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 914d5866a897a15315b41842af1bacc9ad18a3a760c7b05a991101d3de53c36b
MD5 7c8be14468e90381aadacef99cfd6b5e
BLAKE2b-256 45009c3171a6966188566f8803004544b4d8ed6572640211aa2a79518ea0f388

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page