4. STL Functions for Binary Search | Detailed explanation with examples & solution-Lower,Upper Bound
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
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.
Thank you so so much Sandeep! Means a lot! Hoping to see you everyday 😇
thanks di , I understood it very easily!
WOW!!! A+ Quality teaching Mam . you know our Mannn Ka doubt ... thats why you make us understand everything so easily . stay Succesfull Mam.
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!!
Great job Arghya, so proud ❤️😇✌️
@@codefromscratch-keertipurswani Thank you ma'am.
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
Day 4- Present🙋♂️
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
video 4 done learnt about lower and upper bound
Good teaching and present
it is great to learn from you...
Thanku for starting this channel
great explanation
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!!😇
ma'am you are doing great work. like covering this topic on such detail level . loved your contents. please continue
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....
Thanks Yuvraj! Means a lot! ❤️😇
nicely explained
Thankyou for this video
yesterday It got a run time error !
but today's solution is so better.
thank you
u r an underrated gem didi..
Thank you so much!! Means a LOT! ❤️😇
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
Thanks. Waiting for more medium and hard level questions to be explained.
Thank you :)
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.
Thank You for such amazing content.
Wow! I didn't know this trick before. Thank you!
Awesome! Hoping you will be consistent and will show up tomorrow also 😇
Completed!!!
Day 4 done ❤️
It was so nice when i heard tek he 😀
love you mam
present keerti..
Great job Mukesh! See you tomorrow also ❤️😇
kal bhi dekha aaj samj aya repeat karke aaj samj aya
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
Thanku Mam for this lecture
Great lecture mam👍👍
I didn't understand why you add (- arr) in lower_bound iterator to get the index
Day 3 - Present Ma'am.
Another good video.... Very helpful
Thanks Rahul, means a lot! ❤️😇
great learning 👍👍
I didn't get why -arr is added after lower_bound and upper_bound. Please clarify
I am a Java developer. Thus, skipping this.
present - day 1
Hi Keerthi. Thanks for these videos. can you also explain or write the code in python instead of C++ ?
Are these STL applicable in Java ? If not what’s the alternative any idea people ?
Same query
I think collection
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..
what value does arr contains.If anyone know please reply
Present on 7th July
Thanks.
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 🙏🏻
am i wrong in assuming we can replace the call to binary_search with a check if lower bound returned vector.end()?
Yes I did it
I am watching
I might be late, but I did give a pat. 😅
#4
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 🙂
I think operator is like a pointer I'm not sure maybe someone else can explain it better
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😂😂😂
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
amazing !! keep it up 🎉
Thanks Shalini! Hoping to see you tomorrow also ❤️😇
Coding Prac Day 1 V4
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
}
}
Present 👋
Hi di i am working in software QA is it good field do you think it is good for long term?
Day 4: present Di
Hey Keerti, Thank you for your videos, but any plans to have this all DSA problems in javascript also?
ayo whatt!!! who does DSA in js?
@@guytonedhai 💀😂
@kshitiz, many people do code dsa in javascript!
@gopal, not for now. My main language is C++.
Hi, can you please post the solution in java also
Hi, for now, I am covering the series in C++, will add solutions in all languages on my site, codetal.in
@@codefromscratch-keertipurswani thank you, also try to cover all DSA topics like stack queue trees in java
@@deepakprabhu8235 have patience jeez
#30DaysOfCode Day 1 :)
Consistency Day : 4 😊
Great job Sachin! Let’s do this ❤️😇
Present
Present mam
Great job ❤️ Hope you understand the concept properly ❤️❤️
#KPConsistent : Day[4]
Great job Kishan! ❤️😇
11:21 Ma'am you confused yourself 😅