Binary Tree Data Structure
A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.
Binary Search Tree Data Structure
Binary Search Tree is a node-based binary tree data structure which has the following properties:
- The left subtree of a node contains only nodes with keys lesser than the node’s key.
- The right subtree of a node contains only nodes with keys greater than the node’s key.
- The left and right subtree each must also be a binary search tree.
- There must be no duplicate nodes.
Difference between Binary Tree and Binary Search Tree:
|BINARY TREE||BINARY SEARCH TREE|
|BINARY TREE is a non linear data structure where each node can have almost two child nodes||BINARY SEARCH TREE is a node based binary tree which further has right and left subtree that too are binary search tree.|
|BINARY TREE is unordered hence slower in process of insertion, deletion and searching.||Insertion, deletion, searching of an element is faster in BINARY SEARCH TREE than BINARY TREE due to the ordered characteristics|
|IN BINARY TREE there is no ordering in terms of how the nodes are arranged||IN BINARY SEARCH TREE the left subtree has elements less than the nodes element and the right subtree has elements greater than the nodes element.|