Introduction to Big O Notation and Time Complexity (Data Structures & Algorithms #7)

Поділитися
Вставка
  • Опубліковано 28 вер 2024
  • Big O notation and time complexity, explained.
    Check out Brilliant.org (brilliant.org/..., a website for learning math and computer science concepts through solving problems. First 200 subscribers will get 20% off through the link above.
    Special thanks to Brilliant for sponsoring this video.
    This was #7 of my data structures & algorithms series. You can find the entire series in a playlist here: goo.gl/wy3CWF
    Also, keep in touch on Facebook: / entercsdojo

КОМЕНТАРІ • 1,6 тис.

  • @Thunderbuck
    @Thunderbuck Рік тому +115

    I'm in my late 50s and starting a DS & A university course, and of course the first term I hit was "big-Oh" and when I saw the academic definitions it nearly triggered a panic attack. I am SO grateful for this engaging lecture and also immensely grateful that the Internet makes such valuable content available.

    • @Imsupposedtostudy
      @Imsupposedtostudy Рік тому +2

      why are you not fishing or living in a hut

    • @TheRealTruth65
      @TheRealTruth65 Рік тому +15

      Why don"t u study instead of being rude@@Imsupposedtostudy

    • @乐文玉
      @乐文玉 Рік тому +1

      We're on the same boat, and this lovely tutorial also saved me from panicking! Keep on going my friend!

  • @cl0udbear
    @cl0udbear 5 років тому +4106

    "I'm gonna use pseudocode"
    **uses Python**
    Python: "Am I a joke to you?"

    • @MrKiraBR
      @MrKiraBR 5 років тому +22

      UAHAUHAUHAUH

    • @cl0udbear
      @cl0udbear 5 років тому +11

      @@MrKiraBR yareet there pal?

    • @MagDrag123
      @MagDrag123 5 років тому +42

      Top 10 anime plot twists.

    • @melvinsoto
      @melvinsoto 5 років тому +91

      My professor does the exact same thing. Assignment: Write the pseudo code for a sorting algorithm and run it. You can’t run pseudo code!!

    • @cl0udbear
      @cl0udbear 5 років тому +24

      @@melvinsoto Sure you can. Make a state table where the columns are variables/registers/array elements etc and the rows are the state after the line number is executed. Treat the pseudocode as interpreted code, with you standing in for the interpreter, and track the state on the table as you 'run' the code.

  • @Titan_Ruler622
    @Titan_Ruler622 6 років тому +142

    The flow of your explaining is excellent. After getting frustrated from reading this from text books, I came here and now it looks so simple to understand. Really excellent man..☺

  • @shrutisharma3146
    @shrutisharma3146 4 роки тому +8

    This is by far the best explanation of time complexity and how to calculate it for any function that I have seen on UA-cam. Thank you.

  • @dhruvsingh1837
    @dhruvsingh1837 4 роки тому +7

    Sir, you are doing a really great job. I am able to understand each and everything in this tutorial. You put so much effort into your tutorials. I cannot thank you enough for this crystal-clear explanation. You even quit your job at google, just to teach and share your knowledge with us and that too for free, mad respect for that. Thanks again sir.

  • @mohammedghouse9088
    @mohammedghouse9088 6 років тому +331

    And can you also add O(logn) and O(nlogn)

    • @scopestacker9787
      @scopestacker9787 5 років тому +2

      No, it has to be a mapping inside O(). O(n -> logn) O(n -> nlogn)

    • @abilmansurzhuvandykov9981
      @abilmansurzhuvandykov9981 5 років тому +11

      @Youssef Zahir Data Structures and Algorithms in Python [Goodrich, Tamassia & Goldwasser]. Chapter 3

  • @malickdiagne
    @malickdiagne Рік тому

    I have learning it at university at 2013 and i couldn’t understand this s***t. After ten years, i can proudly say i get it. Thanks you guy. You are genius. That’s the best algo complexity’s explanation that ever seen

  • @Sarah-uh8wy
    @Sarah-uh8wy 6 років тому +371

    I should be paying my tuition and fees to you lmao
    Seriously, thanks!

    • @cruzer6571
      @cruzer6571 4 роки тому +10

      Having to pay tuition for going to university/college must suck /🇸🇪

    • @SauceyRedHN
      @SauceyRedHN 3 роки тому

      Cruzer ikr 🇳🇴

  • @mor11lano93
    @mor11lano93 4 місяці тому

    bro, my lecturer just explained it so poorly for 4 hours. And you just made it so understandable in half an hour! good job man thank you

  • @retinalhd
    @retinalhd 5 років тому +3

    Thank you so much for explaining this. I have a quiz on Big O analysis tomorrow and I was completely lost before watching this video.

  • @brainy3429
    @brainy3429 3 роки тому

    when I watched this a week ago , I didn't quite understand this.Maybe because that was my very first time to learn Big O and time complexity.But this time,I really understand everything U taught.Thanks sir! and if there were someone out here who didn't understand this right away , don't be discourged.U will understand this when u watch next time.

  • @toberixng
    @toberixng 5 років тому

    I am not a computer science student, I have been struggling to understand BIG O Notation for month, this solve this in the simplest best of way. thanks a million

  • @fiNitEarth
    @fiNitEarth 6 років тому +120

    I really would love to see a explanation on the mathematical details!:) When i wrote programms for maths class I always myself how I could figure out how much time a certain Programm would Take to run and if it's even worth to wait for a result! Thank you for your video

    • @medgazzeh9884
      @medgazzeh9884 6 років тому +4

      Here is the more accurate mathematical definition of O(something):
      Let be U(n) and V(n) two sequences then U(n)=O(V(n)) if and only if U(n)=W(n)×V(n) where W(n) is a bounded sequence in other words it exists a natural number 'N' and a real number 'M>0' where for every natural number 'n' with n>N then | w(n) | < M
      This ( O( ) ) is used to approximate the behavious of a sequence with an other , in other words _ and in the case of time complexity _ the graph of execution time for an algorithms is very similar to the one of the expression inside the parentheses after big O.

    • @CSDojo
      @CSDojo  6 років тому +21

      Okay! Sorry I just saw this comment - I'll see if I can make it after my trip :)

    • @tunebrotherdon
      @tunebrotherdon 5 років тому

      ++++++

    • @NguyenTrang-je6zg
      @NguyenTrang-je6zg 5 років тому +1

      I would love so too

    • @eiderdiaz7219
      @eiderdiaz7219 5 років тому

      same here

  • @hansonlee4195
    @hansonlee4195 5 років тому

    A very good and detailed explanation of Big O notation and time complexity. I'm a college student and I took Data Structure course before but the professor was suck so that I end up did not learn any knowledge about Data Structure. After I watched this video, I really hope that you were my professor at the time that I was learning Data Structure. Excellent video.

  • @colton-cu5kf
    @colton-cu5kf 5 років тому

    Where have you been all my life? You summed up in less that one hour what I have been struggling for weeks to learn. TY!

  • @HarshaVardhan17
    @HarshaVardhan17 6 років тому +16

    Hi CS Dojo really love your content!! Please make more content on python for people coming from other languages like java,c++ gives the differences in syntax, structure in OOP, control statements, inbuilt data structures and important libraries in it. Also missed you for so long !!!😻

    • @CSDojo
      @CSDojo  6 років тому +5

      Okay sounds good. Thank you for saying that!

    • @HarshaVardhan17
      @HarshaVardhan17 6 років тому +4

      CS Dojo my pleasure 😇 YK!! Thanks for making videos!!!

  • @leooel4650
    @leooel4650 5 років тому +2

    Sincerely, what a tremendous talent!
    Took me 36 minutes to understand everything that I have been struggling to understand for weeks.
    Thanks YK

    • @scars707
      @scars707 3 роки тому

      Fuck that ***pp

  • @technogrinder
    @technogrinder 5 років тому +3

    Thanks Bro, I just cleared an interview with the help of this video. Love you from India

  • @MWmDGC
    @MWmDGC 4 роки тому

    My professor, who has been teaching programming for 35 years, could not explain this concept properly and you just made it look so simple in just 30 minutes. Not all heroes wear capes, indeed.

  • @chanwingkei1576
    @chanwingkei1576 4 роки тому +3

    Thanks for this!! Very helpful. And I suggest whoever thinks this is good should go through all the ads(that's what I do) so that Dojo can make more from this great contribution ;)

  • @delealli9965
    @delealli9965 2 роки тому

    OMG you make it so simple to understand! Thank you. My professors need to take notes.

  • @alfredoromero1346
    @alfredoromero1346 2 роки тому +5

    the teacher at my university is getting paid while this guy is the one who teaches me things correctly. it seems unfair.

  • @imrych2014
    @imrych2014 5 років тому +1

    It's a shame for me that I have worked with various types of projects but I don't know basic things like this, thank you, you just made my day! :)

  • @FilipMakaroni_xD
    @FilipMakaroni_xD 2 роки тому +3

    Great video, I finally understand Big O and how to get it for my programs, the ending was exactly what I was wondering about, what if there's two equally growing highest terms.
    Someone correct me if I got the wrong expression but since O(2n^2)=O(n^2) I think it's safe to simplify the initialization, addition and return of variables to O(1) when non scientifically determining the big O notation as it will probably never increase the notation more than it would have been anyway

  • @ollysalanson9452
    @ollysalanson9452 3 роки тому

    I started coding two years ago after watching your videos, now I'm back and still getting so much out of your content. Thanks so much for creating this content.

  • @angkymusa972
    @angkymusa972 3 роки тому

    I really understand more much better bigO now with your explaination than my lecturer did in college. I wish i knew your video several years ago and i hope i can achieve my dream for being a lecturer then teach these to my student so they can understand as much as i did. Thank you so much, may god bless you.

  • @jiyunhwang9559
    @jiyunhwang9559 5 років тому +3

    this is a great video!
    one small correction: for the first find_sum function, i believe total should be total += array[i], rather than i.
    other than that, great video! kudos to you.

  • @lindawisebear
    @lindawisebear 5 років тому +2

    I wish you were my university lecturer - so happy to have found this!! :) It made things make so much more sense!

  • @ThetaSonne
    @ThetaSonne Рік тому

    Your teaching style is unmatched. Thank you for this video.

  • @sasubramanian6893
    @sasubramanian6893 4 роки тому

    i have not understood this concept till this lecture,great tutorial ever , awesome! Thank You lot!

  • @NoName-rb6fj
    @NoName-rb6fj 3 роки тому

    Oh hell, i hardly understood anything while reading about this topic in book, but here everything explained very clear! Thanks you so much!

  • @WhyNotProgram
    @WhyNotProgram Рік тому +1

    I’ve been struggling with this concept but you explained it better than most!

  • @dano.819
    @dano.819 4 місяці тому

    UA-cam-U at it's finest! Thanks so much for the elegant explanation!

  • @shree2710
    @shree2710 6 років тому +14

    My drug is back!
    お久しぶりY.Kさん!

  • @gisellemartinez-sanchez2071
    @gisellemartinez-sanchez2071 3 роки тому

    These explanations are priceless! This video is highly UNDERrated.

  • @chrishelm1
    @chrishelm1 3 роки тому

    Someone give this man a medal!!!

  • @stutigoyal2771
    @stutigoyal2771 4 роки тому +1

    This video has literally cleared all my concepts on this topic. Thank you so very much CS Dojo!

  • @viveksuman9600
    @viveksuman9600 4 роки тому

    The best video on Big O on youtube. Great explanation 👍

  • @mzamomahaeng268
    @mzamomahaeng268 5 місяців тому

    Your video simplified an entire university class😢thank you

    • @PawnxPawn
      @PawnxPawn 5 місяців тому

      I find books and universities will over complicated things just to make them longer. 😅

  • @lemonwithswag2593
    @lemonwithswag2593 6 років тому +5

    Hi, awesome video as always.

  • @samsricatjaidee405
    @samsricatjaidee405 4 роки тому

    Thank you very much. Your explanation is so clear. Now I understand Big O Notation after long time confused.

  • @pauldaviddavies
    @pauldaviddavies 4 роки тому

    Premiered in 2014 but as sweet in 2020. So relaxed, composed and to the point. I had to subscribe!

  • @steafansteinocher462
    @steafansteinocher462 Рік тому

    Can someone explain to me why I understand this CLEARLY whereas a traditional math class I couldn’t get through basic algebra? Or he’s that great of a teacher

  • @michaelokellomykfrost
    @michaelokellomykfrost 2 роки тому

    I swear i never got this concept in college but YOU SIR are a legend. Thank you man.

  • @shankar7435
    @shankar7435 2 роки тому

    Excellent explanation. This is far better than many paid courses. Thanks for such a quality content.

  • @alfredama
    @alfredama 2 роки тому

    love this guy!!! my favorite UA-cam programmer all hail CS dojo

  • @georgez.7278
    @georgez.7278 4 роки тому

    Thank you my frieng, You should be a proffesional tutor at some university. You make my college teachers look stupit. The way you explain everithing is so much easier to understang. Thank you very, very much.

  • @ahmadabeeb6151
    @ahmadabeeb6151 2 роки тому

    Thank you a million times over. Excellent teaching.

  • @snk31195
    @snk31195 4 роки тому

    Its amazing the way you simplified this complex term. Even a kid can understand this way. Please make video explaining complexity equations

  • @mariaselenta2412
    @mariaselenta2412 7 місяців тому

    Hi, this lovely tutorial also saved me from panicking! Thank you and keep on going please 🙂

  • @LoofaTroopa
    @LoofaTroopa 8 місяців тому

    I could not understand this for the life of me in our text. This helped so much.

  • @NthHarmonic
    @NthHarmonic 4 роки тому

    Explained perfectly. I don't understand why it can't be explained this way in my CS courses...

  • @archanakadam2980
    @archanakadam2980 2 роки тому

    Most appropriate explanation I have ever seen

  • @calvinrogercanas6737
    @calvinrogercanas6737 2 роки тому

    Thank you YK, this really helped me understand Big-O notation.

  • @JacobSnover
    @JacobSnover Рік тому

    Great vid, I love how Python is becoming everyone's psuedo code

  • @acc.7953
    @acc.7953 4 роки тому

    U made it so easier to understand. Respect

  • @plusqueparfait6759
    @plusqueparfait6759 4 місяці тому

    which is the time complexity of the following sequence? and why?
    int n, i, j, k, s=0;
    cin>>n;
    for(i=1; i

  • @oldgamerZone
    @oldgamerZone 3 роки тому

    A huge "Thank you" from Italy

  • @lolomimama193
    @lolomimama193 4 роки тому

    Thank you! My professor literally did not explain this at all. It just appeared in the activities..... It's like going to university so they make you find yourself everything....

  • @tz2014
    @tz2014 4 роки тому +2

    Hello YK thanks for this great video, I would appreciate another video that explain the formal definition of big(O)and also more advanced topics on data structures and algorithm.

  • @jacobzheng8701
    @jacobzheng8701 3 роки тому

    Thank you for making this video. You explain much better than my professor!

  • @amberski7198
    @amberski7198 5 років тому

    Currently studying for my Data Structures midterm a after this video I feel more confident about it!

  • @alexbaeza1541
    @alexbaeza1541 4 роки тому

    Excellent presentation of Big O! Very clear and easy to follow, I plan to recommend this.

  • @roadtv6860
    @roadtv6860 3 роки тому

    Now I know a bit of python code :D honestly we didn't cover this topic in curriculum we have. You are just the one who introduce it to me and I'm glad you are my prof because I easily catch up the topic you're discussing.

  • @karthiksk7246
    @karthiksk7246 6 років тому +4

    What if the row and column are not equal will it be O(mn)??
    Stupid function 👌😂😂

    • @ihorbond
      @ihorbond 5 років тому +2

      My exact question too! And I think it would be linear O(n) where n = rows * columns

  • @koreanrhythm8248
    @koreanrhythm8248 4 роки тому

    Ur way of teaching is really good

  • @DrizzleAnimations
    @DrizzleAnimations 4 роки тому +2

    This video has been infinitely more useful to me compared to my professors who have spent 3 weeks trying to explain this to me. You're a legend, thank you so much :D

  • @thecodinghustle1006
    @thecodinghustle1006 5 років тому

    whitelisted your channel from my adblocker and watched your ads.... that's the best i can apparently do to help you :) THANK YOU!

  • @venuarremsetty2425
    @venuarremsetty2425 4 роки тому

    Your explanation is simple and clear. What is the TOOL you are using? it enhances your teaching methodology.

  • @kwiktips
    @kwiktips 3 роки тому

    This was my second Big 0 explanation video and it may be my last. Perfect!

  • @j_aaa_y
    @j_aaa_y 3 роки тому

    Very helpful!! Loved the teaching style!!!

  • @yassinechaoui95
    @yassinechaoui95 3 роки тому

    Thanks million for this wonderful and clear explanation !!

  • @subtlecommunication2039
    @subtlecommunication2039 4 роки тому

    This guy is good at explaining

  • @sriramvadakattu6635
    @sriramvadakattu6635 4 роки тому

    Simplest explanation. Thanks for the video

  • @jwange1
    @jwange1 3 роки тому

    TNX man, you have a good head in explaining data structures.

  • @ava.wolf.
    @ava.wolf. 5 років тому +2

    Thank you🍁🍁Love from India💜

  • @fun2badult
    @fun2badult 4 роки тому

    Would you say that the Time Complexity is basically the dimensions of the arrays we are using? For example, a single 1-dimensional array is O(n), 2 dimensional matrix array comes out to O(n^2) and a 3-dimensional array would come out to O(n^3)? Or would that also represent how many for-loops we are trying to use? 1 For loop would be O(n) and 2 for-loops would be O(n^2) and so on

  • @beibityergesh9838
    @beibityergesh9838 3 роки тому

    Please professors, explain new concepts like this guy

  • @karolinecruz3391
    @karolinecruz3391 2 місяці тому

    Thank you so much. Now I understood and will practice!

  • @orlandoirizarry8130
    @orlandoirizarry8130 3 роки тому

    Very good and timely video and education!

  • @cara1362
    @cara1362 3 роки тому

    It's a super clear explanation to Big O! Thank you so much!

  • @mohitdeshmukh3456
    @mohitdeshmukh3456 3 роки тому

    Thank you so much for this video! You explained this in very lucid way.

  • @scar_c2_1d
    @scar_c2_1d 11 місяців тому

    a legend. a legend, my guy

  • @wulumgames
    @wulumgames 2 роки тому

    That was a brilliant detailed explanation. Thank you!!!

  • @HarshKumar-nh6be
    @HarshKumar-nh6be 4 роки тому +1

    Thank u dOjO u make me understood bigO to me:)

  • @elsbbbb1
    @elsbbbb1 2 роки тому

    This is very well explained, thank you.

  • @frederickrbrock
    @frederickrbrock 5 років тому

    I really enjoyed this video. Great Job!! It was a good refresher for me before I started interviewing. I was given some problems to solve as part of an interview and I nailed it.

  • @deepikat2570
    @deepikat2570 4 роки тому +1

    Cs dojo can you make one crash course in data structures and algorithms?

  • @devleonardodavid
    @devleonardodavid Рік тому

    JUST BRILLIANT! What a superb video to understand the topic, thank you very much!

  • @MarcusAseth
    @MarcusAseth 4 роки тому

    I came here to learn about this big-O notation, but what I see a 31:41 seems wrong, maybe I've misunderstood something so please correct me if I'm wrong #CSDojo .
    So let's assume your array_2d at every index has a single sub_array or 1 element, then even if you iterate trough it with those 2 for loops, is still 1 operation per sub_array, identical to the normal array case so O(n). Now in your example where you have each sub_array of size 4, you're still adding a linear ammount of element per each sub_array, therefore if your array_2d is size 5 (5 sub_array of size 4) you're doing `total += i` 20 times, and if your array_2d is size 10 (10 sub_array of size 4) you are doing `total += i` 40 times, array_2d of size 15 would be 60 operations and so on. Therefore this is linear and O(n). Am I wrong?

  • @SupGhostly
    @SupGhostly 5 років тому

    I wish u had a course ,or software engineer path, video playlist , you are really good at teaching

  • @kabralmogos2787
    @kabralmogos2787 5 років тому

    Thank you. The way you explain is very clear and understood. We are waiting more videos.

  • @jaivang5243
    @jaivang5243 2 роки тому

    Just one word: amazing!

  • @AmiParikh9
    @AmiParikh9 4 роки тому

    This is just simply awesome. Thanks

  • @Matty.B
    @Matty.B Рік тому

    This was really helpful. Thank you!

  • @lightninginmyhands4878
    @lightninginmyhands4878 5 років тому

    I sincerely appreciate you recognizing the youtube majority as intellectually capable. I'm afraid many a modern university and public education system think otherwise.

  • @rremix9267
    @rremix9267 5 років тому

    Thanks man u made my day! I was stuck at this topic at my college and u made it easy for understanding. Please make more videos on data structures.

  • @tinkerbell3813
    @tinkerbell3813 2 роки тому

    Great job explaining, was def rlly helpful

  • @joydeepc8155
    @joydeepc8155 4 роки тому +1

    Really liked the video but I didn't get the equation for the linear time where T =an+b

  • @javiermejia5987
    @javiermejia5987 3 роки тому

    Very concise explanation