Binary Search in Java - Full Simple Coding Tutorial

  Рет қаралды 134,266

Coding with John

Coding with John

Күн бұрын

Пікірлер: 187
@jasonmilton7158
@jasonmilton7158 Жыл бұрын
I’m currently a CS student at UofSC Columbia and YOU played a major role in me getting an A in my first Java class and it looks like you’re also gonna play a major role in me passing the second one. I know when I get my degree you will deserve half the credit good sir. Each of your videos are easily more valuable than a week of in class lectures! Thank you
@YasuOsatoku
@YasuOsatoku 5 ай бұрын
It's sad that I'm at UBC - O, and I have to use John's videos to understand the content and prepare for the final...Sometimes the profs are just sloppy and clueless...
@danielja1832
@danielja1832 Жыл бұрын
My man, we were just covering this in college this week and you happen to be much better at explanations than our professor. You're a legend!
@theseriousaccount
@theseriousaccount Жыл бұрын
College makes more money the longer it takes, it feels like an expensive scam because it is. Learning is best done elsewhere.
@programmingwithnurulhuda
@programmingwithnurulhuda Жыл бұрын
@@theseriousaccount It's always good to learn something.
@frankiia7507
@frankiia7507 Жыл бұрын
tell your professor that face to face
@RishiRajxtrim
@RishiRajxtrim Жыл бұрын
Yes, 100 points!
@kritibrotodatta5172
@kritibrotodatta5172 Жыл бұрын
Why do I have to learn this in class 10 😭
@Hidden_-
@Hidden_- 5 ай бұрын
You are that one good teacher which this world doesn't deserve but totally needs
@koikoi7666
@koikoi7666 Жыл бұрын
I'm a Senior Dev in Java and I just discovered your videos this week. Even though i'm experienced in the language I feel like I still learn things from watching your content, the way you explain things is incredibly easy to grasp. Please keep making more content, I think you are much better than other channels or even paid courses I have taken in the past.
@yaroslavpanych2067
@yaroslavpanych2067 8 ай бұрын
Pray your boss doesn't discover this comment, you will be demoted to juniors at best!
@Heavenset
@Heavenset 4 ай бұрын
how are you a senior and still don't know the basic sorting algorithm?
@artem2055
@artem2055 Жыл бұрын
i was waiting for it! Please do more videos on algorithms and problem solving in general
@nenuanenenuane6645
@nenuanenenuane6645 Жыл бұрын
+1
@abhiram2369
@abhiram2369 Жыл бұрын
+2
@programmingwithnurulhuda
@programmingwithnurulhuda Жыл бұрын
@@nenuanenenuane6645 It's always good to learn something.
@programmingwithnurulhuda
@programmingwithnurulhuda Жыл бұрын
@@abhiram2369 It's always good to learn something.
@nenuanenenuane6645
@nenuanenenuane6645 Жыл бұрын
@@programmingwithnurulhuda It's always good to learn something.
@HackBoy_YT
@HackBoy_YT Жыл бұрын
I am a 10 th grade student from India and dont know binary search thank u so much u deserve millions of subscribers 😊
@simonrozendal7542
@simonrozendal7542 Жыл бұрын
Wow especially with a lot of data, binary search goes really vast and saves a lot of time and energy. thank you John.
@hashantha_lk
@hashantha_lk Жыл бұрын
The best explaining ever ! Clarity is top notch John ! Sending gratitude from SriLanka! ❤
@adulmdul8939
@adulmdul8939 Жыл бұрын
man you're my rescuer, with sincere love and appreciation
@SarangSaraf
@SarangSaraf Жыл бұрын
Thank you sooo much. I stopped watching my paid udemy Java courses after I found your channel. REALLY!
@5n2joelemmanuel54
@5n2joelemmanuel54 Жыл бұрын
john is so good at explaining i could binge watch these tutorials and not get bored
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Have at it!
@cloudycode5009
@cloudycode5009 Жыл бұрын
​@@CodingWithJohn Hey man, i love so much your videos im a student, im very excited, i want to see videos about Java GUI awt spring
@fruttoo
@fruttoo Жыл бұрын
One video watched, and boom! I became your subscriber. You''re really good with explanations. Congrats!
@amongusztav655
@amongusztav655 Жыл бұрын
Very informative and useful video! Thanks!
@viewer_evgeniy
@viewer_evgeniy Жыл бұрын
I want to add one important thing about moving high and low pointers to the "right" or "left" of middle pointer (mid+1 or mid-1), it's not just because we want to exclude the number (index) which out of our concern already since we know that if our searched value is not equal to the middle pointer value then there is no reason to ever deal with it again. But doing such kind of things (+1 or -1) ensures that we won't be stuck in an infinite loop (in case your searched value is not presented in the array).
@andreadiotallevi5780
@andreadiotallevi5780 Жыл бұрын
Such an excellent communicator - I wish to become as articulate as you. Amazing video!
@fisheyesarans
@fisheyesarans Жыл бұрын
Excellent explanation to prepare for a quick interview
@fardovav1
@fardovav1 Жыл бұрын
So well explained. Thank you John for coding and explaining each step. Much better than our professor could do!
@auritro3903
@auritro3903 8 ай бұрын
Damn I have my AP Computer Science A exam tomorrow, you're literally gonna save me :D Thanks!
@abuiman5251
@abuiman5251 Жыл бұрын
Thank you brother! Please don't stop teach us!! God bless you!
@chulsooslaugh1209
@chulsooslaugh1209 Жыл бұрын
Your explanations are easy to understand. It might be your voice or your choice of words but whatever it is, I'm thankful that I am able to fully grasp the concept more easily this time compared to when I took it 2 semesters ago. Looking forward to more videos in the future!
@justalilbit8887
@justalilbit8887 Жыл бұрын
Thank you John! I 've been digging into search algorithms, lately. It's great to see you made another great video for it.
@RehanAhmad1
@RehanAhmad1 Жыл бұрын
you're my end of search as Java Teacher.. no matter what algorithm we use.. 😀
@palakkhatri6264
@palakkhatri6264 Жыл бұрын
Amazing, amazing, amazing explaination John!!
@alexkotusenko
@alexkotusenko 2 ай бұрын
Short and sweet, thank you for an amazing video
@mylife9751
@mylife9751 6 ай бұрын
Thank you sir, you're helping alot of icse school, 10th graders 💞
@Antonio-kv4lj
@Antonio-kv4lj Жыл бұрын
Started learning Java two weeks ago. Your videos are godsent. Really enjoying them. I would very appreciate if you could make video about managing workspace, projects, files and jdks (jres) in Eclipse. I'm having little trouble with understanding all that. Much thanks.
@aldoumene6201
@aldoumene6201 Жыл бұрын
Yaay love it! more data structures and algorithms please 🙏
@mastershonobi110
@mastershonobi110 Жыл бұрын
Thanks John for making these vids; we appreciate your time and effort(s).
@jordanwhatareyoudoing
@jordanwhatareyoudoing 9 ай бұрын
thank you John wonderful video I will use this on my arrays homework, I have some ideas I want to accelerate faster.
@DadaKhan1912
@DadaKhan1912 Жыл бұрын
Hi Sir, I have watched every video of Java on your Channel. You are Extremely Super in Teaching Java. And now I want to Learn Java Spring Boot. And I think you are the best teacher to teach Spring Boot in Java. And it is also Tending Technology. So I am telling you to create a playlist on Java Spring Boot. And it will help all the people who want to learn Java Spring Boot. Thank you sir ❤
@fahadgaliwango4502
@fahadgaliwango4502 11 ай бұрын
first attempt and your explanation is very clear
@MariaRuiz-qm5ql
@MariaRuiz-qm5ql Жыл бұрын
Every time I need to understand something better I go to KZbin hoping that you’ve covered it …🙏 Thank you so much!!
@anishmathew7108
@anishmathew7108 Жыл бұрын
I think you are one of the best Java tutorials videos done in KZbin , can you done tutorials for spring boot
@ruvvier1509
@ruvvier1509 Жыл бұрын
This is such a good timing to what I am learning in class right now in college. Thank you John!
@btrsl
@btrsl Жыл бұрын
Great explanation 👌! First time watcher here, will watch more of your content.
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Thanks a ton! Hope they're helpful, and let me know if there's anything you'd like to see!
@btrsl
@btrsl Жыл бұрын
@@CodingWithJohn I've watched more than 10 videos of yours in last couple of days. Learned a lot! I'd love to see some Design Patterns content (implemented in java) on your channel.
@btrsl
@btrsl Жыл бұрын
and also congrats on 200k subs!!! 🥳🥳🎉🎉🎉
@kristhianortiz151
@kristhianortiz151 Жыл бұрын
I just needed this!!! You're a savior🙏🙏🙏
@davidpokol
@davidpokol Жыл бұрын
Great vid John, but here is a little thing you didn't mention about the built-in binary search method: If the number that we looking for is not in the array, the built-in method returns -(insertion point). So for example, if the array contains the following values {1, 2, 4, 5, 7, 9, 11}, and we would like to find 8, it would print -6.
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Nice! Didn't realize that about the built in one, that's a nice feature
@rtweakim3122
@rtweakim3122 9 ай бұрын
It is very simple and intuitive.😮😮😮😮
@gnair9064
@gnair9064 Жыл бұрын
Hey please don't stop uploading videos you are gret
@hackwithharsha
@hackwithharsha Жыл бұрын
00:07:21 Thank You, Any reason to declare private method as static ?
@kap21031991
@kap21031991 Жыл бұрын
This is very good content and explained in very simple manner!! Please try to create tutorials on concurrency and parallelism.
@FabianAshrafian
@FabianAshrafian Жыл бұрын
You`re carrying my grade, I love u
@TheTrueType
@TheTrueType Жыл бұрын
Hey John, amazing videos you got here on your channel. You are really playing in an own league, thank you very much helped me a ton! Would you mind doing a video about Iterator aswell?
@BajiShaik-sf5df
@BajiShaik-sf5df Ай бұрын
Super sir❤ I am from India
@fadhlifirdaussulaiman1463
@fadhlifirdaussulaiman1463 11 ай бұрын
Your DSA lectures are making me pass my IVs, damn it I'll repay you one day!!
@mouloudguell2763
@mouloudguell2763 Жыл бұрын
very good and clear explanation
@MannshaanSingh
@MannshaanSingh 2 ай бұрын
Too helpful to describe in words...
@benjaminallcock4268
@benjaminallcock4268 Жыл бұрын
Wow, this is awesome explanations, thank you 😃
@denisdominguez7287
@denisdominguez7287 Жыл бұрын
Hi John, great video. But here is a small correction. The result of looking for the number 8 should have been -6. Because binarySearch returns the index where the missing number should be -1 (-(insertion point) - 1). But for an exercise is really cool. Thanks for your time 🙂
@ManosSef
@ManosSef Жыл бұрын
This is not a correction, it's a different way of doing it. Java's built-in library does it this way, John does it by always returning -1 when not found. Depends on if you actually want to know where the missing element would be though.
@elizabeth00653
@elizabeth00653 Жыл бұрын
John I love your Java videos and I really think you're one of the best Java instructors here. I was wondering if you'd consider explaining a Java login project one day with a useful framework, or adding it to your course. That would be so awesome.
@williamsun2230
@williamsun2230 Жыл бұрын
Hi John! Love your videos!!! May you make one on the big O notation? Thank you!!!
@revolutionaryfrog
@revolutionaryfrog Жыл бұрын
I prefer to make my middle position variable "pointer" but nice simple explanation here!
@LizyAd
@LizyAd 3 ай бұрын
This was helpful. Thanks!
@UCE5YhzPOD
@UCE5YhzPOD Жыл бұрын
From my experience I would recommend to use half-open intervals instead of segments in all algorithms that use intervals like binary search, sortiing, segment tree and so on. It allows to decrease number of +1/-1 in the code, and this +1/-1 is a place where people often make mistakes. private static int binarySearch(int[] numbers, int numberToFind) { int low = 0, high = numbers.length; while (low + 1 < high) { int middlePosition = (low + high) / 2; int middleNumber = numbers[middlePosition]; if (numberToFind < middleNumber) { high = middlePosition; } else { low = middlePosition; } } if (low < numbers.length && numberToFind == numbers[low]) { return low; } else { return -1; } }
@reapxiety
@reapxiety Жыл бұрын
John! I love your vids man, Could you do a Linear Search algorithm? I'm honestly having struggles with that algorithm, very much appreciate it
@bels1
@bels1 Жыл бұрын
Fantastic explanation, as always! Can you also make a video on the Big O notation?
@katiebeers2476
@katiebeers2476 Жыл бұрын
I love your videos, you're fantastic
@kieranteets527
@kieranteets527 Жыл бұрын
I love your videos but i was wondering what editor are your using? Keep up the awesome videos!!
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Thanks! I use DaVinci Resolve to edit my videos, it's free and offers everything I need.
@eugenesmith9940
@eugenesmith9940 Жыл бұрын
I've seen in some binary search realizations that formula to calculate middle pointer looks like that: low + (high - low) / 2. Why is that? Also, inside Arrays class this part of binary search looks like: (high - low) /2 >>> 1. How to read such code? What >>> 1 does in this case?
@girijashankarn
@girijashankarn Жыл бұрын
Sane question…. Did you get any answer on low+(high-low)/2?
@ritampramanik1
@ritampramanik1 9 ай бұрын
Professor your explanation is genius. Can you help me in an additional part, like if I want to print "Sorry we cannot find the number" instead of -1 what are the changes can we make to modify this code? THANK YOU in advance.
@oussamaachour1523
@oussamaachour1523 Жыл бұрын
Hey john, thanks for all your tutorials, I would like to see you doing one project with all the oops concepts if that is possible
@Talkatfive
@Talkatfive 10 ай бұрын
Excellent tutorial
@Tranzin40
@Tranzin40 Жыл бұрын
cool video, it would be cool to hear about faster search and sorting algorithms
@ВладиславСалюкТВ-23
@ВладиславСалюкТВ-23 Жыл бұрын
John , you are the best programmer-blogger I ever seen. Ukraine is watching you right now 🇺🇦❤️
@ngndnd
@ngndnd Жыл бұрын
woah wtf this was posted at the perfect time. I searched this up thinking it was one of your older videos lmao
@CodingWithJohn
@CodingWithJohn Жыл бұрын
Nice! I stole the thumbnail pic from an older video (forgot to take a new one...) so maybe that thre you off
@angelcholakov2670
@angelcholakov2670 Жыл бұрын
Hi John, I really enjoy your videos and the way you explain java in general, so thanks about what You do I am sure loads of people do appreciate it too. I wonder if You have plans to do a video about GUI any time soon? I would love to see one (if this can be done in one video of course) as I am about there in my java study right now
@ciccioJava
@ciccioJava Жыл бұрын
Jhon why dont you start a tutorial about Spring? Thanks to you I learned Java and now I am having some problem with spring without your video! 😁
@prasannsurya9415
@prasannsurya9415 Жыл бұрын
Hey john i have a doubt in java, what is the difference between object and instance , please could you make a brief video of that it will very useful to all , and make more understanding of the fundamentals in java
@TheGamer720x
@TheGamer720x Жыл бұрын
Hi John, I'm curious to know for the experience you have in the software industry, what were the concepts in Java that were crucial in any scenario apart from basic control structures? Any design patterns/frameworks? Any concepts like Inheritance/ Overloading / Overriding etc? Thanks.
@atrivyas8512
@atrivyas8512 Жыл бұрын
all of them are equally important
@teo_ke
@teo_ke Жыл бұрын
could you make video about static in class. how it works and where we should use it in
@djouudjou
@djouudjou Жыл бұрын
can we do the same but without hard coding the values ? like ask the user to enter all the vales and the target value ?
@Therandomness1235
@Therandomness1235 4 ай бұрын
Will the user be sorting the numbers while they enter them? If not, will there be a way to put the numbers in ascending order?
@programmingwithnurulhuda
@programmingwithnurulhuda Жыл бұрын
It's always good to learn something.
@explorer10179
@explorer10179 Жыл бұрын
Thanks so much. It really helps. Can you please upload a video explaining "Static" keyword? Thanks again!
@SamandarHamrayev-h2h
@SamandarHamrayev-h2h Жыл бұрын
its great video
@ManishYadav-yp2mi
@ManishYadav-yp2mi Жыл бұрын
Your videos are really helpful and good for students like me. If only you can start a series of leetcode solving regularly that would be game changer for us. Whether you upload something or not try to upload problem solving question. thank you
@findlestick
@findlestick Жыл бұрын
Can you do a video about how ChatGPT is changing the coding scene, and its potential consequences?
@omparghale
@omparghale Жыл бұрын
Hey john,which color scheme and theme do you use in your intellij ide?
@ganastars7402
@ganastars7402 Жыл бұрын
Could you please send me a link for complete course for learning Java for biggner for yourself
@kshitijofthejune
@kshitijofthejune Жыл бұрын
Implement red black tree in java.. Using enums
@csistheonlychoice8256
@csistheonlychoice8256 Жыл бұрын
can you make a video about time complexity of algorithms and Big O, Big Ω etc, notations please??
@codeZarathustra
@codeZarathustra Жыл бұрын
Thanks Jhon!
@magudesh5872
@magudesh5872 4 ай бұрын
HI, I have a doubt. will low
@noobster9212
@noobster9212 Жыл бұрын
very thoughtful idea
@JavaCodeShorts
@JavaCodeShorts 7 ай бұрын
thanks for sharing!
@ashishp-c3i
@ashishp-c3i Жыл бұрын
Thnx for the wonderful tutorial and keep up the good work => Btw you look like Mark Strong/ Jhonny Sins 🙂
@MaxBondarenko
@MaxBondarenko Жыл бұрын
Does it make sense to use it for Strings array?
@Avarn388
@Avarn388 Жыл бұрын
Is a good way to think of Binary Search is that if you have a physical dictionary, you’re starting at the middle and going left or right in sections as opposed to starting from the beginning or end of a dictionary? Correct me if I am wrong.
@CodingWithJohn
@CodingWithJohn Жыл бұрын
That's a great way to think about it!
@beachbuggyracing9305
@beachbuggyracing9305 Жыл бұрын
Great sir...
@enriquepasa
@enriquepasa Жыл бұрын
Thanks for the video
@eizwaneiz
@eizwaneiz Жыл бұрын
you know how good your video is? when a 17 minutes video felt tile 5 minutes.
@da_nightcore
@da_nightcore Жыл бұрын
yeah man do more prob solving stuff ,really need them in java
@marknebadon8709
@marknebadon8709 Жыл бұрын
Just one question, from what I can see, is that we get a single number in the middle range when they are an odd set of numbers, so I was wondering what happens if we have 20 inputs in the array, which equals to 20 -1 / 2 in terms of index. What is the number evaluated? help please
@hemobhai1
@hemobhai1 Жыл бұрын
Thank You Sir
@osmanozturk5891
@osmanozturk5891 Жыл бұрын
Thanks John . i have a question if our array was int[] ={1,2,4,5,7,9,11,12} What search algorithm would we use? (fast)
@ManosSef
@ManosSef Жыл бұрын
It doesn't matter what the array is, binary search does the job.
@sdxus
@sdxus Жыл бұрын
Nice detailed tutorial! I think it's better/safe to sort the array first @Line12 -->>> numbers = Arrays.stream(numbers).sorted().toArray();
@AlisonAcostachinchilla18
@AlisonAcostachinchilla18 9 ай бұрын
Thanks for the content. But why did you write the binarySearch method as private: "private static int binarySearch" ?
@mylife9751
@mylife9751 6 ай бұрын
Private method restrics the accessiblity of method to the respective class only
@clarence9527
@clarence9527 Жыл бұрын
hi, john, can you make a episode about the backslash usage in java regex please? such as the "\\\\" impies the "\" in java. it is tricky to understand.
@pzmt8051
@pzmt8051 Жыл бұрын
Is it possible to run java on colab?
@trup10ka
@trup10ka Жыл бұрын
Hello, this video was again, awsome, you though me so much during year 2022. I do have a request. Could you make a video about How to use Java with server requests and some things aroud this topic (URL's or something; I'm not really educated in this so please forgive me if I described it badly 😀)
@الجورزماوي
@الجورزماوي Жыл бұрын
hello sir, again with another wonderful video , i would like to ask you if you can make a video about Dependency Injection in java
Quicksort Sort Algorithm in Java - Full Tutorial With Source
24:58
Coding with John
Рет қаралды 259 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Java's Creators Rejected Multiple Inheritance - Here's Why
13:14
Coding with John
Рет қаралды 71 М.
Linear & Binary Search Code | Big O Notation
19:31
Telusko
Рет қаралды 42 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 913 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 763 М.
Binary Tree Algorithms for Technical Interviews - Full Course
1:48:53
freeCodeCamp.org
Рет қаралды 748 М.
Recursion in Java Full Tutorial - How to Create Recursive Methods
11:11
Coding with John
Рет қаралды 282 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 795 М.