Skip to the content.

Trees Tree Types to discuss : (Links to an external site.)

K-ary Trees :

A tree that have more than two children node. K is used to define the maximum number of children a node can have. To traverse we use a similar approach to breadth first traversal but we have more node than left and right. Traversing K-ary starts by enqueuing the first node and hence we have one node we can dequeue. Then enqueue all the children of the dequeued node. Then we dequeue the front and traverse using it. Repeat until finished. Binary search trees (Links to an external site.) BST have some restrictions other than binary trees which is elements greater than the root are placed on the right side and smaller will be placed in the left.

Searching BST can be done quickly since it compares only height times.

The big O of searching is O(H) which stands for height.