📜  二叉树和二叉搜索树之间的区别

📅  最后修改于: 2021-05-24 21:28:12             🧑  作者: Mango

二叉树数据结构

元素最多具有2个子代的树称为二叉树。由于二叉树中的每个元素只能有2个子代,因此我们通常将它们命名为左子代和右子代。

二叉搜索树数据结构

二进制搜索树是基于节点的二进制树数据结构,具有以下属性:

  • 节点的左子树仅包含键值小于节点键值的节点。
  • 节点的右子树仅包含键大于该节点的键的节点。
  • 左和右子树也都必须是二叉搜索树。
  • 不得有重复的节点。

二叉树和二叉搜索树之间的区别:

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.