8
Binary Search Tree Binary Search Tree

Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key

Binary Search Tree

Binary Search Tree

Page 2: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key

Binary-Search-Tree Property

� Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key <= x.key. If y is a in the left subtree of x, then y.key <= x.key. If y is a node in the right subtree of x, then y.key >= x.key.

Page 3: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key

Binary-Search-Tree Operations

� Searching

� Minimum� Minimum

� Maximum

� Successor

� Predecessor

� Insertion

Deletion� Deletion

Searching

Page 4: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key

Given a pointer to the root of the tree and a key k, TREE-SEARCH returns a pointer to a node with key k if one exists; otherwise, it returns NIL.

Page 5: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key
Page 6: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key
Page 7: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key
Page 8: Binary Search Treepattarachai/FIT/PDF/BinarySearchTree.pdf · Binary-Search-Tree Property Let x be a node in a binary search tree. If y is a node in the left subtree of x, then y.key