Binary search in 4 minutes

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

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

  • @theatticbywik8238
    @theatticbywik8238 2 года назад +201

    another day, another person's semester you just saved

    • @MichaelSambol
      @MichaelSambol  2 года назад +25

      Boom! Awesome.

    • @masterhimanshu8467
      @masterhimanshu8467 5 месяцев назад +2

      Lmao I am having my practical today and I am doing this now... That too without laptop... 😂 And I have to do it in C language lol

  • @harshvardhansingh5507
    @harshvardhansingh5507 Год назад +15

    CS UG student here, you are precise and to the point which makes you different from rest of the creators

  • @NeerajSamshette
    @NeerajSamshette 11 месяцев назад +9

    Best video on binary search I've found, straight to the point with well made animations. Thanks a lot Michael!

  • @amitos1646
    @amitos1646 Год назад +18

    Damn. I am commenting a bit late but man it's people like you who help me keep on coding and not giving up. Thank you! Amazing content.

  • @nalskipper7447
    @nalskipper7447 Год назад +14

    Thank you for using a black background and white text. All of your older sorting algorithm videos were really helpful.

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

    u r singlehandedly making algorithms easy for people keep it upppppp

  • @BirukBelayneh-rq2we
    @BirukBelayneh-rq2we 21 день назад +2

    damn, this is amazing and exactly what i wanted as a python beginner currently. thanks Michael

  • @theanamex9969
    @theanamex9969 Год назад +11

    Your code is so simple and easily understandable, it helped a lot. My professor had 3 slides on it, very yuck. Thank you so much!

  • @glenn7422
    @glenn7422 Год назад +2

    such a great explanation, I love your calmness

  • @sudhirms6507
    @sudhirms6507 10 месяцев назад

    Ur the goat bro I just watch ur vids 1 hr before the exam and covered the entire 5 months syllabus ,🔥🔥

  • @yorgodev
    @yorgodev Год назад +2

    Cool stuff Michael! Keep up the great work!

  • @hojongyu8243
    @hojongyu8243 Год назад +3

    Amazing explanation. Thank you!

  • @Czarcasm.
    @Czarcasm. 5 месяцев назад

    reviewing for a data structures quiz rn, this was exactly what i was looking for! 💪very clear and helpful explanation :3

  • @Anonymous-ri4mk
    @Anonymous-ri4mk 2 месяца назад

    Oh this makes it so much easier i was watching the visualisation but i just get confused lol since i am not very perceptive thank you this helps a lot

  • @okok-sc2cx
    @okok-sc2cx Год назад +1

    Please please please keep making videos, I watch your videos everyday, you make my day, thank you

    • @MichaelSambol
      @MichaelSambol  Год назад +1

      More coming! 4 weddings in October stalled my progress. Thank you for watching!

    • @ZandalfBunt
      @ZandalfBunt Год назад +6

      @@MichaelSambol 4 wives? As expected of Mr. Sambol.

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

    Nicely explained!

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

      thank you! I appreciate you watching.

  • @SunsetsOverBatteryCity
    @SunsetsOverBatteryCity 6 месяцев назад

    Him: “quick sort=pivot”
    Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”

  • @DavidZapata-q4n
    @DavidZapata-q4n 6 месяцев назад +1

    I watched previously the video where you explain the Big-O Notation, in it you showed ant the end that in a "IF -> ELSEIF -> ELSE" the time complexity would be O(n^2).
    At 2:47 there was an "IF -> ELSEIF -> ELSE" why is the time complexity in this case O(log n) and not O(n^2)?

    • @MichaelSambol
      @MichaelSambol  6 месяцев назад

      Might be helpful to watch the whole playlist on analyzing algorithms: ruclips.net/p/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv

  • @t_ahmad
    @t_ahmad 2 года назад +4

    Great Explaination! Could you make a video on Linear Search is well?
    :)

  • @eliyoung9406
    @eliyoung9406 5 месяцев назад

    Bro is actually a godsend

  • @ziyad7780
    @ziyad7780 Год назад +1

    i like your explanation:) keep it up

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

    hey, try median bucket sort, its 2n log n, ie, first linear median search O(n) then split the elements to two buckets, repeat for sub-buckets

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

    0:35 generally it will be rounding down since int always kind off round down by default in more languages

  • @vraimoi
    @vraimoi 4 месяца назад

    great vid man keep it up

  • @jakubrembiasz8942
    @jakubrembiasz8942 5 месяцев назад

    amazing video keep it up!

  • @techytech07
    @techytech07 Год назад +1

    Just a quick question, after finding the average of index, if that mid position happens to land on the target index, does the search stop and the target is found?

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

      yep. see code here: github.com/msambol/youtube/blob/master/search/binary_search.py

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

      @@MichaelSambol Great! thanks a lot

  • @nurpaujiana4664
    @nurpaujiana4664 Месяц назад

    thanks bro, iam understand now

  • @magma6554
    @magma6554 Год назад +1

    you are a legend

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

    thank you so much !

  • @nerfornada-
    @nerfornada- Год назад

    THANK YOU

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

    bro should be known by more people

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

    Curious if it would behoove the algorithm to check if either left, right, or mid is the answer

  • @Tyore_0
    @Tyore_0 5 месяцев назад +1

    can you make one on linear searches

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

    thank you

  • @MrBurn666
    @MrBurn666 10 месяцев назад

    Whats the purpose of returning specifically -1 if the target value is not found? Why not simply state that the target wasnt found?

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

    lifesaver

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

    These search routines are canned so you can just grab them and use them

  • @rain_yy
    @rain_yy 6 месяцев назад

    nice explanation but how do i know the time complexity?

    • @rain_yy
      @rain_yy 6 месяцев назад

      do i calculate or something? hehe

    • @MichaelSambol
      @MichaelSambol  6 месяцев назад +1

      Take a look here, this should help: ruclips.net/p/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv

    • @rain_yy
      @rain_yy 6 месяцев назад

      thank you Sir !! @@MichaelSambol

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

    👏👏

  • @head-lag
    @head-lag Год назад

    niceeee

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

    Why not return array[mid], why return mid I don't understand

    • @MichaelSambol
      @MichaelSambol  Год назад +1

      The code returns the index/location of the element you're searching for: github.com/msambol/youtube/blob/master/search/binary_search.py.

    • @maxheinwal5084
      @maxheinwal5084 8 месяцев назад

      if you return array[mid], you would return the number you are looking for, because mid is the index of the wanted number.

  • @jwinwithin5124
    @jwinwithin5124 5 месяцев назад

    what if the number 29, how will it work

    • @MichaelSambol
      @MichaelSambol  5 месяцев назад

      Try it here :) github.com/msambol/dsa/blob/master/search/binary_search.py

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

    why do we return -1?

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

      returning -1 if key is not in the array. otherwise return the key: github.com/msambol/dsa/blob/master/search/binary_search.py#L9

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

    There are 14 numbers in this LIST.. so Average should be (0,14)=7

    • @MichaelSambol
      @MichaelSambol  Год назад +1

      It's by index in the array... so 0 and 13. See code here: github.com/msambol/dsa/blob/master/search/binary_search.py

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

      @@MichaelSambol Thank you!!! =)

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

    𝓅𝓇𝑜𝓂𝑜𝓈𝓂 ✔️