binary search treepattarachai/fit/pdf/binarysearchtree.pdf · binary-search-tree property let x be...
TRANSCRIPT
![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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/1.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/5.jpg)
![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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/6.jpg)
![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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/7.jpg)
![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](https://reader036.vdocuments.us/reader036/viewer/2022063013/5fcd2384d326756fef555985/html5/thumbnails/8.jpg)