Big O Notation - Code Examples

  Рет қаралды 114,945

Keep On Coding

Keep On Coding

Күн бұрын

Пікірлер: 132
@KeepOnCoding
@KeepOnCoding 2 жыл бұрын
Get the full course here ➡ keeponcoding.io/data-structures
@sarahaz4151
@sarahaz4151 2 ай бұрын
oh no sight cant be reached
@sarahaz4151
@sarahaz4151 2 ай бұрын
could you post it again
@ricardoestrella95
@ricardoestrella95 4 жыл бұрын
Definitely you're my hero. I just reached this topic in my data structure classes last week and I didn't understand at all until now. I wish you were my teacher. :(
@aayushmathpal9665
@aayushmathpal9665 4 жыл бұрын
After 4 hours of searching I got this video and finally understood the concept of Big O. Why don't you tube recommend such videos on the top :(
@MrElderwand
@MrElderwand 3 жыл бұрын
What an amazing explanation, hope this will definitely help me in cracking my next set of problems. A big thanks!
@sabianzhupa2823
@sabianzhupa2823 2 жыл бұрын
I have an exam in data structures tomorrow, you really help me a lot , thank u man you are awsome :)
@ArmanOganesyan
@ArmanOganesyan 4 жыл бұрын
That is a very useful, dude! Eventually I understood why O(2n) is O(n). And the last example was really tricky. Thank you for the video.
@skumakerguitar8708
@skumakerguitar8708 4 жыл бұрын
haha yea this is happened to me
@theaudiomelon
@theaudiomelon 2 жыл бұрын
I got more out of this than my last two class sessions of my teacher trying to explain it. THANK YOU
@azkymohamed123
@azkymohamed123 4 жыл бұрын
Great refresher... Gotta admit, I missed the last one.
@samuelmichael914
@samuelmichael914 4 жыл бұрын
Been trying to understand the nested for loops for a while and how they work in bubble sort. Thank you for the explanation.
@jorgevasquezang
@jorgevasquezang 4 жыл бұрын
Great explanation, thanks for sharing!
@bbbbluhhhh
@bbbbluhhhh 3 жыл бұрын
Best video that helped me in my data structures course. Code examples are so helpful!
@abel94214
@abel94214 4 жыл бұрын
This was amazing! Please please make more. You are very good teacher man!
@TheFirstNerubi
@TheFirstNerubi 3 жыл бұрын
came here to learn more about bigO and learned also how to draw out recursive methods! -- they always gave me a hard time; thanks a lot!
@MohammedBakheet
@MohammedBakheet 4 жыл бұрын
That was beautiful man, can't thank you enough, keep coding
@vdtidake
@vdtidake 4 жыл бұрын
crisp and clear explanation
@GreenFlame16
@GreenFlame16 3 жыл бұрын
Value acquired, expressing gratitude
@saideepesh6036
@saideepesh6036 4 жыл бұрын
Make a part-2 explaining some harder problems.
@shreephadke3679
@shreephadke3679 4 жыл бұрын
I second this!
@makok5825
@makok5825 4 жыл бұрын
@@shreephadke3679 Same
@jeff_mci_gaming6018
@jeff_mci_gaming6018 4 жыл бұрын
I agree, these are common examples. Good stuff tho
@vighnesh93
@vighnesh93 4 жыл бұрын
+1
@nikhilraov100
@nikhilraov100 4 жыл бұрын
Simple explanation is the best explanation and u have nailed it
@FlawlessYT66
@FlawlessYT66 2 жыл бұрын
What a hero you highlighted on tricks that i wasnt aware of. Much Thanks
@prafulmaka7710
@prafulmaka7710 2 жыл бұрын
Very good explanation on application of BigO to real examples. Liked and subscribed!
@chilkuru
@chilkuru 3 жыл бұрын
Wonderfully explained the Big 'O' Notation calculation. Thanks
@kpkauur
@kpkauur 3 жыл бұрын
Brilliant explanations. Please cover all the big O's examples & coding exercises of cracking the coding interview.
@ngndnd
@ngndnd 2 жыл бұрын
this is exactly what i needed. Im the type of person who can ONLY learn from examples or else i zone out i did find the parts with the recursive tree kind of confusing. Didnt really understand why you did what you did
@pujakarmakar9176
@pujakarmakar9176 3 жыл бұрын
The last one was really tricky for me thanks for the video now I'm going to ace the presentation!!!!
@Lons_Tran
@Lons_Tran 8 күн бұрын
@5:42 I'm not understand why it's not a quadratic time since a is o(n) and b is o(n) I'm not familiar of bigO(a*b) what's is it ranking in the chart?
@Ewson556
@Ewson556 4 жыл бұрын
You know I'm starting to think you follow me around in real life. Next week I have an exam that includes a topic like algorithm analysis. Yet here you are....
@prodigalScindian
@prodigalScindian 3 жыл бұрын
Gone through so many articles and tutorials and never understood this bigO.. Simple problems with breakdown really helped understand better.. Thank you.. Can we try some complex example problems please
@Bosnian1212
@Bosnian1212 2 жыл бұрын
Thank youuuu I needed these code examples
@atifworld
@atifworld 2 жыл бұрын
Best explanations, specially the last one Thank you
@DeGoya
@DeGoya 2 жыл бұрын
it should be noted that println also takes time complexity of O(n) since it has to print every character of a string individually
@vasugupta1
@vasugupta1 4 жыл бұрын
Good explanation mate, keep it up
@mohamedalthaf526
@mohamedalthaf526 3 жыл бұрын
You are breaking the rule of teaching but in a good way!
@escargoux
@escargoux 3 жыл бұрын
in the fibonacci sequence, where are you getting the constant 2 from? (2^0, 2^1, 2^3..)?
@Lentato
@Lentato Жыл бұрын
because at the first level its 1, so 2^0, next level its 2, so 2^1, and next its 2^2, which is 4. He literally explained it in the video
@abovebelow4061
@abovebelow4061 2 жыл бұрын
I have my onsite with google in two hours hahaha I'm really glad I saw this
@justinliebenberg2321
@justinliebenberg2321 Жыл бұрын
My exam is tomorrow... I didn't really understand this topic until now. Thank you sir.❤
@aaryadeshpande1621
@aaryadeshpande1621 2 жыл бұрын
Question: 3:27 - can you please elaborate on why a constant doesn't make much difference? It seems like we would keep it since if n=1000 iterations, then for 2n, that would be 2*1000, which is 2000, as opposed to 1000. Or 20n throughout a program, then won't 20*1000 be MUCH different than just 1000 alone? I likely don't have the mental framework necessary to find this intuitive, so could someone explain it or direct me to a resource? Thanks!
@a7xxd
@a7xxd Жыл бұрын
It is very possible for O(N) code to run faster than 0(1) code for specific inputs. Big O just describes the rate of increase. For this reason, we drop the constants in runtime. An algorithm that one might have described as 0(2N) is actuallyO(N). Many people resist doing this. They will see code that has two (non-nested) for loops and continue this 0(2N). They think they're being more "precise:'They're not.
@cebastiansantiago3203
@cebastiansantiago3203 4 жыл бұрын
Bro thank you so much this makes so much sense better explanation then my professor
@kamran_desu
@kamran_desu 2 жыл бұрын
Brilliant, best way to explain is to use examples like this to hit it home.
@skumakerguitar8708
@skumakerguitar8708 4 жыл бұрын
thanks i have been thinking first example is O(n2) and 3rd example is O(n3) thanks for detail !
@KeepOnCoding
@KeepOnCoding 4 жыл бұрын
Glad to help!
@pratiknalage6408
@pratiknalage6408 2 жыл бұрын
This is amazing, exactly what I needed.
@aponoypi
@aponoypi 6 ай бұрын
learning the big O notation from stanford algorithm class. retired from IT after 35 years. missed programming
@MisTree118
@MisTree118 11 ай бұрын
thank you for your share~ best big-o examples!🤩
@almora4888
@almora4888 Ай бұрын
thank you limited time the exact thing i searched for
@codewithmarwan
@codewithmarwan 4 жыл бұрын
That was really helpful, deserve a sub and a big thumps up haha
@vanjamihajlovic1605
@vanjamihajlovic1605 17 күн бұрын
thank you for this!!! this is SO helpful 🙏
@xelordragon4507
@xelordragon4507 4 жыл бұрын
I think the biggest mistake for Big O is that people also forget that we are after the biggest time complexity so we drop the lower time complex values. Ex. 2N *2^N With this one 2N is a lower time complexity then 2^N so we don't really care about it and we would just drop it. Making the time complexity 2^N
@giacomodario5661
@giacomodario5661 3 жыл бұрын
What you say works with sum or multiplication by constants but the complexity here is O(N*2^N) because it is another infinite order bigger than 2^N and you have to take it into account :)
@juliahuanlingtong6757
@juliahuanlingtong6757 3 жыл бұрын
Good stuff! Please Make part2- more compliacted and tricky examples!!!
@KuldeepSingh-jg9xz
@KuldeepSingh-jg9xz 3 жыл бұрын
super !!! Keep up good work bro...
@yahyayozo8660
@yahyayozo8660 3 жыл бұрын
thanks man this really helped me
@michalrabek7743
@michalrabek7743 3 жыл бұрын
8:38 Recursive Fibonacci sequence... Ouch, my eyes. You should've shown the iterative implementation too, it would've been very beneficial. Nevertheless, it was a great video. I'm looking forward to part 2 :-)
@jaatharsh
@jaatharsh 4 жыл бұрын
can you plz share some reference/links to better understand last Problem time complexity, thanks in advance
@KeepOnCoding
@KeepOnCoding 4 жыл бұрын
You can reference the Big-O chapter in Cracking the Coding Interview
@fungusthemungus3754
@fungusthemungus3754 10 ай бұрын
You're a life saver!!! Thank you so much!
@patrickgroves1765
@patrickgroves1765 3 жыл бұрын
Examples with O log n and O n log n please!
@troyhackney148
@troyhackney148 Жыл бұрын
Great video! I was hoping to see O(logn) :)
@yuriiharasymovych7182
@yuriiharasymovych7182 3 жыл бұрын
Thanks a lot! Solved a lot of problems in my mind :)
@aztlijimenez
@aztlijimenez 3 жыл бұрын
This is exactly what I needed. Thank you so much!!!! :)
@frozen_dusk579
@frozen_dusk579 3 жыл бұрын
Thank you I wasn't sure that I understood Big O
@parabalani
@parabalani 3 жыл бұрын
Great video! But it's scary that some of these can be in an interview
@zaidpatel8695
@zaidpatel8695 Жыл бұрын
That last one got me too.
@ayanaxhye
@ayanaxhye 2 жыл бұрын
“the time complexity is based on whether or not the algorithm changes based on the input”. if the input doesn’t affect the algorithm then it is constant time. 😮
@JacobBrenke
@JacobBrenke 3 жыл бұрын
Hey man, this was valuable. Thank you.
@ariton2990
@ariton2990 4 жыл бұрын
Can you do tutorial on Java bitwise operators?
@NandoLofi
@NandoLofi 2 жыл бұрын
Just finishing my coding boot camp and trying to understand this....I know it's big for interviews but I want to have a strong understanding it. New to all this...seems difficult a bit .
@jacobwerner8533
@jacobwerner8533 5 ай бұрын
is this java code? im learning big-o through a c data structures and algorithm book.
@cabiste
@cabiste 4 жыл бұрын
3:05 i thought you were writing outside my screen
@fantashio
@fantashio 4 жыл бұрын
Nice video!!
@Viruzzent
@Viruzzent 4 жыл бұрын
Awesome vid. Thanks can u help me with this? im making a game for school. a card game in java. im learning a lot of stuff but i dont know much about design patterns. What design patters would you do for a card game?.
@dharsan.s7937
@dharsan.s7937 4 жыл бұрын
no O(logn) and O(log logn) it will be tricky with logs
@krishshah3974
@krishshah3974 4 жыл бұрын
the background is lit :)
@kellenstuart4698
@kellenstuart4698 3 жыл бұрын
Appreciate the video. That helped.
@phofuria
@phofuria 4 жыл бұрын
In the last example why we don't count how many times the fib will be called?
@memegalore257
@memegalore257 4 жыл бұрын
How about O(log(n))
@TitusRex
@TitusRex 3 жыл бұрын
Thanks a lot for this video
@omermir332
@omermir332 4 жыл бұрын
Thank you!
@nelsonberm3910
@nelsonberm3910 11 ай бұрын
Thanks man!
@josephwong2832
@josephwong2832 4 жыл бұрын
Thanks for the video
@christopherobrien6215
@christopherobrien6215 4 жыл бұрын
O(a*b)? first time i'm seeing this. i don't see anything that resembles it on the wikipedia page for big o or other resources i use. what is it called? ie constant, logarithmic, polynomial, etc. what's the name of O(a*b)?
@voldyking4526
@voldyking4526 4 жыл бұрын
It is just like n^2... But think of this in this way...if you had to traverse through a matrix with rows and columns equal to n,then time complexity would be n^2 right...but what if the matrix has different rows and columns..say no.of rows=a and no.of columns=b...then total input size is a*b right?? .. because the program has to run a*b times to traverse through the entire matrix...hope you understood this....
@luismisanmartin98
@luismisanmartin98 3 жыл бұрын
You could say it is the general case of a quadratic polynomial
@178fahimahmed7
@178fahimahmed7 4 жыл бұрын
Really helpful , Plz 2nd and 3rd video .
@LeetJourney
@LeetJourney Жыл бұрын
Nice video! I have got a similar Big O video (10 minutes long) which teaches you everything you need for your technical interview.
@sandeepchouhan838
@sandeepchouhan838 3 жыл бұрын
Please make a vedio on some harder problems!!!
@kays3599
@kays3599 3 жыл бұрын
these teaching videos are really helpful. If you ever needed more ideas for content, you just found it... TEACHING. :) #keeponcoding
@mikaelaq.purugganan4367
@mikaelaq.purugganan4367 2 жыл бұрын
"It's not about writing code anymore" I agree. I really need to grow and mature now. It's not really about 'just' writing a code now. aaah
@falconiere
@falconiere 2 жыл бұрын
Awesome!!
@finelliott2440
@finelliott2440 2 жыл бұрын
Is this pseudo code?
@abelrevelation8566
@abelrevelation8566 4 жыл бұрын
Awesome video. You said when you have 2^0 to 2^n-1 ... technically is equal to 2^n I need help on the math behind this :).
@MJ710287
@MJ710287 4 жыл бұрын
Note that 2^0 = 2^1 - 1. Now assume 2^0 + 2^1 + 2^2 + ... + 2^(n-2) = 2^(n-1) - 1. Then 2^n - 2 = 2 * (2^(n-1) - 1) = 2 * (2^0 + 2^1 + 2^2 + ... + 2^(n-2)) by our assumption. Therefore, by the rules of exponents 2^n - 2 = 2^1 + 2^2 + 2^3 + ... + 2^(n-1), which implies 2^n - 1 = 1 + 2^1 + 2^2 + 2^3 + ... + 2^(n-1). Since 2^0 = 1, it follows that 2^n - 1 = 2^0 + 2^1 + 2^2 + 2^3 + ... + 2^(n-1). This is called a proof by induction. We proved that if the result is true for (n - 1), then it is also true for n. Additionally, we showed that the results is true for n = 0. Thus when n = 1 we know the result is true for (n - 1) since n - 1 = 0, so it must be true for n = 1 as well. We can continue this logic so that the result is true for any integer n.
@koshirou7
@koshirou7 Ай бұрын
U saved my life
@904hattrick8
@904hattrick8 2 жыл бұрын
I don't know if anyone will see this, but what about finding Big Omega?
@chienphung9633
@chienphung9633 Жыл бұрын
last example is quite tricky
@bruceslasher6374
@bruceslasher6374 3 жыл бұрын
14:04 It's 2^n x 1/2 Not 2^n - 1 But it doesn't matter
@РуменЙордакиев
@РуменЙордакиев 3 жыл бұрын
2^n x 1/2 = 2^n x 2^(-1) = 2^(n-1)
@luismisanmartin98
@luismisanmartin98 3 жыл бұрын
That is wrong. It is indeed 2^n - 1 (no parenthesis), you need to use the geometric sum, look it up ;)
@humdrumsnail1036
@humdrumsnail1036 2 жыл бұрын
At 6:36 you miscalculated. It was supposed to simplify to O(N^3) because those were nestd loops
@АлександрЖарков-у9ш
@АлександрЖарков-у9ш 4 жыл бұрын
Cool, thanks
@vanshsindhu8559
@vanshsindhu8559 4 жыл бұрын
1:20 I am viewing in 1.75x speed
@dubble_g
@dubble_g 2 жыл бұрын
would have been nice if u just retyped that code and then put it on screen instead of a low resolution photo but otherwise good
@SuperYtc1
@SuperYtc1 3 жыл бұрын
Bik ohhh of n riiiiiii ??? (imitating my Chinese lecturer from university 5 years ago in computational methods module).
@Chmouss
@Chmouss 4 жыл бұрын
Me at every examen ... big O :')
@hamidbluri3135
@hamidbluri3135 4 жыл бұрын
I doubt about last one
@izzafraxene
@izzafraxene 3 жыл бұрын
you are amazing
@andrews13
@andrews13 3 жыл бұрын
Perfect
@mercedesaker7947
@mercedesaker7947 4 жыл бұрын
Very good explanation, definitely learned from this. 👍🏻
@techslugz
@techslugz 4 жыл бұрын
Dont you all think its crazy how you get good videos like this, and some (4) twat(s) who click dislike. I mean yeah, maybe they just dislike the video sure, but why click it, so toxic.. I mean fair enough he could make money via the videos but they are also massively helping potentially millions of people, if they are interested.
@techslugz
@techslugz 4 жыл бұрын
I appreciate the video anyway
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 553 М.
Complete Beginner's Guide to Big O Notation
21:58
Colt Steele
Рет қаралды 231 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
What Is Big O Notation?
17:45
Reducible
Рет қаралды 319 М.
Learn Big O Notation In 12 Minutes
12:18
Web Dev Simplified
Рет қаралды 193 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 420 М.
Full Computer Science Degree in a Nutshell
20:39
MrAlgorithm
Рет қаралды 116 М.
Big-O notation in 5 minutes
5:13
Michael Sambol
Рет қаралды 1,2 МЛН
Compiled Python is FAST
12:57
Doug Mercer
Рет қаралды 124 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Big O Notation, Time Complexity | DSA
21:17
Telusko
Рет қаралды 87 М.