Binary Search Tree

Binary Search Tree is a binary tree based on nodes that has a certain attribute such as


  • that the left node is smaller than its parents' node
  • that the right node will always be bigger than its parents' node
  • that both nodes must also be binary search tree and therefore cannot contains duplicates

Above is an example of a Binary Search Tree

Binary search tree can perform several operations such as:
  • Searching, By comparing its roots to its nodes a program can climb through the node of a Binary search tree and find a specific node. by checking each root, comparing it to what it searched for climbing down to find the right node.
    • sample code for searching in BST
  • insertion, an operation to input certain data unto the Binary search tree on a specific node in the tree. by creating a space pushing the node and creating a new node either in the middle, the end or the beginning. 
    • sample code of insertion in BST
  • Deletion, an Operation that removes a node from the binary search tree and refills that certain location with a corresponding node
    • sample code of deletion in BST
  • Traversal, an operation to display the nodes of the binary search tree in several ways such as inorder, postorder and pre-order
    • sample code of traversal in BST









Komentar

Postingan populer dari blog ini

AVL Tree & B-Tree

Summary