Posts

Showing posts with the label data structure

DATA Structures :Binary Search Trees

Image
Bnary Search Trees Binary tree is a tree that each node in it has maximum of two children. Binary search tree (BST) is a binary tree which its elements positioned in special order. In each BST all values(i.e key) in left sub tree are less than values in right sub tree. This is a simple implementation of Binary Search Tree Insertion using Python. class Node:   def __init__(self, val):  self.l_child = None  self.r_child = None  self.data = val def insert(root, node):        if root is None:             root = node        else :             if  root.data > node.data:                  if root.l_child is None:                       root.l...