A tree is the hierarchical data structure unlike an array or linked list which are linear.
- You can store hierarchical information using a tree data structure, like an organization structure, family tree, etc.
- A tree has nodes and children. The top or first node is called the root.
- The tree data structure is like an inverted tree in the real world.
- A binary tree is a special tree, where you can have at most two children. This means, one node can either no child, one child, or two children. They cannot have three children or more.
- All the nodes which don't have any children are known as a leaf node.
- Binary Search Tree is a special type of binary tree where values of the left subtrees are less than or equal to root and values of nodes on right subtrees are greater than or equal to root. This provides a sorting structure to a binary search tree, which makes searching really fast.
Post a Comment