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

要查看或添加评论,请登录

Poonkodi P的更多文章

  • Buzzwords

    Buzzwords

    1. Object-Oriented Java follows the Object-Oriented Programming (OOP) paradigm, which includes concepts like…

  • Features of OOP

    Features of OOP

    Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects, which encapsulate data and…

  • Concepts of OOP

    Concepts of OOP

    Class: A blueprint for creating objects. It defines properties (also called attributes) and methods (also called…

  • Object Oriented Programming

    Object Oriented Programming

    Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects." Object-Oriented…

  • 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…

社区洞察

其他会员也浏览了