reading-notes

View on GitHub

Trees

Trees types :

Tree components :

image

There are two categories of traversals for trees: Depth First : (use Stack)  There are three methods for depth first traversal: Pre-order: root » left » right In-order: left » root » right Post-order: left » right » root

Breadth First (Use Queue)

The idea of recursion is when we complete a function call, we pop the top node off the stack and are able to continue execution through the previous function call

If root.left and a root.right Both are null, so recursion will end the execution of that method call

Big O The Big O time complexity of a Binary Search Tree’s insertion and search operations is O(h) The Big O space complexity of a BST search is O(1)

The Binary Trees restrict the number of children to two (hence our left and right children) If Nodes of the Tree are able have more than 2 child nodes ,  we call the tree that contains them a K-ary Tree