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

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 1.6K

  • @ahmadali-zz8om
    @ahmadali-zz8om 4 ปีที่แล้ว +2707

    After I finish my course I want to send this vid to my professor and tell him to explain it this way to make the student's life easier.

  • @guitarbansi1
    @guitarbansi1 4 ปีที่แล้ว +1417

    Humble message to all the teachers I ever had:
    This is how you teach.

    • @janibhai8215
      @janibhai8215 4 ปีที่แล้ว +2

      Dara to mention them @sunil shetty😅😂

    • @OzozGaming
      @OzozGaming 4 ปีที่แล้ว +3

      Yes exactly I hateeee my lecturer

    • @adamkaraki3389
      @adamkaraki3389 4 ปีที่แล้ว

      ifkr

    • @rhalfik
      @rhalfik 3 ปีที่แล้ว +3

      Teachers are obsolete.

    • @RammSkz
      @RammSkz 3 ปีที่แล้ว +4

      I'm pretty sure that spending 36 minutes to explain something pretty simple isn't the right way to teach, unless your students are ...

  • @Thunderbuck
    @Thunderbuck ปีที่แล้ว +130

    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 ปีที่แล้ว +19

      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!

  • @drewb9162
    @drewb9162 4 ปีที่แล้ว +401

    I sat in class for the whole semester struggling to figure this out. Then I see your video and understand it in 30 mins. College is a joke.

    • @moh11ful
      @moh11ful 4 ปีที่แล้ว +27

      That is the problem
      Teachers who teach us those things
      Got their computer science degrees from a long ages .
      They are old , so serous and boring

    • @V-for-Vendetta01
      @V-for-Vendetta01 3 ปีที่แล้ว +3

      @Muhammed Mishal facts

    • @GustavoCosta-jr1mh
      @GustavoCosta-jr1mh 3 ปีที่แล้ว

      You are so right!

    • @andrewzhang5345
      @andrewzhang5345 3 ปีที่แล้ว +20

      In college, you would rigorously define O notation, along with theta and omega. This video isn't rigorously defining it, which is why it's so much easier to understand.
      In high school, and intro calc class, limits are easy and intuitive to understand, but it's the rigor of the epsilon delta definition that causes so much confusion.
      I don't think it's fair to say that your professor is a worse teacher when the video isn't necessarily explaining the same content.

    • @hmm7458
      @hmm7458 3 ปีที่แล้ว +7

      @@andrewzhang5345 shhh...🤫 if ever complaining kids could read this they would be very angry

  • @spicytuna08
    @spicytuna08 6 ปีที่แล้ว +569

    I went to UC Irvine in Southern Cal. I had a professor (obviously PhD) who graduated from a big Ivy league who explained this. I could not understand. I couldn't F understand from the course book also. Now I understand. You are such a great teacher.

    • @saveUyghurs
      @saveUyghurs 6 ปีที่แล้ว +111

      The ability to teach is truly something only a few ppl who are actually good should be allowed to do. Otherwise, you end up thinking you're the dumb one when really delivery of the material was bad. So many dreams crushed this way

    • @rushilmehra
      @rushilmehra 5 ปีที่แล้ว +12

      Lol pattis

    • @imtiyazshaikh5331
      @imtiyazshaikh5331 5 ปีที่แล้ว +10

      @@saveUyghurs Completely agree. Teaching is not only a highly respected but also a high demanding profession.
      I think the way teachers are recruited should be totally revolutionized and teachers themselves should prepare and plan the lecture before delivering it.

    • @joelovalistien9275
      @joelovalistien9275 4 ปีที่แล้ว

      lmao shindler?

    • @Sun-yv9fr
      @Sun-yv9fr 4 ปีที่แล้ว +4

      Knowledge of effective teaching is what they needed in order to teach effectively rather than just having an Ivy league and Ph.D. background.

  • @cl0udbear
    @cl0udbear 5 ปีที่แล้ว +4152

    "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 ปีที่แล้ว +43

      Top 10 anime plot twists.

    • @melvinsoto
      @melvinsoto 5 ปีที่แล้ว +92

      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 ปีที่แล้ว +25

      @@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 ปีที่แล้ว +146

    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..☺

  • @maialso6096
    @maialso6096 ปีที่แล้ว +63

    0:20 sum function
    1:30 how much time does it take to run this function ?
    -> depends on the computer & programming language etc..
    some tools to answer the question : Big O notation & Time Complexity
    2:40 testing the function in python
    4:54 Time Complexity
    -> Linear time
    -> constant time
    -> quadratic time
    5:42 Big O notation
    -> Linear time, O(n)
    -> constant time, O(1)
    -> quadratic time , O(n^2)
    7:30 how to find big O from an expression
    -> find the fastest growing term
    -> take out the coefficient
    10:54 convenient features
    -> gives you a rough idea about how your function scales as input increases
    -> doesn't depend on your practical environment
    12:38 practice_1
    17:40 practice_2
    -> O(1)+O(1)=O(1)
    20:51 practice_3
    25:06 practice_4
    31:52 practice_5
    edit : Free Palestine !!🍉🍉

  • @CSDojo
    @CSDojo  6 ปีที่แล้ว +442

    Hey guys, sorry for the delay on this video.
    I traveled for a week, and I sort of fell out of my routine after that. But I’m back!
    Anyway, thanks a lot to everyone who messaged me or commented on my videos while I was away.
    As usual, please let me know if you have any video requests in a comment below :)

    • @vayabbavayabba9285
      @vayabbavayabba9285 6 ปีที่แล้ว +1

      CS Dojo you will start all new languages but you don't continue it
      And you will start again new language we are suffering

    • @CSDojo
      @CSDojo  6 ปีที่แล้ว +9

      Which languages?

    • @pavanprabhakar7358
      @pavanprabhakar7358 6 ปีที่แล้ว +23

      Bro pls make videos on competitive programming

    • @YugiohXLight
      @YugiohXLight 6 ปีที่แล้ว +1

      CS Dojo what is the complexity of the original sum function? In python i think you could do func = (lambda given_array: sum(given_array))

    • @chetanhegde1476
      @chetanhegde1476 6 ปีที่แล้ว +11

      CS Dojo Please make separate videos on big oh, big theta and big Omega.

  • @jonharvey
    @jonharvey 2 ปีที่แล้ว +48

    Thank you for the helpful video! Great examples for a beginner
    0:21 Intro w/ example function find_sum
    2:40 Testing actual runtime of example function in microseconds
    12:37 Another Example: stupid_function O(1) compared with O(n)
    17:03 Without Testing runtimes: BigO + TC for stupid_function and find_sum
    25:05 Another Example : O(n^2)
    34:04 Wrap up

  • @smallcreativecorner5930
    @smallcreativecorner5930 4 ปีที่แล้ว +80

    4 years of University couldn't explain what you just did in 40 mins.
    You truly have a gift!

  • @mikeallencopeland
    @mikeallencopeland 5 ปีที่แล้ว +62

    YK, just wanted to say how much I appreciate you for dedicating your valuable time and knowledge to the youtube community of developers. I am starting out fresh as a software developer and CS major this fall. Your videos are excellent learning tools are are helping me to grasp the discipline so thanks man!

  • @shrutisharma3146
    @shrutisharma3146 4 ปีที่แล้ว +9

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

  • @mastle313
    @mastle313 4 ปีที่แล้ว

    Read multiple books and watched several videos on this subject and i didn't understand anything until I stumbled upon this video.
    This guy is a legend.
    If anyone has a hardtime understanding the big O notation, they only need to watch this video!

  • @thundersmind
    @thundersmind 6 ปีที่แล้ว +97

    Hey Dojo. Keep up with the amazing videos. You're destined for greatness!!

  • @mor11lano93
    @mor11lano93 7 หลายเดือนก่อน

    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

  • @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.

  • @asadashoori5553
    @asadashoori5553 3 ปีที่แล้ว +2

    you simplified the concept in a way that we don't memorize anything but understand them.
    thank you so much for your clear explanation 🙏

  • @Codebake
    @Codebake 4 ปีที่แล้ว +7

    I learnt this concept from a course and I swear no lecturer explained it better than you did. Good work man😎

  • @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

  • @sahilgarg94
    @sahilgarg94 2 ปีที่แล้ว +4

    Finally, in my current life. I understood this concept. Can't thank you enough dojo.

  • @melusimkhize1607
    @melusimkhize1607 3 ปีที่แล้ว +2

    One of the best in the world, I found you on my first teaching python using Jupiter notebook. It was unfortunate in my school they were using wing as IDE. Two years later I found you again and I'm fortunate we use the same concept of Data Structure.

  • @RohanVetale
    @RohanVetale 5 ปีที่แล้ว +5

    14:41 if you're removing all the coefficients then the 1 will also be removed.Instead of that you may write the function as
    0.115 * x to the power 0 so that variable x remains according to the rule(anything to the power zero is 1).

    • @imtiyazshaikh5331
      @imtiyazshaikh5331 5 ปีที่แล้ว

      Well, you are stuck in an infinite loop there.

    • @RK-oe4vt
      @RK-oe4vt 4 ปีที่แล้ว

      th-cam.com/video/vrnzAj9jnoE/w-d-xo.html

    • @AstroTibs
      @AstroTibs 3 ปีที่แล้ว

      1 is not the coefficient. 0.115 is.

  • @sweetiepiedpiperr
    @sweetiepiedpiperr 7 หลายเดือนก่อน

    Amazing video. I've just started out in Python Programming having had no prior experience and I can confidently say I understand time complexity well enough thanks to this video. Thank you SO MUCH for taking the time to create this content! :)

  • @ZainKhan-ge6kc
    @ZainKhan-ge6kc 2 ปีที่แล้ว +4

    Amazing! my university professors were not able to explain this as well and clearly as you. I'm so happy that I finally understand this concept. Thank you for sharing and taking the time out

  • @zakirazakira6951
    @zakirazakira6951 3 ปีที่แล้ว +2

    Sir your way of teaching is fabulous. Any novice person will become expert from your way of teaching.Hats off to you for this endeavour and fantastic way of teaching. Lots of Thanks to you 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

  • @jasonfeliz4366
    @jasonfeliz4366 6 ปีที่แล้ว +1

    Best tutorial on Big O on this planet. Everything clicked with this video. Far superior than Hacker Rank

  • @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 ;)

  • @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

  • @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 /🇸🇪

    • @MinecraftJesusGaming
      @MinecraftJesusGaming 4 ปีที่แล้ว +3

      I stan this man

    • @SauceyRedHN
      @SauceyRedHN 4 ปีที่แล้ว

      Cruzer ikr 🇳🇴

  • @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.

  • @insharamin1147
    @insharamin1147 4 ปีที่แล้ว +10

    Hey Dojo. It's been a pleasure learning from u. Plz upload the complete explanation for Big O Notation (log, limits etc).

  • @mariale5262
    @mariale5262 4 ปีที่แล้ว

    You finally made Big O click for me in the first 11 minutes of your video over some of the other 1 hr lectures I tried listening to. THANK YOU SO MUCH

  • @Jozin2626
    @Jozin2626 4 ปีที่แล้ว +15

    I've been struggling with this concept in my data structures & algorithms course, the way you explained it helped 👍

  • @hasnainmalick8888
    @hasnainmalick8888 2 ปีที่แล้ว

    I tried so many channels and learned something but nobody taught us like you. Your content is too much deep. hats off men

  • @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.

  • @huckleberryfinn8795
    @huckleberryfinn8795 ปีที่แล้ว

    This is the best tutorial on Big O notation I have seen on TH-cam, thank you.

  • @ericgc01
    @ericgc01 5 ปีที่แล้ว +14

    The mathematical rigorous explanation of Big O Notation would be much appreciated, brother. Thank your for the videos. :D

  • @rezaghasemzadeh9440
    @rezaghasemzadeh9440 หลายเดือนก่อน

    That's the content I want, not shallow, short and cringe, but Deep, long and interesting, thank you for making this incredible video

  • @pizzacheeseman2854
    @pizzacheeseman2854 3 ปีที่แล้ว +5

    Having just learned to make a sorting algorithm and hash table in C I love when he said “I implemented it in Python” but the pseudo code he wrote is perfectly valid Python already

  • @jezzymichelleirarelevo971
    @jezzymichelleirarelevo971 4 ปีที่แล้ว

    I just knew this topic because I have to take an exam for a job application but he explained it very well! I didn't know I can watch, listen and learn from a youtube video this easy. Omg thank you!

  • @chriscampbell5901
    @chriscampbell5901 5 ปีที่แล้ว +131

    I'm sorry but the 151 people who disliked this video need Big O explained to them in crayon. This video is perfect.Thanks a million!

    • @mikehunt3688
      @mikehunt3688 4 ปีที่แล้ว +2

      >:( n IS A LETTER NOT A NUMBER HOW DO I MULTIPLY IT

    • @ifmondayhadaface9490
      @ifmondayhadaface9490 4 ปีที่แล้ว +2

      Imagine not being able to understand basic algebra and trying to learn computer science.

    • @ericcapiz6516
      @ericcapiz6516 3 ปีที่แล้ว +1

      i need it explained in crayon.. lolol

    • @ep1cshay337
      @ep1cshay337 3 ปีที่แล้ว

      @@ericcapiz6516 same. Pls explain in crayon 🖍 with pictures and colors 🥺

    • @AstroTibs
      @AstroTibs 3 ปีที่แล้ว +4

      A lot of arrogance on display here. No, this video is not "perfect."
      The instructor could have given examples of a 2D array that was not square.
      Ultimately, the final example is _either_ O(n²) or O(N) depending on if you're referencing your input size to being either n rows (in a square array) or N total elements. Both descriptions are valid, but you need to clarify. This is an important point that is not discussed.
      It would have been better to use an example such as: a function that takes each element in a 1D array and multiplies it against each every element, returning the sum of all i×j. That would have resulted in a O(n²) complexity with a 1D input. Everyone would agree on this without ambiguity.
      It also would have been nice if the video had shown examples of O(n×log[n]).

  • @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.

  • @technogrinder
    @technogrinder 5 ปีที่แล้ว +3

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

  • @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.

  • @YugiohXLight
    @YugiohXLight 6 ปีที่แล้ว +79

    In the first function in 'pseudocode' if you remove each it will be a good python code:)

    • @CSDojo
      @CSDojo  6 ปีที่แล้ว +19

      Haha yes, I noticed it, too :)

    • @vikrantsingh47
      @vikrantsingh47 5 ปีที่แล้ว +20

      Python IS pseudocode

    • @azizalaliq8
      @azizalaliq8 5 ปีที่แล้ว +12

      @@vikrantsingh47 thats why its amazing

    • @trevandrea8909
      @trevandrea8909 8 หลายเดือนก่อน

      ​@@azizalaliq8 I loveee Python 😍

  • @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

  • @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!!!

  • @gusiwanaga7380
    @gusiwanaga7380 4 ปีที่แล้ว

    This is by far the best explanation of Big(O) and Time Complexity.

  • @fiNitEarth
    @fiNitEarth 6 ปีที่แล้ว +119

    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 ปีที่แล้ว +20

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

    • @tunebrotherdon
      @tunebrotherdon 6 ปีที่แล้ว

      ++++++

    • @NguyenTrang-je6zg
      @NguyenTrang-je6zg 6 ปีที่แล้ว +1

      I would love so too

    • @eiderdiaz7219
      @eiderdiaz7219 5 ปีที่แล้ว

      same here

  • @edmoods
    @edmoods 3 ปีที่แล้ว

    Finally someone who knows what he's talking about and knows how to explain! Thanks very much! Reminds me of organic chemistry tutor, also an excellent teacher

  • @alfredoromero1346
    @alfredoromero1346 2 ปีที่แล้ว +6

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

  • @colton-cu5kf
    @colton-cu5kf 6 ปีที่แล้ว

    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!

  • @Ali-mi9up
    @Ali-mi9up 6 ปีที่แล้ว +4

    The box approach is kinda cool, really helps not throw all the stuff at you in one go

  • @edgarjeparchin2382
    @edgarjeparchin2382 3 ปีที่แล้ว

    dude I've spent hours watching university material and nothing made sense till I saw this video. Thanks and keep goog work.

  • @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 4 ปีที่แล้ว

    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.

  • @TheDracnah
    @TheDracnah 4 ปีที่แล้ว +8

    Shouldn't the "for each i in given_array:" be 0(n) at 22:28 ?

    • @oliviervanlier4947
      @oliviervanlier4947 3 ปีที่แล้ว

      Depends on how you look at it, if you look at the for loop as a compound statement that repeats everything inside n times , you could say it is O(n). Or you could like at the statements inside the for loop and determine their big O notation. Since you repeat those statements n times, you get the big O of the for loop as n times the big O of what’s inside the for loop. So it’s the same thing, the perspective is just a little different. :)

    • @holymacaroni3319
      @holymacaroni3319 3 ปีที่แล้ว +1

      @@oliviervanlier4947 I get what he is saying in the video but isn't it wrong to write n x O(1)? Because mathematically speaking n x O(1) could be written as O(1) + O(1) + O(1) .. n times + O(1) and as we know O(1) + O(1) is still O(1). I just want to make sure I understand, not throwing any hands. :))

  • @isajal07
    @isajal07 4 ปีที่แล้ว +2

    Finished my CS degree 3 years ago and Finally, I clearly understood the Big-Oh. Thanks

    • @uchihasasuke7436
      @uchihasasuke7436 3 ปีที่แล้ว

      @Ganesh E most textbooks call it Big-Oh

  • @blackheart6897
    @blackheart6897 6 ปีที่แล้ว +22

    I am fond of the way of your teaching.

  • @FORGIVE123N
    @FORGIVE123N 4 ปีที่แล้ว

    By far the most comprehensive explanation of time complexity and big O notation I've ever met, so simple and clear. Thank you!

  • @raveeshmalhotra7347
    @raveeshmalhotra7347 4 ปีที่แล้ว +5

    hello brother,
    in the video, you mentioned that the second function's(the one with for loop calculating sum near 22:35) time complexity as n(O(1)), and T2= O(1)+ n(O(1))+ O(1)...but there is a CONDITION in the FOR loop to check the ENTRY of program control(until i is less than number of items in array), why you didn't consider the TIME TAKEN in evaluating that condition??? can you please explain that??

    • @bwzffgh7
      @bwzffgh7 2 ปีที่แล้ว

      Because he was trying to keep this as simple as possible. Explaining loop terminating conditions isn't necessary to understand how this time complexity notation works.
      He also excluded the time difference between passing the array as a value versus a reference. When estimating scalable performance times, that could be a bigger factor than the loop itself.

  • @krishnavamsirangu1727
    @krishnavamsirangu1727 3 ปีที่แล้ว

    The one I have ever seen teaching in this way better than best.
    Thank you.

  • @wackmachine
    @wackmachine 6 ปีที่แล้ว +7

    The array_2d example solution is incorrect. The input data size is N=Row*Row, since it's generated outside of the function and irrelevant to the function's own complexity. The actual complexity would be O(N) because the function itself is going through each element of the input only once.
    It's easier to understand if you consider that the same function can be implemented with accepting a one dimensional array (with the same number of elements as the example). Thus the actual function complexity would be O(N).

    • @adfke8ncx
      @adfke8ncx 6 ปีที่แล้ว

      You are rigth.

    • @qiannathancao
      @qiannathancao 6 ปีที่แล้ว

      If 2d_Array.shape is (n , n), then he: O(n^2) is correct, you are wrong.
      If 2d_Array.size = n, then you: O(n) are correct, he is wrong.

    • @philliey
      @philliey 6 ปีที่แล้ว

      yeah I'm pretty sure he was basing it on the 2d array on the left where it was size n by n.
      He put the other n by m there to explain rows and columns.

    • @Cutiepie-ky9oh
      @Cutiepie-ky9oh 5 ปีที่แล้ว

      Do you happen to know why the formula for stupid_function, is T^2? I understand that its runtime is O(N), but do not know why Time was written as T^2.

    • @0x1EGEN
      @0x1EGEN 5 ปีที่แล้ว

      Actually it's better to say O(n*m), because N is the time it takes to traverse the first array and M is the time it takes to traverse the nested array. But yes theoretically O(N) is also correct.

  • @ParsclickTV
    @ParsclickTV 4 ปีที่แล้ว +1

    The best video about Big O notation.
    Love from 🇮🇷

  • @fairozahmed6888
    @fairozahmed6888 6 ปีที่แล้ว +23

    Hey CS Dojo Really love your teaching and content ...I hope you make a lot of videos on Data Structures ..I have watched your other videos ...Awesome Work ..God bless you :)

    • @naveedakhtar7172
      @naveedakhtar7172 6 ปีที่แล้ว +2

      Fairoz Ahmed yes plz data structure n algorithm analysis... more videos on BIG O plz discuss its each n every aspect

  • @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! :)

  • @cristinalee7276
    @cristinalee7276 6 ปีที่แล้ว +5

    You're a fantastic teacher! Thanks for explaining it so clearly.

  • @abvdgr8886
    @abvdgr8886 4 ปีที่แล้ว +1

    I remember when I was taking CS Applications I was so confused when watching this video, but now that I am watching it I can’t believe I couldn’t understand it the first time. It’s explained so well!

  • @kasiviswanath9019
    @kasiviswanath9019 5 ปีที่แล้ว +22

    please make video on O(logn) and O(nlogn)
    Thank u so much for your nice explanation

    • @awosikaolawoyin5837
      @awosikaolawoyin5837 4 ปีที่แล้ว +1

      Please were you able to find a series that explained the O(logn) and O(nlogn) properly?? if yes can you please share as i could not find the series that covers this on YK's channel. Thank You

  • @BurningMarmite
    @BurningMarmite 6 ปีที่แล้ว +9

    pls make a video about formal mathematical definition of Big O!! I need it very much, so do the rest of us. Very nice video btw, keep up the good work!!!! Love you dawg, see you in heaven ;)

  • @BlackBlingGirl
    @BlackBlingGirl 4 ปีที่แล้ว +1

    Thank you so much! This was so easy and straight forward. No book has ever explained it to me in a way that i got it right away! Thank you and keep up the good work!

  • @shree2710
    @shree2710 6 ปีที่แล้ว +14

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

  • @tunjiadewoye448
    @tunjiadewoye448 2 ปีที่แล้ว +1

    Great stuff as usual! Going to make sure to watch all the vids on this Data Structures & Algorithms Series

  • @mauarrogs2360
    @mauarrogs2360 5 ปีที่แล้ว +7

    THANK YOU FOR THIS VIDEO CANT UNDERSTAND MY PROFESSOR BUT BRO YOU NAILED IT!

  • @gisellemartinez-sanchez2071
    @gisellemartinez-sanchez2071 3 ปีที่แล้ว

    These explanations are priceless! This video is highly UNDERrated.

  • @Yetipfote
    @Yetipfote 5 ปีที่แล้ว +293

    "I use pseudocode for demonstration."
    > shows python
    😎

    • @wenwen1111
      @wenwen1111 5 ปีที่แล้ว +4

      HAHAHAH my thoughts exactly, but then that could be his level of pseudo-code.

    • @youtubeaccount0x073
      @youtubeaccount0x073 5 ปีที่แล้ว +2

      Volvox I KNOW ROGHTTTT

    • @praveenawesome2182
      @praveenawesome2182 5 ปีที่แล้ว +1

      Python :am i joke to u ?

    • @ViAikBreeck
      @ViAikBreeck 5 ปีที่แล้ว +11

      "for each" is not Python. :)

  • @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.

  • @NaimaZakaria
    @NaimaZakaria 5 ปีที่แล้ว +3

    yes, please make formal definition video. Thank you for posting.

  • @Natena
    @Natena ปีที่แล้ว +1

    Unbelievable how simple the explanation is. Thank u

  • @dennisramos9270
    @dennisramos9270 4 ปีที่แล้ว +5

    Thanks for the great videos! I'm currently using several of them in the classes I teach. The example below is from Blue Pelican Java Lesson 38 by Charles Cook. Your last example with the 2D Array and the example below look like the same idea. However, Cook explains that the Big O value is O(n) because you are essentially adding each element of the 2D array once, that is O(r*c) where r is the number of rows, and c is the number of columns. Could you explain what the difference is?
    public static int[] addStuff(int x[ ][ ])
    {
    int row, col;
    int b[] = new int[x.length];
    for(row =0; row < x.length; row++)
    {
    for(col= 0; col < x[row].length; col++)
    {
    b[row] += x[row][col];
    }
    }
    return b;
    }
    Yes, this one is a bit more complicated than the previous ones. Let’s assume we call
    this method with the following code:
    int dfg[][] = { {1,2,...},
    {0,4,...},
    ... };
    //Assume this array has r rows and c columns for a
    int newArray[] = addStuff(dfg);
    //total of rc = n elements
    Studying the addStuff method, we note that we go through the outer loop x.length
    times which is the number of rows, r. For the inner loop we go through x[row].length
    which is the number of columns, c. Therefore, the total number of times through the
    code in the inner loop is rc, which in turn is just the number of elements in the entire
    matrix, n. We can write the Big O value as either O(rc) or O(n).

    • @ZBlinkZ
      @ZBlinkZ ปีที่แล้ว

      From my understanding I think it's because in his example we always have n squared number of elements(number of rows = number of columns), that's why the time complexity is increased. In your example the number of rows and columns are two different variables O(rc) hence O(n). They seem 2 different cases to me that I could easily mix up, if you didn't point this 😀

  • @adamkalimi3542
    @adamkalimi3542 4 ปีที่แล้ว +1

    Thanks for putting this together. I enjoyed your method of blocking out the equations, and revealing them later. It's very clean. Keep up the good work!

  • @subramanianchenniappan4059
    @subramanianchenniappan4059 6 ปีที่แล้ว +8

    Please put formal mathematical definition video for O(n)

  • @bootae9246
    @bootae9246 4 ปีที่แล้ว +2

    Thank you for this video! You did what my professors couldn’t! You’re really good at explaining in a simple way but getting all the information across anyway! I’ve tried for a week to understand this and your video really helped!

  • @lemonwithswag2593
    @lemonwithswag2593 6 ปีที่แล้ว +5

    Hi, awesome video as always.

  • @cretik_shmurda
    @cretik_shmurda 2 ปีที่แล้ว

    So far the best video on Alg Complexity

  • @dhairya9990
    @dhairya9990 6 ปีที่แล้ว +7

    Please make a video talking about "how maths important for programming"

    • @FsimulatorX
      @FsimulatorX 6 ปีที่แล้ว

      You need to know addition at the very MINIMUM!

  • @viveksuman9600
    @viveksuman9600 4 ปีที่แล้ว

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

  • @bilalismail5175
    @bilalismail5175 4 ปีที่แล้ว +4

    Where the hell was this guy when I was doing my CS Degree !!!!!!!

  • @shankar7435
    @shankar7435 2 ปีที่แล้ว

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

  • @timofeytsvirko2699
    @timofeytsvirko2699 5 ปีที่แล้ว +3

    17:41 - how to find time complexity

  • @brioche8378
    @brioche8378 4 ปีที่แล้ว +1

    I’m studying at the University of Lincoln (UK) and you explained this way better than my professor in half the time.

  • @zombieslayamr
    @zombieslayamr 5 ปีที่แล้ว +20

    "I'm gonna use pseudocode to explain this..."
    ...
    ...
    ...
    NAH... *uses Python*

  • @boboz5502
    @boboz5502 2 ปีที่แล้ว

    This is a great course! Clear, detailed, and understandable. Much better than all my professors at the University, especially my supervisor...

  • @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

  • @biruwolde1160
    @biruwolde1160 6 ปีที่แล้ว

    This world is beautiful because of peoples like you!! Keep doing the good work!!

  • @puckpuck18
    @puckpuck18 4 ปีที่แล้ว

    Thanks dojo, i saw like 7 tutorial on youtube before I saw yours, and this was the best tutorial I stumbled on to.. loved the explanation

  • @dano.819
    @dano.819 7 หลายเดือนก่อน

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

  • @ahmadabeeb6151
    @ahmadabeeb6151 2 ปีที่แล้ว

    Thank you a million times over. Excellent teaching.