Valid BST from Preorder | Verify Preorder Sequence in Binary Search Tree

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024

ความคิดเห็น • 32

  • @ayushprakash3890
    @ayushprakash3890 3 ปีที่แล้ว +30

    bro one suggestion... instead of showing what to do it would be better if you told us why we are doing those operations and why specifically stack is used... what if we use a queue instead of stack, can we do the same question using a priority queue.

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว +2

      Noted!

  • @FitCoder
    @FitCoder  3 ปีที่แล้ว +11

    00:00 Introduction
    00:08 Validate BST from Preorder
    02:00 Pseudo Code
    09:47 Implementation

  • @shristisrivastava4468
    @shristisrivastava4468 3 ปีที่แล้ว +2

    Great Explaination Sir!

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      Glad you liked it

  • @rishabhjajoriya2821
    @rishabhjajoriya2821 3 ปีที่แล้ว +3

    Bhaiya why are u not making videos nowadays?
    Ur teaching style is so good

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว +2

      Will resume uploading soon. Busy with some personal stuff. Keep supporting!

  • @Chesstreamer
    @Chesstreamer 2 ปีที่แล้ว +3

    You should explain why recursive method or the first method which strikes our mind is not the best way to go and provide may be a pseudocode for that ,so that anyone preparing for interview have knowledge about implementing that approach also as more often interviewer expect us to build the solution from a slightly worst time complexity to an efficient solution.Just a suggestion for further videos.

    • @FitCoder
      @FitCoder  2 ปีที่แล้ว

      thanks for the feedback :)

  • @codingninja3123
    @codingninja3123 3 ปีที่แล้ว +1

    Great video bro....awesome!

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      thank you :)

  • @sanathkumar3115
    @sanathkumar3115 3 ปีที่แล้ว +3

    You should explain, why it does rather than what it does?

  • @111rhishishranjan2
    @111rhishishranjan2 ปีที่แล้ว

    I think 2 , 4 , 1 can represnt a bst a 2 is root , 4 is on right of it and root for 1.the sequence 2, 4, 1 can represent the preorder traversal of a binary search tree (BST). A preorder traversal of a BST visits the root node first, followed by the left subtree, and then the right subtree. One possible BST that has the preorder traversal 2, 4, 1 is:
    2
    \
    4
    /
    1
    In this tree, the root node is 2, which is visited first. Then the left subtree is empty, so the traversal moves to the right subtree, where it visits the node 4. Finally, the traversal moves to the left subtree of 4, where it visits the node 1. This results in the preorder traversal 2, 4, 1.

  • @sohankapoor6839
    @sohankapoor6839 3 ปีที่แล้ว +1

    Great video!

  • @lizziedaffofil6064
    @lizziedaffofil6064 3 ปีที่แล้ว +3

    Why is the condition "preorder[i] > top of stack" in the pseudocode?

  • @utkarshkushwaha757
    @utkarshkushwaha757 3 ปีที่แล้ว +1

    thanks for this video!

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      welcome :)

  • @hackzyoboy2459
    @hackzyoboy2459 3 ปีที่แล้ว +7

    Abey bro, we could have understood code from GFG(where u have taken this code from). We expected an intuition behind using Stack. You were simply dry running the code, hence disliked your video

    • @FitCoder
      @FitCoder  2 ปีที่แล้ว +1

      thanks for the feedback

  • @harshitverma6026
    @harshitverma6026 3 ปีที่แล้ว +3

    Awesome explanation ! need more such videos ! Just a tiny suggestion.. please use dark theme and code editor like sublime or VS Code !

  • @sudeeshnadeva2855
    @sudeeshnadeva2855 3 ปีที่แล้ว +1

    Good one

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      thanks :)

  • @lizziedaffofil6064
    @lizziedaffofil6064 3 ปีที่แล้ว +3

    Is there an alternate approach using call stack instead of an actual stack?

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว +1

      Yes...this can be done via recursion too.

  • @manjugoswami7063
    @manjugoswami7063 3 ปีที่แล้ว

    Sir can u please make a video on "Construct Binary tree from String with bracket representation ".
    Thankyou

  • @iit_da_munda
    @iit_da_munda 3 ปีที่แล้ว +2

    Try to explain how it is actually doing.

  • @tushar5359
    @tushar5359 ปีที่แล้ว

    not helpful sorry bro

  • @rktpro
    @rktpro 4 หลายเดือนก่อน

    bro showing pre-order traversal first and then creating a tree from it casually. That's not possible