際際滷

際際滷Share a Scribd company logo
DATA STRUCTURE
D AY 6
BY : M O H A M M E D E L S D O D Y
BINARY SEARCH TREE
Binary Search Tree, is a node-based binary tree data structure which has the following
properties:
 The left subtree of a node contains only nodes with keys lesser than the nodes key.
 The right subtree of a node contains only nodes with keys greater than the nodes
key.
 The left and right subtree each must also be a binary search tree.
There must be no duplicate nodes.
BINARY SEARCH TREE
Tree provide an ordering among keys so that the operations like search,
minimum and maximum can be done fast. If there is no ordering, then we
may have to compare every key to search a given key.
SEARCHING A KEY
 To search a given key in Binary Search Tree, we first compare it with root, if the key is
present at root, we return root. If key is greater than roots key, we recur for right
subtree of root node. Otherwise we recur for left subtree.

More Related Content

Data structure day 6

  • 1. DATA STRUCTURE D AY 6 BY : M O H A M M E D E L S D O D Y
  • 2. BINARY SEARCH TREE Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys lesser than the nodes key. The right subtree of a node contains only nodes with keys greater than the nodes key. The left and right subtree each must also be a binary search tree. There must be no duplicate nodes.
  • 3. BINARY SEARCH TREE Tree provide an ordering among keys so that the operations like search, minimum and maximum can be done fast. If there is no ordering, then we may have to compare every key to search a given key.
  • 4. SEARCHING A KEY To search a given key in Binary Search Tree, we first compare it with root, if the key is present at root, we return root. If key is greater than roots key, we recur for right subtree of root node. Otherwise we recur for left subtree.