BS-1. Binary Search Introduction | Real Life Example | Iterative | Recursive | Overflow Cases

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

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

  • @takeUforward
    @takeUforward  Год назад +109

    Please comment understood and give us a like if you got everything :)

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

      Sir if possible can you please make a series on sliding windows ,2 pointers after this

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

      Salute to your dedication sir

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

      ​@@sabyasachibiswal7790 as he is following the a2z sheet so i think next will be on string. Sliding window is on step 10 so it will take time i think.

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

      now 2023 c++ , pls dont skip java , again saying refactor entire sries java , tell me bench how many projects u get C++

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

      all people now doing dsa java foregt C++ in next 2 years recession

  • @playtune9217
    @playtune9217 Год назад +54

    This guy does amazing work. If I can grasp it, anyone can follow this playlist. thanks man.

  • @Slice32gaming
    @Slice32gaming Год назад +9

    bhoat sahi bro masta kaam kar raha hai tu .jo loag course afford nahi kar shakte unko free maine sikha raha .India need people like you

  • @nilesh69420
    @nilesh69420 7 месяцев назад +12

    26:03 Just a small correction at line 6. It should be mid - 1 instead of high - 1. I checked in striver's website and it is correct there. Also, Excellent explanation as always.

  • @CodePinaka
    @CodePinaka Год назад +85

    "Raj" may be not in dictionary, but one thing is sure that "Raj" is in our heart :)

  • @SiddhiAgrawal-m5l
    @SiddhiAgrawal-m5l 2 месяца назад

    🎯 Key points for quick navigation:
    00:02:00 *🕰️ The video aims to explain binary search comprehensively, covering real-world examples, coding problem examples, and both iterative and recursive implementations.*
    00:01:23 *📚 Binary search can be understood using a dictionary example, which is organized alphabetically and allows for efficient searching.*
    02:44 *📖 Binary search can be applied when searching in any sorted search space, such as an array or dictionary, making it highly efficient.*
    03:55 *🔄 Binary search involves repeatedly dividing the search space in half to efficiently locate a target item.*
    06:06 *📋 Pseudocode for the iterative binary search is introduced, explaining the logic behind updating search bounds based on target comparisons.*
    12:55 *🔍 If a binary search exhausts the search space without finding the target, it returns -1, indicating the target is not present.*
    16:48 *📝 The iterative binary search code is presented, demonstrating the efficiency of this method in practice.*
    17:18 *⚙️ Recursive implementation focuses on solving the problem through repeated function calls, with similar steps to the iterative approach.*
    20:45 *🚫 Base case in a recursive binary search occurs when the search space is exhausted, allowing the function to stop and return -1.*
    21:27 *🧩 Recursion effectively trims the search space by calling itself with updated bounds, improving search efficiency.*
    00:21:55 *🔄 Discusses the logic for calling the recursive function for binary search, emphasising changes in the low and high pointers.*
    00:23:05 *🧮 Explains how the first call calculates the middle of an array and adjusts search based on target comparison.*
    00:24:26 *🔙 Details the step-by-step progression of recursive calls in binary search until reaching the base case returning -1.*
    00:25:55 *🧩 Describes how recursive calls return -1 if the target is not found in the recursion tree, showcasing how the entire function handles it.*
    00:27:25 *📉 Analyzes time complexity, illustrating how binary search reduces search space logarithmically with respect to base 2.*
    00:29:10 *⚠️ Discusses the potential Overflow issue occurring if the middle point calculation exceeds the integer storage capacity.*
    00:31:10 *📝 Provides solutions to Overflow issues, recommending writing an alternative expression for mid calculation or using `long long` data type.*
    00:32:55 *👍 Concludes with encouragement to check the Binary Search playlist and highlights the importance of understanding binary search beyond arrays.*
    Made with HARPA AI

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

    Striver the way you teach is exceptional 👏 .

  • @vikasbagri1225
    @vikasbagri1225 Год назад +25

    Understood it very well
    And the OVERFLOW part was awesome
    Keep up the good work Striver
    Although you have promised us 30+ videos but no worries as we know how busy you are
    Once again thanks for this amazing series

  • @anuragsingh8910
    @anuragsingh8910 Год назад +46

    0:00 Introduction
    1:27 Real Life Example
    5:18 Coding Problem Example
    13:22 Iterative Binary Search Code
    17:15 Recursive Binary Search Code
    26:18 Time Complexity Analysis
    29:12 Overflow Case
    32:46 Outro

    • @takeUforward
      @takeUforward  Год назад +13

      Thank you so much

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

      @@takeUforward Welcome ❤

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

      ​@@takeUforward completed same day

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

      @@takeUforward bhaiya ek question hai ......at the end of video aapne kaha ...INT MAX + INT MAX ...which is 2*INT MAX.......bhaiya kya yeh kisi variable me store hoga...then divide by 2 hoga........
      agr aisa hoga tabhi na bhaiya overflow condition aayega....isem thora sa confusion hai bhaiya...please clear kar dijiye na bhaiya

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

      ​@@sujitrishikumar8621INT MAX + INT MAX .... Which is 2*INT MAX , dono variable int type ke hai to int hi output aayega esa compiler samjhta hai, and int type ka memory block provide krta hai output store ke liye, but jb two int max ko add krege to vo int memory block mai store nhi ho payega jisse overflow condition aayegi ,
      And variable mai store nhi ho raha hai , jb program ram mai aata hai run krne ke liye tabhi program ko memory milti hai , kitni memory lgne wali hai program ko or kaha lgne wali hai ye compile time pr decide ho jata hai

  • @harshith1424
    @harshith1424 Год назад +208

    Bro dropped whole" binary search" album overnight 😂😂😂

    • @emtiazahmed5333
      @emtiazahmed5333 Год назад +12

      😂😂😂😂 sahi bola..bhaiya is on fire😂

    • @takeUforward
      @takeUforward  Год назад +88

      Sorry pura nai ho paaya as website ka kaam chal raha tha, pura aa jaega 5/6 din me

    • @roshanraturi1040
      @roshanraturi1040 Год назад +12

      ​​@@takeUforward bhya aap itna v kr rhe houtna hi bhoot h ❤

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

      Bcz he promised and he never forget his promises that why we love him ❤

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

      @@takeUforward arey bhai mai tho mazak kar Raha tha ....u r doing next level hardwork for students.... always thankful to you🙏

  • @utkarshshrivastava2632
    @utkarshshrivastava2632 Год назад +16

    Loved the way how you always keep your promise and deliver premium quality content ! Hats off to the dedication man❤❤❤❤

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

    Amazing explaination sir ...first time i watch your video ...clear the binary search..

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

    There was a mistake in your recursive code while submitting on Coding Ninjas, in the else statement you have written bs(nums,low,high-1,target) instead of bs(nums,low,mid-1,target), so it won't be O(logn) time complexity.

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

    Hats OFF to you bhaiyaa for providing us with much of premium quality content( Don't have words to say for your efforts)
    Thank you so much

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

    #Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India.

  • @RagaviSathiyamoorthy
    @RagaviSathiyamoorthy 11 месяцев назад +1

    Thank you so much for this wonderful video session and this is the first time i have clearly understood about the concept and it is very clear. Thank you

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

    understood i was new to lb, ub floor ,ceil ,i learnt them here .Thanks

  • @PiyushWandile-q5u
    @PiyushWandile-q5u Год назад +2

    Hats OFF to you Man for making such Content

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

    LOVED ITACHI NOTEBOOK :)

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

    Wow the best explaination!! Thanks Striver.

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

    Thank you striver for the amazing videos.

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

    One of the best lecture for binary search

  • @sujalGhorse-xh8bs
    @sujalGhorse-xh8bs 7 месяцев назад +9

    Why sound is not there?

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

    Striver bhaiya ka dedication!!!!! Thanks a lot

  • @YATHARTHBHARDWAJ-y8m
    @YATHARTHBHARDWAJ-y8m Год назад +1

    Understood it very well
    THANK YOU SO MUCH SIR

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

    Understood .... thank u so much bhaiya ...its the best i have ever seen ...salaam rocky bhai

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

    Hats OFF to you Man.Thanks for gifting us an Amazing Playlist Like DP.❤❤❤❤❤❤

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

    Your dedication is commendable Striver!!! Great job dude!!

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

    Please give us Sliding Window Playlist . It is very very important and it is not available anywhere.

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

      u can also see for the aditya verma for sliding window ...its also good

  • @venkateshr2923
    @venkateshr2923 7 месяцев назад +4

    Is it a glitch, not able to hear anything in this video..

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

    Understood. Crystal clear.

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

    I completed the Binary search questions on my own, but I'm having a lot of trouble with the String problems.

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

    striver you are very loyal person because you told this video will be post jun 1st .Thank you for the Video for us. Keep doing .

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

    All doubts clear ! Understood

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

    Waiting for the solution of Minimizing the maximum distance to gas station. Amazing series and thanks for the signIn / signUp functionality on the site really solved my problem

  • @Ravikantsingh-b4g
    @Ravikantsingh-b4g Год назад

    maja aagaya bhaiya wait kar rahe the bahut din se

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

    Understood Bhaiya!

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

    Understood! Amazing explanation as always, thank you very very much for your effort!!

  • @RumanaIslam-xs9rw
    @RumanaIslam-xs9rw 3 месяца назад

    This is the best Binary Search explanation I have ever come across, Love from a lost cs soul

  • @prabhakaran5542
    @prabhakaran5542 8 месяцев назад +1

    Understood ❤

  • @TheNStranger
    @TheNStranger 7 месяцев назад

    that's a great job bro. i like your every video after watching and submit question on leetcode😊😊 .

  • @hareshnayak7302
    @hareshnayak7302 7 месяцев назад

    Understood, thanks striver for this amazing video. Really enjoing your lecture videos.

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

    You are just amazing. Please keep this good work going

  • @hemanthkumar-pp8yn
    @hemanthkumar-pp8yn 6 месяцев назад +4

    I am not able to listen voice. Its getting cut right from beginning.. any reason!

  • @SandeepPandey-i9y
    @SandeepPandey-i9y 11 месяцев назад

    Please @takeuforward
    Make such more playlist on every topic please

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

    awesome videos, best dsa videos ever

  • @RaviKumar-sn6tu
    @RaviKumar-sn6tu 7 месяцев назад

    crystal clear explaination✨✨✨✨

  • @DeboleenaMukherjeeM23CSA008
    @DeboleenaMukherjeeM23CSA008 3 месяца назад

    Thank you Striver😇

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

    00:07 Binary search is a searching algorithm in a limited search space.
    02:13 Binary search is a search algorithm applicable in a sorted area.
    06:36 Binary search helps to reduce time complexity in searching.
    08:37 Binary search trims down the search space by splitting it into halves.
    12:59 Binary search works by dividing the search space between low and high and narrowing it down until the element is found or the search space is exhausted.
    15:03 Binary Search is a simple and efficient searching algorithm.
    19:01 Binary search is a recursive algorithm that repeatedly halves a sorted array to find an element.
    20:50 Performing binary search using recursion and base case handling
    24:39 The video explains how recursion works in binary search.
    26:27 Binary search reduces the search space by half in each step.
    30:27 Binary search can cause overflow when the search space becomes small and the low value reaches the maximum integer value.
    32:35 Binary search Overflow case explained

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

    great BS Content i had watched all conceptual Dout's are clear!!

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

    @takeuforward Brother Linked List pe playlist kab tak aayegi ??

  • @komalkrishna7836
    @komalkrishna7836 Год назад +4

    Wow 😍 great explanation Striver 👏

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

    Thanks bhaiya for all the hard work that you have put, now I am going to watch it😁

  • @sridharshree3034
    @sridharshree3034 9 месяцев назад

    Awesome thank You Vikram

  • @impalash_ag
    @impalash_ag 3 месяца назад

    Hi Raj,
    The recursive code that your wrote on CodeStudio has a slight mistake:
    when nums[mid] > target, high becomes mid-1, but in the recursive call you're passing high as high-1 [bs(nums, low, high-1, target)]. The code still runs because the values passed still exists however the no. of iterations to find the number will be higher.

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

    Good understanding with TC

  • @MaheshKumar-jc8sp
    @MaheshKumar-jc8sp Месяц назад

    you are a champion

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

    @takeUforward Hi Raj, shouldn't we also add a condition to check if arr[low] or arr[high] is equal to target. just to save some iterations or stack calls, i know the time complexity would still be log n, but is it advisable to add such optimizations or not ?

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

    striver bhaiya Always on fire🔥🔥🔥🔥🔥🔥

  • @Raj-pi1pl
    @Raj-pi1pl Год назад +1

    Finally worth waiting

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

    good video bhaiya🥳

  • @ShravanKumar-wg9pv
    @ShravanKumar-wg9pv 2 месяца назад

    വളരെ നന്ദി * _* (from kerala)

  • @kingbadshah452
    @kingbadshah452 9 месяцев назад

    understood everything thanks striver

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

    Thanks bhaiya bhot time se intezar tha ❤❤❤

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

    Thanks you Striver bhaiya You made it 🙌🙌 🎉

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

    Awesome bhaiya.................

  • @shrad6611
    @shrad6611 11 месяцев назад

    great playlist

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

    Kuch alag tarika tha . Anyways bahut sahi tha

  • @gautamsaxena4647
    @gautamsaxena4647 21 день назад

    understood bhaiya

  • @pikkok7867
    @pikkok7867 11 месяцев назад

    elif target > nums[mid]:
    return binarysearch(nums, high, mid + 1, target)
    else:
    return binarysearch(nums, mid - 1, low, target)
    a change need to be made

  • @karthik-varma-1579
    @karthik-varma-1579 2 месяца назад

    Striver make a seperate chat space in take you forward as like a discord to get your channel updates in that chat space only
    and also make a thank note who want to thank you or write a testimonals which helped them to get placed.
    It Would be great if you read this so far. and I know You are go fast model you does this fast pace
    thank you lot for bs playlist

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

    Understood, thank you.

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

    Salute to your dedication

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

    Binary search is a search algorithm that efficiently finds an element in a sorted array or sequence. It works by repeatedly dividing the search space in half, discarding the half that cannot contain the target element.
    Key moments:
    00:13 Binary search is a structured path in this video, demonstrating how it works in real life. The video may be longer on the platform compared to others due to following a structured path.
    -The video will start with real-life examples to explain how binary search works in practical scenarios.
    -The video will then delve into coding examples to illustrate the implementation of binary search algorithms.
    -The concept of binary search will be further explained through a practical example of dividing a dictionary to locate specific properties.
    06:07 The video explains the concept of binary search using a unique ordered list, demonstrating how to find a specific element efficiently by dividing the search space in half iteratively.
    -The speaker emphasizes the importance of understanding the index pointers and the significance of the middle element in binary search for efficient searching.
    -Exploring the role of specific indices and variables in binary search to determine the correct position of elements within the ordered list.
    -Demonstrating the iterative process of binary search by updating the search space based on comparisons with target values, showcasing the efficiency of the algorithm.
    13:23 Understanding the process of binary search is crucial for coding problems. The video explains the iterative implementation of binary search with detailed steps and considerations.
    -Iterative implementation of binary search is explained with step-by-step guidance, aiding in understanding coding problems efficiently.
    -The video emphasizes the importance of correctly implementing binary search to efficiently solve coding challenges and optimize search processes.
    -The iterative approach to binary search is highlighted, showcasing how to handle different scenarios and make informed decisions for effective problem-solving.
    18:13 Recursion in coding allows for repetitive functions to be executed with varying parameters, simplifying complex tasks. Understanding base cases and midpoints is crucial for recursion to work effectively.
    -Recursion simplifies repetitive tasks by reusing code with different inputs, enhancing efficiency in programming.
    -Base cases and midpoints play a vital role in recursion, guiding the flow of functions and ensuring correct execution.
    26:20 Understanding the complexity of time is crucial in coding. Recursive code is demonstrated, showing how to trim elements and solve problems efficiently.
    -Recursive code is explained, emphasizing the importance of understanding time complexity in coding.
    -Trimming elements and recursive functions are discussed to showcase efficient problem-solving techniques in coding.
    -The video delves into examples of binary search and word search, highlighting the versatility and complexity of search algorithms beyond arrays.
    32:55 Understanding the concept of binary search in depth is crucial for efficient problem-solving. Exploring different search space scenarios can lead to better algorithmic solutions.
    -Exploring the impact of search space variations on algorithmic solutions. It's essential to consider different scenarios for efficient problem-solving.
    -Emphasizing the importance of understanding binary search intricately for effective problem-solving strategies. Delving into search space optimization can enhance algorithm efficiency.
    Generated by sider.ai

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

    Thankyou thank you was waiting for this eagerly.

  • @per.seus._
    @per.seus._ Год назад +1

    UNDERSTOOD

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

    The bestttt👏

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

    First i like button , then i watch ❤

  • @RS-vu5um
    @RS-vu5um 7 месяцев назад +3

    I don't hear any Audio for this video.

  • @shibsankarpramanik768
    @shibsankarpramanik768 11 месяцев назад +1

    GOAT 🐐 of DSA

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

    Understood Sir🙇‍♂🙏✨💖

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

    God level🛐

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

    UNDERSTOOD:

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

    example was excellent.

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

    completed first vide.

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

    Salute for ur dedication...

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

    I was like Maine notification bell to press Kiya tha fir bhi direct BST-8 ka notification aaya ....... Baki ke time par nahi aaya 🙄 ...... Fir channel pe aake check kiya to dekha ki bhaiya ne ek sath 8 video upload kar diye 😂🤣

  • @anshulrai6058
    @anshulrai6058 7 дней назад

    understood👍

  • @shubha_jagadeesh
    @shubha_jagadeesh 2 дня назад

    understood😍

  • @AruniPathak-p1e
    @AruniPathak-p1e 3 месяца назад

    outstanding

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

    bruhh you're goated🐐

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

    Striver sir jo bolte h vo kr k dikhate h , thanks ❤❤

  • @sahxzm
    @sahxzm Месяц назад +1

    Those who are having audio issue
    Open this video on browser and play
    Its not playing in youtube app.
    I dont know why and how
    Its only playing with audio in browser

  • @raZer.7_
    @raZer.7_ 6 месяцев назад

    Great video❤

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

    thank you sir

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

    very good lecture

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

    you are amazing..........

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

    Understood✅🔥🔥

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

    Understood😀

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

    Understood !! 😎😎