4. STL Functions for Binary Search | Detailed explanation with examples & solution-Lower,Upper Bound

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Smart people use STL to apply binary search! Become smart with me! We have covered some theory, taken examples and running code and also solved a question using STL. This is a very very imp video! ❤️
    You can practise the question here-
    bit.ly/3OF88TW
    You can get 𝐃𝐈𝐒𝐂𝐎𝐔𝐍𝐓𝐒 using code "KEERTI" -
    ➡️ On 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐑𝐞𝐚𝐝𝐲 - get.interviewr...
    ➡️ On 𝐄𝐝𝐮𝐜𝐚𝐭𝐢𝐯𝐞 - educative.io/ke...
    ➡️ On all 𝐆𝐞𝐞𝐤𝐬𝐅𝐨𝐫𝐆𝐞𝐞𝐤𝐬 paid courses - practice.geeks...
    #softwaredeveloper #dsa #interviewpreparation

Komentáře • 91

  • @sandeepkohli3281
    @sandeepkohli3281 Před 2 lety +7

    This is called High quality teaching covering everything that we do need including small small doubts too. Mam do more videos with the same level of confidence we were there to hold you.

  • @comparisondata2473
    @comparisondata2473 Před 11 měsíci +1

    thanks di , I understood it very easily!

  • @Raj-jw7kq
    @Raj-jw7kq Před měsícem

    WOW!!! A+ Quality teaching Mam . you know our Mannn Ka doubt ... thats why you make us understand everything so easily . stay Succesfull Mam.

  • @arghya_0802
    @arghya_0802 Před 2 lety +1

    Never used STL library to implement binary search before. But from now I am pretty confident how to use Binary Search using STL library:
    1.binary_search() - > returns true or false depending on the value is present or not.
    2. lower_bound() -> returns the iterator pointing to an element >= target.
    3. upper_bound() -> returns the iterator pointing to an element strictly greater than target.
    Great explaination ma'am. Waiting for next video!!

  • @mdrashidiqbal6599
    @mdrashidiqbal6599 Před 2 lety +3

    Hi Keerthi,
    Could you please write the program in java because I am not aware with C++ language.
    It would be great if you take this initiation.
    Thanks

  • @deepchill5295
    @deepchill5295 Před 2 lety +2

    Day 4- Present🙋‍♂️

  • @ScienceSeekho
    @ScienceSeekho Před 2 lety

    I started preparing for DSA 3 months back, still learning new stuff
    Thankyou!
    Good thing is that you knew when we didn't understand the definition and you said it at 03:05

  • @kkumar07
    @kkumar07 Před 2 lety

    video 4 done learnt about lower and upper bound

  • @kaustubhav6075
    @kaustubhav6075 Před 2 lety

    Good teaching and present

  • @kamallatwal2059
    @kamallatwal2059 Před 2 lety

    it is great to learn from you...

  • @abhisheksaurabh2007
    @abhisheksaurabh2007 Před 2 lety

    Thanku for starting this channel

  • @balajijangde8470
    @balajijangde8470 Před 2 lety

    great explanation

  • @vigneshiyer1765
    @vigneshiyer1765 Před 2 lety

    This helps a lot!!
    What i feel is people who are comfortable with Java can search for an alternate way on Java
    that way can know many things too!!😇

  • @akanchhaece8041
    @akanchhaece8041 Před 2 lety

    ma'am you are doing great work. like covering this topic on such detail level . loved your contents. please continue

  • @yuv09
    @yuv09 Před 2 lety

    You are among the few female tutors who are very much confident and knowledgeable. I appreciate your efforts and learning from you is a great experience....

  • @nithinshetty1140
    @nithinshetty1140 Před 2 lety

    nicely explained

  • @muhammedfaraaz2562
    @muhammedfaraaz2562 Před 2 lety

    Thankyou for this video

  • @anilreddy5243
    @anilreddy5243 Před 2 lety

    yesterday It got a run time error !
    but today's solution is so better.
    thank you

  • @galepraveen9468
    @galepraveen9468 Před 2 lety +1

    u r an underrated gem didi..

  • @mdwasim6091
    @mdwasim6091 Před 2 lety

    Hi keerti..you r doing good work,i request you pls do all dsa coding in java language because most of the student love to code in java

  • @venkatkrishna3774
    @venkatkrishna3774 Před 2 lety

    Thanks. Waiting for more medium and hard level questions to be explained.

  • @bhaumikdedhia1998
    @bhaumikdedhia1998 Před 2 lety

    Thank you :)

  • @prateek2159
    @prateek2159 Před 2 lety

    Ma'am please either upload long videos or increase the frequency. These are the most precious videos on yt rn, much better than other channels like the all time famous, Code Help. But we have our placements right beside us. Plz ma'am.

  • @ankushladani496
    @ankushladani496 Před 2 lety

    Thank You for such amazing content.

  • @nidhikumari1479
    @nidhikumari1479 Před 2 lety

    Wow! I didn't know this trick before. Thank you!

  • @unknowncoder409
    @unknowncoder409 Před 2 lety

    Completed!!!

  • @akxxhil
    @akxxhil Před 2 lety +1

    Day 4 done ❤️

  • @khalidkhan5308
    @khalidkhan5308 Před 2 lety

    It was so nice when i heard tek he 😀

  • @amitrana2775
    @amitrana2775 Před 2 lety +1

    love you mam

  • @mukeshrawat8816
    @mukeshrawat8816 Před 2 lety +2

    present keerti..

  • @dipeshjoshi9126
    @dipeshjoshi9126 Před 2 lety

    kal bhi dekha aaj samj aya repeat karke aaj samj aya

  • @rtarts1524
    @rtarts1524 Před 2 lety

    In many codes there are values l and r to traverse any array. But how computer knows that the l is leftmost element and r is rightmost? In this video you used arr and arr+n

  • @anmoldogra2451
    @anmoldogra2451 Před 2 lety

    Thanku Mam for this lecture

  • @anwesh07
    @anwesh07 Před 2 lety

    Great lecture mam👍👍

  • @only_for_fun1234r
    @only_for_fun1234r Před rokem

    I didn't understand why you add (- arr) in lower_bound iterator to get the index

  • @ashwaniarchivee
    @ashwaniarchivee Před 2 lety

    Day 3 - Present Ma'am.

  • @rahuldasari1886
    @rahuldasari1886 Před 2 lety

    Another good video.... Very helpful

  • @vivekyadav-il2rx
    @vivekyadav-il2rx Před 2 lety

    great learning 👍👍

  • @sahanagoudar1647
    @sahanagoudar1647 Před 2 lety

    I didn't get why -arr is added after lower_bound and upper_bound. Please clarify

  • @nidhibansaliitr
    @nidhibansaliitr Před 2 lety +2

    I am a Java developer. Thus, skipping this.

  • @ashutoshsinha9848
    @ashutoshsinha9848 Před 2 lety

    present - day 1

  • @narendrachennamsetty6466

    Hi Keerthi. Thanks for these videos. can you also explain or write the code in python instead of C++ ?

  • @prashanthiaruna8501
    @prashanthiaruna8501 Před 2 lety +1

    Are these STL applicable in Java ? If not what’s the alternative any idea people ?

  • @mdwasim6091
    @mdwasim6091 Před 2 lety

    pls do dsa in java ,or c++ and java both ,otherwise what happened is that java coder will not be a part of this series...this is my suggestion only..

  • @rounakpal9708
    @rounakpal9708 Před 2 lety

    what value does arr contains.If anyone know please reply

  • @iamSSudheer
    @iamSSudheer Před 2 lety

    Present on 7th July

  • @prakashbtw678
    @prakashbtw678 Před 2 lety

    Thanks.

  • @akanshapriya516
    @akanshapriya516 Před 2 lety

    Mam...do three years gaps after 12th affect on-campus placements?my frnd is doin cse from Jadavpur University after taking 3 yrs gap due to some medical issues !pls do reply mam 🙏🏻

  • @pearwatch1358
    @pearwatch1358 Před 2 lety

    am i wrong in assuming we can replace the call to binary_search with a check if lower bound returned vector.end()?

  • @RajKamalAnkit
    @RajKamalAnkit Před 2 lety

    Yes I did it

  • @errorless7921
    @errorless7921 Před rokem

    I am watching

  • @harikrishnakada7315
    @harikrishnakada7315 Před 2 lety

    I might be late, but I did give a pat. 😅

  • @rammohanreddy2280
    @rammohanreddy2280 Před 2 lety

    #4

  • @anikettripathi1160
    @anikettripathi1160 Před 2 lety

    Questions I have:
    1. vec.begin() and vec.end() are iterators here. Right?
    2. At 7:48, Why are r u subtracting vec.begin() ? How subtracting it gives us the index. U said, to get the index instead of getting the iterator. What's iterator exactly, here.
    Sorry for the long questions di.. But I'm a 1st yr student, and have learnt c++ and about to start dsa.
    Thanks for the content and consistency 🙂

    • @clashofkings7
      @clashofkings7 Před 2 lety

      I think operator is like a pointer I'm not sure maybe someone else can explain it better

    • @clashofkings7
      @clashofkings7 Před 2 lety

      It is little confusing we need to practice and learn on the go that way we'll get it I'll try this again tomorrow morning I'm sleepy now😂😂😂

    • @clashofkings7
      @clashofkings7 Před 2 lety

      Anyway good explanation it's just that I'm not used to C++ but theory I am understanding though it's just the code and how it's working 😆😆I'm used to Java

  • @ShaliniNegi24
    @ShaliniNegi24 Před 2 lety

    amazing !! keep it up 🎉

  • @utkarshawasthi1665
    @utkarshawasthi1665 Před 2 lety

    Coding Prac Day 1 V4

  • @simran1277
    @simran1277 Před 2 lety

    SUMMARY
    ===================
    3 functions for binary search
    1) binary_search(startaddress, endaddress, valuetofind) => returns true if element is present, else false
    Imp: element at endaddress isn't included
    want to apply binary search on arrays: binary_search(arr,arr+n,x)
    want to apply binary search on vectors: binary_search(vec.begin(),vec.end(),x)
    vec.end() returns an iterator pointing next to last element of the vector container, so here as well that isn't included
    2) lower_bound(startaddress, endaddress, valuetofind) for >=
    3) upper_bound(startaddress, endaddress, valuetofind) for >
    How to approach the first and last occurrence problem in the last lecture?
    ------------------------------
    vector find(int arr[], int n , int x )
    {
    if (binary_search(arr,arr+n,x)) // element is present
    {
    int occ_low = lower_bound(arr,arr+n,x) - arr; // since element is present, so it will return for '=' case
    int occ_high = upper_bound(arr,arr+n,x) - arr - 1; // since element is present and it returns for just greater one, so -1 is needed
    return {occ_low, occ_high};
    }
    else
    {
    return {-1,-1}; // element not present
    }
    }

  • @sexykillerize
    @sexykillerize Před 2 lety

    Present 👋

  • @movietalkiez5650
    @movietalkiez5650 Před 2 lety

    Hi di i am working in software QA is it good field do you think it is good for long term?

  • @jagritiyadavv
    @jagritiyadavv Před 2 lety

    Day 4: present Di

  • @gopalmandloi6374
    @gopalmandloi6374 Před 2 lety

    Hey Keerti, Thank you for your videos, but any plans to have this all DSA problems in javascript also?

  • @deepakprabhu8235
    @deepakprabhu8235 Před 2 lety +1

    Hi, can you please post the solution in java also

    • @codefromscratch-keertipurswani
      @codefromscratch-keertipurswani  Před 2 lety +2

      Hi, for now, I am covering the series in C++, will add solutions in all languages on my site, codetal.in

    • @deepakprabhu8235
      @deepakprabhu8235 Před 2 lety

      @@codefromscratch-keertipurswani thank you, also try to cover all DSA topics like stack queue trees in java

    • @clashofkings7
      @clashofkings7 Před 2 lety +2

      @@deepakprabhu8235 have patience jeez

  • @vivekacharya3652
    @vivekacharya3652 Před 2 lety

    #30DaysOfCode Day 1 :)

  • @sachinaghera8189
    @sachinaghera8189 Před 2 lety

    Consistency Day : 4 😊

  • @arunkumarmohandas4420
    @arunkumarmohandas4420 Před 2 lety

    Present

  • @pratikchavan6614
    @pratikchavan6614 Před 2 lety +1

    Present mam

  • @kishan_suthr
    @kishan_suthr Před 2 lety

    #KPConsistent : Day[4]

  • @ayushsengupta9700
    @ayushsengupta9700 Před 2 lety

    11:21 Ma'am you confused yourself 😅