Binary Search Trees: Construction, Traversal, and Operations

binary search tree n.w
1 / 14
Embed
Share

Explore the world of binary search trees through definitions, construction techniques, traversals, and operations like inserting and deleting elements. Learn the intricacies of maintaining the BST structure efficiently.

  • Binary Search Trees
  • Construction
  • Traversal
  • Operations
  • Data Structures

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. BINARY SEARCH TREE

  2. DEFINITION: A binary tree is called binary search tree(T) if each node N of T has the property: The value at N is greater than every value in the left sub tree of N and less than or equal to every value in the right sub tree of N.

  3. CONSTRUCTION OF BINARY SEARCH TREE (using linked list)

  4. TRAVERSING BINARY SEARCH TREES There are three standard ways of traversing a binary search tree T with root R. These three algorithms are called preorder, in order, post order. Preorder (p) If p! =null Visit info (p) Preorder (left (p)) Preorder (right (p))

  5. In order (p) If p! =null In order (left (p)) Visit info (p) In order (right (p)) Post order (p) If p! =null Post order (left (p)) Post order (right (p)) Visit info (p) Note: complexity for traversing the binary search tree is O (n)

  6. INSERTING AN ELEMENT

  7. DELETION OF AN ELEMENT The procedure for deleting a given node z from a binary search tree has 3 cases 1. If z has no children, we modify its parent p[z] to replace z with nul as its child.

  8. 2. If the node has only a single child, we slice out by making a new link between its child and its parent.

  9. 3. If the node has two children, we slice out zs successor y, which has no left child and replace z s

More Related Content