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

📅  最后修改于: 2021-09-14 02:13:04             🧑  作者: 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.

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程。