Check if a tree is bst or not

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ส.ค. 2024
  • This video explains how to check if a given binary tree is a binary search tree or not in simplest way possible. I have explained the concept of a BST first (including the cases when you can call a binary tree as BST). After concepts, i have explained the algorithm for determining a binary tree to be a BST. CODE LINK is given below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    CODE LINK: drive.google.c...

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

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

    Highest underrated channel in tech field. Hats off to your explanation.

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

      Thanks :)

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

      Now folks can tip, so vote with $$

  • @HimanshuKumar-xz5tk
    @HimanshuKumar-xz5tk 3 ปีที่แล้ว +8

    I really don't know what these 8 dislikers want
    This is such an awesome explanation!
    I appreciate all the work you do, thank you so much brother

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

      Welcome :)

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

      @@trigger3012 bro optimization to ho phle normal navie approach to sikh lo

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

      @@trigger3012 It's O(n) , every node is visited only once.

    • @259_parthpatidar9
      @259_parthpatidar9 3 ปีที่แล้ว

      @@ashutoshtiwari4719 hold my backtracking

  • @sidharthansidhu4783
    @sidharthansidhu4783 7 หลายเดือนก่อน

    This is the clearest explanation of this topic that I have found on the internet.

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

    This channel is like a motivation to all NON TECH college students that with determination you can go for tech jobs

  • @sb-jo2ch
    @sb-jo2ch 2 ปีที่แล้ว +2

    This explanation finally clicked for me. Thanks!

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

    Excellent explanation with examples 🙏🙏, thank you sir

  • @abhaytiwari6411
    @abhaytiwari6411 4 ปีที่แล้ว +2

    # 1 Like
    plz upload video quickly
    because i feel bored
    when you are not uploding video

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Bro i am home right now. Will upload quickly once I reach my workplace :) These are advance videos which i already made.

    • @abhaytiwari6411
      @abhaytiwari6411 4 ปีที่แล้ว +1

      @@techdose4u OK

  • @TomerBenDavid
    @TomerBenDavid 4 ปีที่แล้ว +5

    Excellent explanation would be great also to see some Java code

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +6

      Bro i dont know java. I need to copy it from somewhere but i cant explain if something goes wrong. That's why i don't upload java codes :(

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

      System.out.print(checkBST(root, 0, 100));// print
      bool checkBST(Node root, int min, int max) {
      if (root == null) return true; // BST
      if (root.value >= min && root.value

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

      I more thing to coder, it'll work only with checkBST, isBST method from your source code should be removed.

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

    this code is not working in gfg practice question

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

    Excellent explanation!!! thank you!

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

    very good explanation. do you have iterative solution as well?
    thanks a lot.

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

      Don't remember

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

    For a valid binary tree inorder traversal has to be increasing in nature right .. Can we do that ?

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

      No. For an invalid case the inorder might still be increasing.

  • @ryan-bo2xi
    @ryan-bo2xi 4 ปีที่แล้ว +3

    Excellent !

  • @SumitSingh-wn5se
    @SumitSingh-wn5se 4 ปีที่แล้ว +5

    [2147483647,2147483647] what about this test case?
    it would def fail.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +4

      You need to make modifications depending on constraint dude. If your value contains INT_MAX then either modify your if condition or take a larger MAX/MIN by using long. Simple.

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

      Simply use :
      Long min= -pow(2,31)-1
      Long max= pow(2,31)+1

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

      @@anupriyanishad why can't be done here
      long min =INT_MIN-1;
      long max= INT_MAX+1;
      it is actually showing error
      runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'

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

    Thankyou sir, You are the best

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

    best explaination

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

    very well explained

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

    Great, but what about time and space complexity

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

    Could you please help me to resolve the issues when root->right=NULL or root->left=root->data.

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

    do explain the coding also , explaination itself sometimes is not enough , we get stuck in coding sometimes. ,if possible add code in java also, not only c++

  • @baidya87
    @baidya87 4 ปีที่แล้ว +2

    thank you !

  • @shashankpagrut8415
    @shashankpagrut8415 4 ปีที่แล้ว +1

    Thank You

  • @mahesh4274
    @mahesh4274 4 ปีที่แล้ว +2

    Please explain the code also...

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      If you face doubt in any part of the code then do let me know.

    • @maheshm4292
      @maheshm4292 4 ปีที่แล้ว +1

      @@techdose4u if you don't mind, can you share the code through gist, or github , in the future videos maybe. Good night. Happy new year. 🎉

    • @maheshm4292
      @maheshm4292 4 ปีที่แล้ว

      @@techdose4u if doubt, how should I let you know , through comments or any other way????

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Same to you :)

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Through comments. If i couldn't reply and it's urgent then you can use mail.

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

    3:13