Binary Search Algorithm in 100 Seconds

  Рет қаралды 510,961

Fireship

Fireship

2 жыл бұрын

Binary Search is an algorithm that can find the index of an element in a sorted array data structure. You've likely used Binary Search it in everyday life without even realizing it.
#compsci #programming #100SecondsOfCode
🔗 Resources
Binary Search en.wikipedia.org/wiki/Binary_...
Big-O in 100 Seconds • Big-O Notation in 100 ...
Recursion in 100 seconds • Recursion in 100 Seconds
🔥 Get More Content - Upgrade to PRO
Upgrade to Fireship PRO at fireship.io/pro
Use code lORhwXd2 for 25% off your first payment.
🎨 My Editor Settings
- Atom One Dark
- vscode-icons
- Fira Code Font
🔖 Topics Covered
- Binary Search in JavaScript
- How does binary search work?
- When was binary search first used?
- How code recursive binary search?
- Big-O Time complexity of binary search

Пікірлер: 1 100
@mr.anderson5077
@mr.anderson5077 2 жыл бұрын
Hey Jeff, Please cover all the topics from data structures and algorithm. Thanks
@Ma1ne2
@Ma1ne2 2 жыл бұрын
Yes plz!
@SheikhAmeen
@SheikhAmeen 2 жыл бұрын
Yesss! Like this comment, get to the top!
@auroreis2308
@auroreis2308 2 жыл бұрын
Yessssss fully agree
@flyte9844
@flyte9844 2 жыл бұрын
YES PLEASE :D
@gopalkmrr
@gopalkmrr 2 жыл бұрын
Yes
@discarded1669
@discarded1669 2 жыл бұрын
Do a series of these different Algorithms.. Helps immensely in quick revising them for tests..
@WTHBrou
@WTHBrou 2 жыл бұрын
Yes, please. I've been having a hard time implementing variations of DFS and BFS graph algos.
@marcelsantee1809
@marcelsantee1809 2 жыл бұрын
@@WTHBrou I keep failing hard at graphs interview, I second that
@Ruf4eg
@Ruf4eg 2 жыл бұрын
Yes, please.
@6_nikki_9
@6_nikki_9 2 жыл бұрын
MOAR ALGORITM PLS
@JettoDz
@JettoDz 2 жыл бұрын
Yes. A series, then put them in a playlist. CS 101. You'll get tons of students into it. I can already forsee teachers using Fireship videos as introductions for every (available) algorithm.
@taylorcarroll6487
@taylorcarroll6487 2 жыл бұрын
More algorithms please, I was just looking this up yesterday and found this video explains it more clearly than others because you clearly explain WHY we would use this rather than just parroting how to do it out of textbook.
@m1rac1e
@m1rac1e 2 жыл бұрын
If you're a CS student/beginner learning data structures & algos for the first time, I cannot recommend "A common-sense guide to data structures & algorithms" enough. It's a textbook that is focused on explaining the base concepts in plain English to a beginner. It goes in-depth without overwhelming you. Provides exercises, examples, & diagrams. Book saved my life freshman year of CS.
@shreehari2589
@shreehari2589 2 жыл бұрын
@@m1rac1e bro i am gonna be in freshmen year in August, can you please give me the link to download it.
@nateo7045
@nateo7045 2 жыл бұрын
I would like more algorithms because I like algorithms, but this is a hardly revolutionary video. Here's to generic praise 😂
@m1rac1e
@m1rac1e 2 жыл бұрын
@@shreehari2589 look up textbook piracy, can't link it because youtube filter blocks me. gotta use ur brain.
@rajikkali2381
@rajikkali2381 2 жыл бұрын
@@shreehari2589 try z-lib
@StuartLoria
@StuartLoria 2 жыл бұрын
This is amazing. I would call the series “demystifying Algorythms”, or “computer archeology”, or “understand the technical interview”
@arossfelder
@arossfelder 2 жыл бұрын
That's a great idea you got here ...
@123456crapface
@123456crapface 2 жыл бұрын
aaaand thats why no one asked you
@freakymidget
@freakymidget 2 жыл бұрын
A playlist of common interview questions would be a godsend
@sauravbv
@sauravbv 2 жыл бұрын
I finished my engineering course long back, but would pay you to watch data structures and algorithms explained in such a nice way!
@koolamusic_
@koolamusic_ 2 жыл бұрын
bru
@Chiefsosa17
@Chiefsosa17 2 жыл бұрын
Well, I knew binary search already. But this dictionary anology was just amazing.
@Aresous
@Aresous 2 жыл бұрын
i think cs50 does this
@DodaGarcia
@DodaGarcia 2 жыл бұрын
This was so awesome, as a self-taught developer I never got to learn most theoretical things like this, and it definitely has an effect on my problem solving
@wajidnv
@wajidnv 2 жыл бұрын
What a miracle. My computer science teacher taught us linear search today. And will teach binary search tomorrow. I got it easy 😊
@18.j
@18.j 2 жыл бұрын
Love to see more algorithms videos! 👏🏻
@Chapali9a
@Chapali9a 2 жыл бұрын
Holy moly! Ive never seen anyone explain it as simple as this. Please do more data structures and algorithms stuff. Thank you
@mridulbarman027
@mridulbarman027 2 жыл бұрын
Need many many more videos please ❣️ Sir taught in class many times but never able to explain like this. Thank you ❤️
@mephi5t0
@mephi5t0 2 жыл бұрын
The code shown actually have a bug. When it was written back in the day it was not a problem. Now of your search array has billion elements the sum of integers may overflow and become negative. The new proper way to avoid going out of bounds of the integer to calculate mid point is int mid = low + ((high - low) / 2); This was a bug in Java for 9 years
@Dr.Schnizzle
@Dr.Schnizzle 2 жыл бұрын
This is actually really important. I’ve gotten dinged for this.
@AkaiKnight
@AkaiKnight 2 жыл бұрын
To be fair, he did say the code was in JavaScript. But this is still an important insight you’re giving
@jandresshade
@jandresshade 2 жыл бұрын
No only that, this kind of iteration is really limited in JS (in fairnes JS is not a declarative lenguaje and has the while loop for this kind of problems), you going to get a "Maximum call stack size exceeded error" before getting this bug.
@svenniepennie4237
@svenniepennie4237 2 жыл бұрын
@@jandresshade Why would you get a maximum call stack size exceeded error?
@vectoralphaAI
@vectoralphaAI 2 жыл бұрын
I don't get it. Can you explain?
@JohnSnow-gi7iv
@JohnSnow-gi7iv 2 жыл бұрын
We need more like these algorithms
@conceptioned
@conceptioned 2 жыл бұрын
More algorithms in under 100 seconds like these, please! This was explained way more succinctly than a regular class would have done.
@alichamas63
@alichamas63 2 жыл бұрын
I really love these videos. My favourite dev content on KZbin. Perfect balance of knowledge, time, humour, and impact.
@heathenmonk1249
@heathenmonk1249 2 жыл бұрын
Yes, continue with more algorithms, this was so easy to understand, thanks!
@chiroyce
@chiroyce 2 жыл бұрын
With Jeff's videos we can speedrun learning!
@sirgrem2988
@sirgrem2988 2 жыл бұрын
Man, you've come at a perfect timing for this one! Would love to see more about algorithms.
@normankidhoma9897
@normankidhoma9897 2 жыл бұрын
Wow. The simplicity is amazing. Would love more of these. Thanks
@abdousidiya2130
@abdousidiya2130 2 жыл бұрын
I’d appreciate if you make a series about data structure and algorithms. Your explanation is really helpful! Thanks:)
@jesusrojas5262
@jesusrojas5262 2 жыл бұрын
This is the first time that I truly understood the Binary Search algorithm and how to implement it using recursion in just 2 minutes. Awesome!
@jewpcabra666
@jewpcabra666 2 жыл бұрын
love it! these are great for practicing for coding interviews - especially if you cover more complex topics that are hard to visualize (dynamic programming, fast/slow pointers, loops etc)
@aschmelyun
@aschmelyun 2 жыл бұрын
Definitely keep making these. I'm a full-stack developer, but missed out on a lot of the 'low-level' knowledge like algorithm design and Big O notation. This video was incredible!
@alansaldivares
@alansaldivares 2 жыл бұрын
This is pure gold, and yes, the crowd cries out desperately for more videos of algorithms and data structures. Keep it up man, thanks!
@y404
@y404 2 жыл бұрын
hey this was really informative and interesting to watch all while being entertaining because of how good your animations are. please keep doing more of these 👍
@niteshsethi4091
@niteshsethi4091 2 жыл бұрын
Algorithm holds a massive part in today's technical world. Apart from dev tools like react, redux, and all including devops, algorithm is something we all get to ask even in interview. I appreciate the work you have done yet and doing continuously to get us know what that technology actually means and when should we have it in use. Other data structures and algorithms are welcome from my side. We all need it.
@ericpeck7858
@ericpeck7858 2 жыл бұрын
Great video! We would love to see videos like this for all sorts of algorithms. Even compare and contrast different algorithms(space & time complexity, etc).
@pedgarcia
@pedgarcia 2 жыл бұрын
Short and sweet (as usual). Please, keep them coming!
@colinzollars2017
@colinzollars2017 2 жыл бұрын
Please do more Algorithms! I'm practicing Leetcode so this video is incredibly helpful in explanation. Time Complexities are a harder concept for me so this helped explain that a little more.
@elijahmandeville8475
@elijahmandeville8475 2 жыл бұрын
This made more sense to me than when I learned about it during a 2 hour lecture. Would love to see algorithms more
@januszwitkowski878
@januszwitkowski878 2 жыл бұрын
That's a really cool format for algorithms showcases! Keep it up!
@pyanimate1493
@pyanimate1493 2 жыл бұрын
Hi Fireship, I am learning data structures and algorithms. Please continue. I actually like the way you simplify things.
@reandov
@reandov 2 жыл бұрын
Hey Jeff, great video! How about a new series where you show most known algorithms in 100 seconds? That would be great!
@Lee14G
@Lee14G 2 жыл бұрын
Beautiful! I want more videos like this! Common algorithms explained and implemented.
@kevinfriedman6766
@kevinfriedman6766 2 жыл бұрын
Please continue to release these videos. Algos/DS are always top of mind for most folks interview prep, amazing stuff as always.
@dadidus1
@dadidus1 2 жыл бұрын
I would use the .indexOf() function instead of a for loop
@M9625Rahul
@M9625Rahul 2 жыл бұрын
Thats Language feature not available in all languages and you aren't allowed to do that
@erfanexp
@erfanexp 2 жыл бұрын
I wish I didn't know how binary search works so that I could enjoy this video more
@emilianogarcialopez3591
@emilianogarcialopez3591 2 жыл бұрын
Love this series on algorithms! You should do more
@bigmackdombles6348
@bigmackdombles6348 2 жыл бұрын
You are a genius at teaching, I will watch and use whatever content you make, including more algorithm vids.
@lightning_11
@lightning_11 8 ай бұрын
Who's gonna tell him that these videos are all 150 seconds long?
@shreym03
@shreym03 2 жыл бұрын
This is a good video. But I see one flaw in it. You haven't explained the fact that binary searches work only in an environment where everything is sorted
@jef777
@jef777 2 жыл бұрын
0:39 "given a sorted array"
@kolegowiewtrasie4054
@kolegowiewtrasie4054 2 жыл бұрын
in a 100s video every word counts
@mohamedsaleh5970
@mohamedsaleh5970 2 жыл бұрын
Greate idea to make algorithms series. keep doing it and thanks for your wonderful content and simplified description.
@yousefelsayed4203
@yousefelsayed4203 2 жыл бұрын
would love more videos about algorithms like this video concise and to the point and with an example to understand. Keep it going
@krishnasahu8553
@krishnasahu8553 2 жыл бұрын
First
@funwithalbi2425
@funwithalbi2425 2 жыл бұрын
didn’t ask + don’t care + ratio
@negaaa5080
@negaaa5080 2 жыл бұрын
Ratio
@Fireship
@Fireship 2 жыл бұрын
🥇 Gold!
@JoseMoreno-uc2qz
@JoseMoreno-uc2qz Жыл бұрын
What took my intro to data structures/algorithms professor weeks to each you succinctly explained it in less than 3 minutes. I appreciate your work a lot!
@DesignByFaizi
@DesignByFaizi 2 жыл бұрын
Amazing video. I would love to see more algorithms explained like this.
@azzazkhansiddiqui
@azzazkhansiddiqui 2 жыл бұрын
Love your short videos and if you explain data structures and algorithms like this it would help me a lot in my university!
@shaahkars
@shaahkars 2 жыл бұрын
This was brilliant. Please do make more videos on algorithms. Cheers!
@roulzhq
@roulzhq 2 жыл бұрын
Nice video! I like this more than going over really complex subjects in 100 seconds because you can barely scratch the surface there. This now really explained a lot of the approach already. Question by the way: where do you get your emoji pictures like the pointing hand from?
@miroslavblagoev5887
@miroslavblagoev5887 2 жыл бұрын
Yesss! love the algorithm explanation! would love to see more like these
@tapiwakundishora6195
@tapiwakundishora6195 2 жыл бұрын
Yes please do more algorithm videos🙏🏾; great video btw!!
@curiosity6969
@curiosity6969 2 жыл бұрын
Very informative! Need more videos on algorithms!!
@RandomDude889
@RandomDude889 2 жыл бұрын
I absolutely need more algorithm oriented content this is fantastic.
@sighbru
@sighbru 2 жыл бұрын
Love it. Please more algorithms videos!
@badreddineinfo
@badreddineinfo 2 жыл бұрын
hey Jeff this is a great video 👍🏼, make videos like this about algorithms in the future
@typicalgamer9064
@typicalgamer9064 2 жыл бұрын
Videos about popular and lesser known algorithms would be great content. Would watch them all!
@sava-lakicevic
@sava-lakicevic 2 жыл бұрын
Absolutely want to see more. Keep them coming.
@GrahamBillington
@GrahamBillington 2 жыл бұрын
This was such a great refresher for me man thanks a lot 👊🏼
@TomDoesTech
@TomDoesTech 2 жыл бұрын
This is awesome! More data structures and algo videos please :)
@arkhamian7586
@arkhamian7586 2 жыл бұрын
It would be great if you could cover the most common algorithm and data structures topics that are asked in interviews. Also, topics like solid principles, deadlocking, etc. Your videos make a great refresher for any concept without being boring. In any case, thank you for the great work!
@max0223
@max0223 2 жыл бұрын
Amazing explanation for a common problem that is very helpful. Please do more of this!
@iamrajthomas
@iamrajthomas 2 жыл бұрын
Loved these 100 seconds. I happen to find my best 100 seconds for today. Thanks Jeff. 💚
@roy_2470
@roy_2470 11 ай бұрын
I know this is a relatively old video, but I love these algorithm videos, please return with more of these in depth algorithm videos if you feel like it:)
@brandonsayring
@brandonsayring 2 жыл бұрын
This is the best explanation of binary search algorithms I've seen.
@LalanDesai
@LalanDesai 2 жыл бұрын
Make a whole playlist like 'Algorithms in a nutshell' or something like that and explain all those algorithms out there in 100 seconds.
@Dan7Isc
@Dan7Isc 2 жыл бұрын
Great video! More algorithm-type videos would be awesome!!
@lomitaswasuna5132
@lomitaswasuna5132 2 жыл бұрын
Simple, short yet great content. More on algorithms please.
@mc5427
@mc5427 2 жыл бұрын
I hope there will be more videos of that type, you explain Algorithms in a very good way.
@SohailKhan-cb9ls
@SohailKhan-cb9ls 2 жыл бұрын
Much needed refresher. Need more of it.
@berkakipek8991
@berkakipek8991 2 жыл бұрын
Hey Fireship keep up good work. Your channel is awesome. It will be great if you make more videos about algorithms.
@darriongering392
@darriongering392 2 жыл бұрын
More of these please!!!! So well done
@Kayzewolf
@Kayzewolf 2 жыл бұрын
Your method of teaching both in the "to the point" time constraint and the visuals have really helped me better understand what a lengthy memorization-centric course fails to do.
@pranavsetpal
@pranavsetpal 2 жыл бұрын
Woah, that's pretty cool! I knew how to do it but by using a recursive function it was definitely a much different approach I hadn't seen before. Looked so much better than a binary search algorithm I had made earlier.. The explanation was so much simple and straight forward from the one in my textbook. This is absolutely amazing!
@wizarddev3506
@wizarddev3506 2 жыл бұрын
Quite an interesting algorithm and certainly one important for all developers, regardless of language or field. The video explains it quite well. Keep up the good work Fireship!
@JoeyFenny
@JoeyFenny 2 жыл бұрын
Yes please! Great job at simplifying it. Way easier to understand than via leetcode
@betterdeveloper9073
@betterdeveloper9073 2 жыл бұрын
Yes, please more videos like this. And thank you for all your work!
@deriegle
@deriegle 2 жыл бұрын
Great explanation! Would love more of these videos.
@antonionotbanderas9775
@antonionotbanderas9775 19 күн бұрын
This channel is so good it's raising my ADD everywhere else.
@JayJames
@JayJames 2 жыл бұрын
I already know this will be a great mini series!
@BrandonAaskov
@BrandonAaskov 2 жыл бұрын
You’ve done it again! So concise!
@Iceehockey21
@Iceehockey21 2 жыл бұрын
You never miss ! So helpful
@HazemTamimi
@HazemTamimi 2 жыл бұрын
Yes, we need to see more videos about algorithms and data structures please!
@onefloatavenue
@onefloatavenue 3 ай бұрын
I hadn’t been able to picture divider-and-conquer algorithms for weeks, until this video. Thank you so much.
@alvin6088
@alvin6088 2 жыл бұрын
This is the simplest and understandable explanation I've found on this topic. Thanks!
@sergioornaque7943
@sergioornaque7943 2 жыл бұрын
I love this type of videos, please make more of these ^^
@shegsdev
@shegsdev 2 жыл бұрын
More of this Jeff! Thank you
@mukhammadsobirov1311
@mukhammadsobirov1311 2 жыл бұрын
yes, I'd love to see more videos on this topic please!
@timc0212
@timc0212 2 жыл бұрын
This was a really cool video, keen to watch more
@sostenemunezerobagira8358
@sostenemunezerobagira8358 2 жыл бұрын
Well explained, Please continue making algorithm videos
@unaisulhadi9102
@unaisulhadi9102 2 жыл бұрын
Yes, Please to a complete series on all algorithms and data structures, it'll be really helpful.
@FOLKENT05
@FOLKENT05 2 жыл бұрын
Hey jeff great job!! Yes pls more algorithm examples!
@phyf3
@phyf3 2 жыл бұрын
Great video, really simplifies it, please make more data structures and algorithms videos if you can, thank you!
@eduardocruz1882
@eduardocruz1882 2 жыл бұрын
Your style is awesome!, Tries would be a really good topic!
@7im283
@7im283 2 жыл бұрын
Please make more algorithm videos!!! This one helped alot.
@moonedCake
@moonedCake 2 жыл бұрын
Amazing Content❣ Thanks a lot. Please do this type of explanation for other algorithms as well.
@aakudr2474
@aakudr2474 2 жыл бұрын
Yes please! You're great at explaining algorithms! ♡
@tanveerabbas26
@tanveerabbas26 2 жыл бұрын
That is really awesome . please cover all algos and data structures topics .
@mtrsoftwareservices
@mtrsoftwareservices 2 жыл бұрын
Good video. Would love to see more on this topic.
@sohammondal578
@sohammondal578 2 жыл бұрын
Extremely helpful. Thank you!
@TechyMechie
@TechyMechie 2 жыл бұрын
I like the humour of your videos. It is just awesome! You successfully manage to deliver the techy content along the way. It makes my day and it is one of the reasons I follow your channel on top of the valuable coding tips and tricks you provide. Thanks...
100+ Computer Science Concepts Explained
13:08
Fireship
Рет қаралды 2,3 МЛН
10 weird algorithms
9:06
Fireship
Рет қаралды 1,1 МЛН
Маленькая и средняя фанта
00:56
Multi DO Smile Russian
Рет қаралды 5 МЛН
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 44 МЛН
Bug in Binary Search - Computerphile
11:31
Computerphile
Рет қаралды 282 М.
Reacting to Controversial Opinions of Software Engineers
9:18
Fireship
Рет қаралды 2 МЛН
Learn Binary Search in 10 minutes 🪓
10:04
Bro Code
Рет қаралды 98 М.
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 398 М.
Binary Search - A Different Perspective | Python Algorithms
8:56
CPU vs GPU vs TPU vs DPU vs QPU
8:25
Fireship
Рет қаралды 1,5 МЛН
How Binary Search Makes Computers Much, Much Faster
6:51
Tom Scott
Рет қаралды 1,4 МЛН
Lua in 100 Seconds
2:24
Fireship
Рет қаралды 2 МЛН
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
React for the Haters in 100 Seconds
2:34
Fireship
Рет қаралды 1,5 МЛН
How Neuralink Works 🧠
0:28
Zack D. Films
Рет қаралды 32 МЛН
What’s your charging level??
0:14
Татьяна Дука
Рет қаралды 7 МЛН
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 12 МЛН