These are some BST algorithms designed to review BSTs.
# --------------------------------------------------
# 1. To generate a random BST
python
import binarytree
# binarytree.bst(height=3, is_perfect=False)
bst = binarytree.bst()
bst.values
# 2. To generate a printout for reference
bst.pprint(bst)
# Copy the output value ex. [14, 13, None, 4, None, None, None, 2, 12]
# In test case:
import binarytree
root = binarytree.build([14, 13, None, 4, None, None, None, 2, 12])
# For more see https://binarytree.readthedocs.io/en/latest/specs.html#binarytree.bst
./settings.json
will provide recommended setup. Accept any installs requested to re-use.
pyenv
is installed on latest, and withpip
andpipenv
modules (different if not Ubuntu):
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
curl https://pyenv.run | bash
- Read the output of the
pyenv
install script, it will ask you to add to~/.bashrc
and/or~/.zshrc
the following (different if not on Ubuntu):
export PATH="/home/quincy/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
- ~/.profile or ~/.zshrc contains
pipenv
onPATH
(different if not Ubuntu):
#Contents of ~/.profile
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
- Enter python dir, use
pipenv
with specified versions (say yes to installign python ver), and run tests withgreen
cd ./python_leetcode
pipenv --rm
pyenv install
pipenv shell
pipenv install
green
- Python Test Explorer
- Black formatter
- Open wsl.conf within Ubuntu WSL
sudo vim /etc/wsl.conf
i
for insert, then paste:
[automount]
enabled = true
options = "metadata"
mountFsTab = false
- Restart
- If prompted, you can now
chmod 600 ./Pipenv
.