Python Program To Implement Binary Search Tree | Program 7 | Min and Max Key

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • In this Python Programming video tutorial you will learn how to implement binary search tree in detail.
    Data structure is a way of storing and organising the data so that it can be accessed effectively.
    Tree is a non linear data structure contains group of nodes connected via links or edge.
    Binary search tree is a special type of binary tree . Here we will use class and object concept to implement binary search tree. In this tutorial we will see how to find minimum and maximum node in tree.
    #DataStructures #PythonPrograms #Tree
    For more free tutorials on computer programming
    / amulsacademy
    AmulsAcademy

КОМЕНТАРІ • 22

  • @pratikmahore852
    @pratikmahore852 2 роки тому +9

    Via recursion 👇🏻
    def min_node(self):
    If self.lchild:
    self.lchild.min_node()
    elif self.lchild is None:
    print("min node :" ,self.key)

  • @ramakrishna4383
    @ramakrishna4383 3 роки тому +2

    This will find also by using recursive function na madam

  • @janardhan6752
    @janardhan6752 2 роки тому

    Amulya if we want to get the position of an node while searching ,is it possible ? Because In the previous code ,we could only know the key is present in the tree or not ,but we couldn't know the position of the key

  • @charchitmangal
    @charchitmangal 2 роки тому

    def minimum(self):
    if self.lchild==None:
    return self.key
    else:
    self.lchild.minimum()
    def maximum(self):
    if self.rchild==None:
    return self.key
    else:
    self.rchild.maximum()

  • @nandeesh5820
    @nandeesh5820 2 роки тому

    mam we need to apply break statement to terminate the while loop
    def min(self):
    current=self
    while current.left:
    current=self.left
    break
    print('the min is: ',current.root)

    def max(self):
    current=self
    while current.right:
    current=self.right
    break
    print('the max is:',current.root)

  • @rohitkamble8515
    @rohitkamble8515 2 роки тому

    Thank you so much for wonderful content.😎👌👌🙌🙌🙌

  • @zainabbohra2915
    @zainabbohra2915 3 роки тому +3

    mam can you please implement it and explain it?please mam if possible , and mam you are also not uploading any videos

  • @prathameshmore5262
    @prathameshmore5262 2 роки тому

    why we didnt write current = self.key except self

  • @nagendrabommireddi8437
    @nagendrabommireddi8437 2 роки тому

    what will happen when tree is empty

  • @shaimaagoda2954
    @shaimaagoda2954 9 місяців тому

    you are amazing 🤩

  • @reddyraviteja7702
    @reddyraviteja7702 2 роки тому

    def min_node(self):
    current=self
    while current.lchild:
    current=self.lchild
    print("The min value in the tree is",current.key)
    def max_node(self):
    current=self
    while current.rchild:
    current=self.rchild
    print("The max value in the tree is",current.key)
    infinite loop coming is mam

    • @RohitSingh-ko2cz
      @RohitSingh-ko2cz 2 роки тому

      you need to use current.lchild in 4th line instead of self.lchild becz self value in not changing, same for max_node function.

    • @nandeesh5820
      @nandeesh5820 2 роки тому

      def min(self):
      current=self
      while current.left:
      current=self.left
      break
      print('the min is: ',current.root)


      def max(self):
      current=self
      while current.right:
      current=self.right
      break
      print('the max is:',current.root)
      we need to apply break statement to terminate te while loop

  • @selvanm2872
    @selvanm2872 3 роки тому +2

    👍

  • @shubhankarsingh4065
    @shubhankarsingh4065 3 роки тому +1

    thanks

  • @datafuse32
    @datafuse32 3 роки тому

    if self.key is None:
    print("Tree is empty")
    return
    if self.lchild:
    node=self.lchild
    while node.lchild :
    node = node.lchild
    print(node.key,"is the min number")
    else:
    print(self.key,"is the min key")

  • @umairbijapure7584
    @umairbijapure7584 3 роки тому

    Is there any Trie structure video??