reading-notes

View on GitHub

Tree

A tree is a data structure like Stacks, Queues and LinkedLists

A tree consists of the following:

Simple Tree

Binary Search Tree (BST)

for binary search tree the structure of it as follow:

as shown in the image below:

Binary Search Tree

searching for a value in a binary search tree, done by looping until meet the last leaf and the time complexity is O(height)

the tree heigth(the number of edges between the root and the last leaf)

and the space complexity is O(1) because searching a binary tree does not allocate and extra space.