Creating Binary Search Tree

Creating Binary Search Tree

Suppose the data elements are - 45, 15, 79, 90, 10, 55, 12, 20, 50

  • insert 45 into the tree as the root of the tree

Node Created and inserted Data

  • Insert 15 , First ensure tree is exist or not, if its exist compare with root value , New value is less than root value so create node as left child

15 < 45 so placed in left child

  • Insert 79, 79 is greater than 45, so insert it as the root node of the right subtree

79 > 45 so its inserted into right subtree

  • The above process will be continued until no more data to insert it

To view or add a comment, sign in

More articles by Poonkodi P

  • Quick Sort

    Quick Sort

    Quick Sort is a divide-and-conquer sorting algorithm that works by selecting a pivot element, partitioning the array…

  • Insertion Sort

    Insertion Sort

    Insertion Sort is a simple, intuitive, and comparison-based sorting algorithm. It works similarly to how you might sort…

  • Selection Sort

    Selection Sort

    Selection Sort is a simple comparison-based sorting algorithm. It works by repeatedly selecting the smallest (or…

  • Bubble sort

    Bubble sort

    Bubble Sort is a simple and straightforward sorting algorithm used to sort a list (or array) in either ascending or…

  • Non-Comparison-Based Sorting Algorithms

    Non-Comparison-Based Sorting Algorithms

    #snsdesignthinkers #snsinstitutions #designthinking These algorithms do not rely on comparing elements directly but…

  • Comparison-Based Sorting Algorithms

    Comparison-Based Sorting Algorithms

    #snsdesignthinkers #snsinstitutions #designthinking These algorithms compare elements in the array and sort them based…

  • Sorting

    Sorting

    Sorting is a fundamental operation in computer science, particularly in the field of data structures and algorithms. It…

  • External Sorting

    External Sorting

    External Sorting is a class of algorithms used for sorting data that is too large to fit into the computer's main…

  • Binary Tree

    Binary Tree

    #snsdesignthinkers #snsinstitutions #designthinking A binary tree is a data structure in which each node has at most…

  • Tree ADT

    Tree ADT

    A Tree Abstract Data Type (ADT) is a hierarchical data structure that consists of nodes connected by edges. It is used…

Insights from the community

Others also viewed

Explore topics