Can anyone please explain the difference between binary tree and binary search tree with an example?
In Binary Search tree, the height or depth of the tree is O(n) where n is the number of nodes in the Binary Search tree. In AVL tree, the height or depth of the tree is O(logn). It is simple to implement as we have to follow the Binary Search properties to insert the node.
Given a Binary Tree, figure out whether it's a Binary Search Tree. In a binary search tree, each node's key value is smaller than the key value of all nodes in the right subtree, and are greater than the key values of all nodes in the left subtree i.e. L < N < RL<N<R.
Binary tree: Tree where each node has up to two leaves
1 / \ 2 3
Binary search tree: Used for searching. A binary tree where the left child contains only nodes with values less than the parent node, and where the right child only contains nodes with values greater than or equal to the parent.
2 / \ 1 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With