Binary Search Trees 5 - Report In Range

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ธ.ค. 2024

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

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

    Doesn't report in range have a run time of theta(n) because you're sifting through every node to determine if they are within the range?

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

      by they I mean the nodes' values

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

      @@joekimeu In the worst case, yes! However, as a simple example: If your tree had only positive values and you try and find the values between -10 and -5, then it will not need to search the whole tree, since it will keep going left until it eventually finds a NIL node meaning there are no nodes that are within the range. In general, the runtime depends both upon the height of the tree and the number of values that actually satisfy the condition

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

      ​@@ProfessorPainter this single comment cleared a dot that I have been trying to connect since 2 days 😂❤ thank you sir ...