Binary Search Tree (BST) Worst Case

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025
  • What is the worst-case time complexity to search an element in a binary search tree (BST) ?
    ►Binary Search Tree Videos:
    Binary Search Tree (BST) Worst Case: • Binary Search Tree (BS...
    Binary Search Tree Example: • Binary Search Tree Exa...
    Binary Search Tree Algorithm: • Binary Search Tree (BS...
    Create A Binary Search Tree: • Create A Binary Search...
    Check out my site: www.EverythingComputerScience.com
    Please subscribe for more videos and updates !
    Resources:
    Website:
    typeocaml.com/2...
    University of Wisconsin:
    pages.cs.wisc.e...
    pages.cs.wisc.e...
    NYU:
    cs.nyu.edu/cou...
    StackOverFlow:
    stackoverflow.c...

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

  • @playdoughfunrs
    @playdoughfunrs 6 ปีที่แล้ว

    thanks man I have a midterm today and this helped a lot

  • @TheAmeer3881
    @TheAmeer3881 5 ปีที่แล้ว

    O(n) because a binary search tree, also called an ordered search tree, can in the worst case be represented by bad data input (1,2,3) for example. If I wanted to find 3, I would need to traverse N elements. If I had balanced data (2,1,3) then to find 3, I would need to traverse only the height of the tree, which is O(log n)

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

    How many worst cases are there for N nodes?

  • @mayankrawat3942
    @mayankrawat3942 5 ปีที่แล้ว +1

    Height of the 2nd tree is not 4 its 3.
    Now, how will it be proved that worst case time complexity is O(no. Of nodes)?

  • @ianwashburn2012
    @ianwashburn2012 8 ปีที่แล้ว +1

    i think you are referring to depth when you say height. not bad though. clear, short explanation.

  • @newtocamelot
    @newtocamelot 9 ปีที่แล้ว +1

    So if I wanted to do an inorder traversal of the tree and print the data, the complexity would be O(n)?

    • @yatharth_er
      @yatharth_er 7 ปีที่แล้ว

      yes , definately it will.

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

    For the first tree you drew, the height should have been 2 and for the second one it should have been 3 because you don't count the root node. Your welcome :)

  • @confused6526
    @confused6526 7 ปีที่แล้ว

    Your explanation of the worst case for BST is correct; however, all of your notations and are incorrect.

    • @randerson112358
      @randerson112358  7 ปีที่แล้ว

      Hi,
      Could you explain what you mean please, that way if I did make a mistake I can correct it ?
      Thanks;
      randerson112358

    • @confused6526
      @confused6526 7 ปีที่แล้ว

      mohammad khizar already pointed out.

  • @numowrestler
    @numowrestler 9 ปีที่แล้ว +1

    ur awesome