Difference between Binary Tree and Binary Search Tree
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 children.
Binary Search Tree Data Structure
A binary Search Tree is a node-based binary tree data structure that 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 is a nonlinear data structure where each node can have at most two child nodes.
|BINARY SEARCH TREE is a node based binary tree that further has right and left subtree that too are binary search tree.
- Full binary tree
- Complete binary tree
- Extended Binary tree and more
- AVL tree
- Splay Tree
- T-trees and more
|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.
|Data Representation is carried out in a hierarchical format.
|Data Representation is carried out in the ordered format.
|Binary trees allow duplicate values.
|Binary Search Tree does not allow duplicate values.
|The speed of deletion, insertion, and searching operations in Binary Tree is slower as compared to Binary Search Tree because it is unordered.
|Because the Binary Search Tree has ordered properties, it conducts element deletion, insertion, and searching faster.
|Time complexity is usually O(n).
|Time complexity is usually O(logn).
|It is used for retrieval of fast and quick information and data lookup.
|It works well at element deletion, insertion, and searching.
|It serves as the foundation for implementing Full Binary Tree, BSTs, Perfect Binary Tree, and others.
|It is utilized in the implementation of Balanced Binary Search Trees such as AVL Trees, Red Black Trees, and so on.
Share your thoughts in the comments
Please Login to comment...