A&DS S01E05. Binary Search

Поделиться
HTML-код
  • Опубликовано: 8 окт 2020
  • Algorithms and data structures. Semester 1. Lecture 5.
    In the fifth lecture, we talked about various applications of the binary search algorithm, as well as the ternary search algorithm.
    Home task and discussion: codeforces.com/blog/entry/83518
    ITMO University, 2020

Комментарии • 22

  • @chuka231d8
    @chuka231d8 3 года назад +20

    Content of this lecture:
    1. Into of Binary Search & naive implemention
    2. Lower_bound & Upper_bound implementation
    3. 2 sample problems covering int and double implementations
    4. Ternary Search

  • @saikoushik1018
    @saikoushik1018 3 года назад +4

    Thank You sir, Its very helpful for me.. Please continue to teach these data structures and algorithms
    sir.

  • @maninandadeepmedicharla6213
    @maninandadeepmedicharla6213 3 года назад +2

    @Pavel Mavrin fantastic videos really helped a lot. keep posting these kinds of videos

  • @shubhamagarwal2998
    @shubhamagarwal2998 3 года назад +6

    Thanks
    Thanks
    Thanks
    Thanks
    Thanks
    Thanks
    -
    -
    -
    -
    -
    Thanks
    Thanks
    Thanks

  • @jonathanandres1657
    @jonathanandres1657 3 года назад

    Thanks!

  • @franky0226
    @franky0226 3 года назад

    Thanks!♥️

  • @yashmalik815
    @yashmalik815 3 года назад +2

    @Pavel Mavrin are these lectures any different from those in the EDU section of codeforces??

    • @blitztage3245
      @blitztage3245 3 года назад +3

      Yes, those lectures are from the perspective of competitive programming whereas these lectures are similar to the ones taught in a Data Structures and Algorithms course in universities

    • @vijaykushwah1414
      @vijaykushwah1414 Год назад

      ​@@blitztage3245can u plz send link of that videos/playlist

  • @devjoytibarman7623
    @devjoytibarman7623 3 года назад

    thanks

  • @abhiraj9990
    @abhiraj9990 3 года назад

    @Pavel Mavrin why in 2nd Method r>l+1 ?

    • @pavelmavrin
      @pavelmavrin  3 года назад +2

      We need to stop the loop when l and r point to adjacent elements, that is r = l + 1

  • @madhukiranattivilli2321
    @madhukiranattivilli2321 2 года назад

    Hi Pavel,
    Your "get the peak point in a curve" problem, which u solved using ternary search (TS)...
    Can be effectively solved using BS also, I'm feeling :
    loop
    break, if r f(m+1) -- as we're on the "falling" section of the curve
    l=m, if f(m) < f(m+1) -- as we're on the "raising" section of the curve
    endloop
    outside the loop -- r == l+1
    return l, if f(l) > f(r)
    return r
    2 questions :
    (1) Is this good enough? Or, like yesterday did I once again make a silly mistake?
    (2) Could you please suggest PROBLEMS where TS is more effective than BS?
    Thanks,
    Madhukiran

    • @pavelmavrin
      @pavelmavrin  2 года назад +1

      That‘s fine if the function has integer argument. If the argument is a real number, you need something like f(m) < f(m + eps), and then you will have accuracy problems

    • @madhukiranattivilli2321
      @madhukiranattivilli2321 2 года назад

      @@pavelmavrin When does algo end with real numbers? f(m)f(m+eps) sets r=m. We've to stop at some point. Should we've to pre-decide the PRECISION LIMIT, and stop the algo when the precision-limit becomes > eps?
      When real numbers are used with TS, is this how we stop the algo?
      set m_limit = precision
      loop
      -- compute m1, m2 from l, r
      -- break, if abs(f(m1) - f(m2)) < m_limit
      -- rest-of-TS-algo
      endloop
      Can precision be nano (10⁻⁹) or pico (10⁻¹²)???

  • @nikunjjayas4520
    @nikunjjayas4520 2 месяца назад

    Predicate search....

  • @prajwalchoudhary4824
    @prajwalchoudhary4824 3 года назад +3

    30:06

  • @miku6701
    @miku6701 3 года назад +1

    45:35 Minecraft villager noises