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:

S. No.Basis of ComparisonBINARY TREEBINARY SEARCH TREE
1.DefinitionBINARY 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.
2.Types
• Full binary tree
• Complete binary tree
• Extended Binary tree and more
• AVL tree
• Splay Tree
• T-trees and more
3.StructureIn BINARY TREE there is no ordering in terms of how the nodes are arrangedIn BINARY SEARCH TREE the left subtree has elements less than the nodes element and the right subtree has elements greater than the nodes element.
4.Data RepresentationData Representation is carried out in a hierarchical format.Data Representation is carried out in the ordered format.
5.Duplicate ValuesBinary trees allow duplicate values.Binary Search Tree does not allow duplicate values.
6.SpeedThe 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.
7.ComplexityTime complexity is usually O(n).Time complexity is usually O(logn).
8.ApplicationIt is used for retrieval of fast and quick information and data lookup.It works well at element deletion, insertion, and searching.
9.UsageIt 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.

Previous
Next