table of contents

binary search tree

2024-02-01

a binary search tree is a binary tree that has the following restrictions:

for example the following tree is a binary search tree:

insertion

a new key is always inserted as a leaf. we start from the root, making our way downwards by comparing the new key to the key of the current node to decide which child to move to on each iteration, until we hit a leaf node, then we add the new node as its child