Reading-Notes

View the Project on GitHub MohammadAl-khatib/Reading-Notes

Trees

A tree is a type of data strucures which consists of nodes, each node inturn might be connected to more than one node, a node without any connection is called a leaf, the height of a tree is the highest number of connections found in one path, the parent node is the node with no nodes refrencing it

tree data structure

Traversing:

Means to investigate the content of the tree, here we have 2 approaches:

  1. Depth first
  2. Breadth first

In eighther ways recursion is the heart of traversing, for depth first approach stack is used to track nodes order, for breadth approach queues are used.

Binary Tree Vs K-ary Trees

A tree where each node is related to only two or less nodes is called binary tree, having more nodes will result in a k-ary tree in which k is the largest number of allowable nodes a node can refrence.

Binary Tree

binary tree

k-ary Tree

k-ary tree

For detailed coding see Code Fellows