Reading_Notes

View the Project on GitHub Hiba-Almade/Reading_Notes

Trees


Traversal: search for a node, and print the contents of the tree.

Two categories of scans:

  1. Depth First :

>> 3 ways to depth first:

pre-order: root >> left >> right

in order: left >> root >> right

later order:left >> right >> root

  1. breadth first:

iterates through the tree by going through each node level of the tree one by one


Binary tree vs K-ary trees

Binary trees:

limit the number of children to two, there is no specified sort order, and nodes can be added in a binary tree wherever space permits

K-ary Trees:

nodes that can have more than two children. K indicates the maximum number of children each node can have

The time complexity of insertions and searches in a binary search tree is O(n).