Time complexity analysis - some general rules

Поділитися
Вставка
  • Опубліковано 2 жов 2024

КОМЕНТАРІ • 262

  • @GlassesAndCoffeeMugs
    @GlassesAndCoffeeMugs 3 роки тому +117

    6 years later and this is still the most clear and concise explanation I've seen

  • @saxenaakash19
    @saxenaakash19 6 років тому +87

    A) Drop lower order terms
    B) Drop the multiplier
    C) Total running time is sum of fragments. For large input sizes the the run time depends upon the fragment with highest run time
    D) If there are two cases possible the time complexity depends upon the worst case scenario (the one with largest time complexity)

  • @skytaer
    @skytaer 10 років тому +257

    this is gold

  • @UriYakir
    @UriYakir 10 років тому +47

    Thank you so much!!! I barely understood the topic and your video made it all clear for me! If I could, I would have given you a thousand likes! :)

    • @mycodeschool
      @mycodeschool  10 років тому +4

      Thanks Uri Yakir

    • @AbhimanyuAryan
      @AbhimanyuAryan 10 років тому +1

      1 dislike lets find that bastard :(

    • @pond.filler-4503
      @pond.filler-4503 8 років тому

      +BomBamBum for the first question, the runtime should be log n. for the second question, the runtime should be n log n

    • @cyberpunk7702
      @cyberpunk7702 8 років тому +1

      +Pond. Filler- may I ask how did you get log(n) for the first question?

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

      so what's up with life now champ, what did you do ?

  • @RafaelCamposNunes
    @RafaelCamposNunes 10 років тому +31

    You should explain the Theta and the Omega general rules as well, it would be awesome, finally I understand how to calculate Time Complexity with your videos. :D

  • @mycodeschool
    @mycodeschool  11 років тому +7

    Sure Tudor, we will try to get more. :)

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

    I am in grad school for software engineering and love to program. I've seen a lot of channels, many good ones, but yours is one of the absolute best. I come back to your videos to refresh and learn, pick up stuff that went over my head the first time around.

  • @sahildhawan22
    @sahildhawan22 9 років тому +24

    Awesome! Where are the follow-up videos?

  • @mycodeschool
    @mycodeschool  11 років тому +4

    Sure ! stay tuned :)

  • @ShubhamSingh-de8es
    @ShubhamSingh-de8es 3 роки тому +2

    Most Clear and Concise Explanation.

  • @suprakashmukherjee007
    @suprakashmukherjee007 7 років тому +2

    hi, at the end of this video you mentioned about the next video in the series "calculating time complexity of recursive programs". I cant find it. If you have uploaded more videos in the series please provide links to the complete series.

  • @tanusreekar2839
    @tanusreekar2839 2 роки тому +1

    Sad to hear about your friend's story Animesh, Stay Strong!

  • @sonianarendramodi2605
    @sonianarendramodi2605 3 роки тому +1

    loop runs n+1 times and statement inside it runs n times , right?

  • @sagarmehta3515
    @sagarmehta3515 7 років тому +1

    Hello, in the tutorial we see O(n), O(n^2),O(n^3) time complexities. But when would you associate logarithmic functions to time complexities. When and how would u calculate that time complexity of a particular code is O(logn) or O(nlogn) ?

  • @yhevrah
    @yhevrah 10 років тому +1

    Hi, Thank you for such informative video. But can you give examples of codes that would at O(lg N), loops would be a certain indication of O(N), or O(N^2) but how about the others? For example, what is the running time of the prime function on your first video? and why? thanks.

  • @TheOverAndAround
    @TheOverAndAround 10 років тому +1

    this is so helpful, the whole big o thing clicked to me by watching this video. Was still a little confused watching the first few videos in areas but this video made 100% sense to me.
    especially when you demonstrated just to focus on the areas that have the biggest impact to overall time and the outer and inner loop example was great for me, saying n loop x n loop = n^2 clicked inside my head.
    thanks again, best big o vid on youtube and ive watched heaps of them.
    please make some more vids on some recursive examples if you could

  • @abuenavi
    @abuenavi 9 років тому +2

    Your explanations are some of the best CS videos I have found anywhere, including videos from universities! Your channel has a lot of videos, some idea of which playlists and videos to start with and what to watch next would be great. Great job!

  • @wolverinelogan9851
    @wolverinelogan9851 10 років тому +4

    Best explanation of time complexity analysis. Thanks a lot for the video.

  • @vishaldeepak2538
    @vishaldeepak2538 10 років тому +1

    gr8 tutorial guys, can you redirect me to any other of your videos where the running time of actual program is calculated, It will be great if there are examples and questions , thankx

  • @mistersir3185
    @mistersir3185 2 роки тому +1

    seeing comments from 4, 5, 6 , 7 years ago is so eerie it gives me chills...

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

    This tutorial video was so well explained. Suddenly entire concept is looking so simple!

  • @sureshdharavath1191
    @sureshdharavath1191 10 років тому +2

    nice tutorial but where are next comming tutorials on timecomplexity ?

  • @AniketKapse
    @AniketKapse 8 років тому +1

    +mycodeschool What about the complexity O(logn) and O(nlogn) wrt the code? Can someone please tell me?

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

    Please start making videos. I can't imagine how easier and clear it would be for CS students if you cover all these DSA and programming topics. Because these are the topics everyone has a hard time with. But sadly, uppar wala doesn't want this to happen; god took your mate and you are alone in the project. GOSH. Just imagine this channel had all playlists for DSA subjects. The world would be much better with everyone being a good programmer discarding these existing shitty so-called professors.

  • @science_is_awesome7070
    @science_is_awesome7070 10 років тому +5

    Excellent lecture on time complexity, thanks for posting!

  • @laylab5195
    @laylab5195 7 років тому +1

    you are my savior!!! I couldn't have passed any of my classes without you.
    please tell me you continued this series somewhere ???

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

    "In next of couple of lessons we will see different time complexity functions and their comparison and we will also see how to analyse the time complexity of recursive functions". Been a decade and I guess "the next couple of lessons" are slow at uploading on UA-cam!

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

    Bhai!!!! Yaar really good explanation for the first time i get clear about time complexity. Such a simple and good explanation!!

  • @Utteeya
    @Utteeya 6 років тому

    Take a bow. Amazing explanation. I find myself lucky that I have found this video in my search results.

  • @sushmitanigam5787
    @sushmitanigam5787 10 років тому +1

    sir you are my god..awesome teaching..plzz do more on algorithms plzz sir so that we can get help in our gate

  • @AnandKumar-yi9yk
    @AnandKumar-yi9yk 3 роки тому

    2:49
    I think here time complexity is O(log n).
    Correct me if I am wrong.
    Great Work Appreciated.

  • @mayanknegi3373
    @mayanknegi3373 6 років тому

    for(i=n;i>0;i--){
    for(j=0;j

  • @KanagaveluSugumar
    @KanagaveluSugumar 9 років тому +1

    Wow what a great start on algorithams :) , you have explained very well and made a great foundations. Thank you so much!!!!

  • @usama57926
    @usama57926 6 років тому +2

    please make video on implementation of calculating time in c++

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

    for 16n +logn its O(n).Then what is the time complexity of 16n +n logn ..?

  • @WebHackmd
    @WebHackmd 8 років тому +6

    Where are the other videos on recursion time complexity ?

    • @ekhliousful
      @ekhliousful 7 років тому +1

      he died

    • @AmrendraKumar-ko8yf
      @AmrendraKumar-ko8yf 7 років тому +2

      how did u know? he is not died .. a frnd of his is died in accident..check fb post of codeschool

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

      The creator died in a car accident.

  • @SibanandaKheti
    @SibanandaKheti 8 років тому +1

    I had been looking all the wrong places, awesome

  • @selviravi8825
    @selviravi8825 7 років тому +1

    Hi... Thank fr the awesome explanation.. One small doubt is.. In ur previous video the time taken to exit a for loop is n+1..one extra loop fr the false condition.. But here u go with n times on for loop??

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

    It is a really good teaching video, well explained, thanks you so much!

  • @mycodeschool
    @mycodeschool  11 років тому +1

    Thanks for your kind words Anthony :)

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

    actually the for loop will be executed n+1 times because the loop will check the false case also , so the equation will change please correct it

  • @inderjit8258
    @inderjit8258 8 років тому

    now doesnt need to take the class from that bullshit teachers who even dnt have knowledge about there subject.. because u are here .. thanks u very much

  • @ravintolatajmahal
    @ravintolatajmahal 7 років тому +2

    i wanna give u big thanks since, u present the time complexity in a easiest way ever seen. keep it up

  • @barunkoirala2821
    @barunkoirala2821 6 років тому

    What if we have two nested loops and we have the equation like O(n^2) + O(n^2) , both have the same order, what will be the time complexity ?

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

    my god why did i find this guy so late. this man is amazing

  • @Akvarma1992
    @Akvarma1992 9 років тому +2

    for(i=0;i

    • @ramborambo4383
      @ramborambo4383 9 років тому

      +Aakash Varma it would be 0(n^2)

    • @shivamkashyap8656
      @shivamkashyap8656 8 років тому +1

      +Aakash Varma nlogn

    • @ramborambo4383
      @ramborambo4383 8 років тому

      Shivam Kashyap How?

    • @pond.filler-4503
      @pond.filler-4503 8 років тому +2

      +Rambo Rambo
      it is nlogn. The nested loop only increments j upto log(n) then the loop exits, so the combined run time is n*log(n) = nlogn

    • @IvanIvanov-qx5oz
      @IvanIvanov-qx5oz 6 років тому

      the outer loop runs n times.
      each time we run the outer loop, we run the inner loop since j is always set to 0 and it increments by 1 until it reaches logn (so it runs logn times)
      so we do the whole thing is (times you run outer loop) * (times you run inner loop) = n * logn

  • @thomashodges841
    @thomashodges841 7 років тому +1

    Thank you for these videos! The book I was studying started talking about O() time, which I generally understood, but then it started in on T() time and using them in equations together also and I couldn't work out what made the two different and how they fit together. These videos gave me a clear perspective with which to finish my chapter.

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

    What if there is no else part in the time complexity problem? What will be the worst-case scenario then?

  • @ishanpatel6583
    @ishanpatel6583 9 років тому

    At 4:38, O(n+1) might come as loop would even check/compare i=n and then return false.... but it would use time in comparing! If n tends to infinity than we can neglect constant and keep it as O(n)

  • @Sparshchokra
    @Sparshchokra 8 років тому

    Hello sir.. u did lots of efforts to make us understand the above Complexity topic, but to make a perfectionist over this topic would you please upload some more videos over this topic by which we will get over all concept of complexity like log(n),log k(n),log b(n) etc related to this ..thank you so much anyways :-)

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

    Finally! A video where I got the understanding of time complexity. Thankyou so much for this incredible explanation! Subscribed to your channel after watching this 1st video itself! Thankyou!!

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

    So on the last part, supposing the condition was "if n

  • @mycodeschool
    @mycodeschool  11 років тому

    Thanks a lot Stavros. We will try to get more in this series.

  • @unev
    @unev 8 років тому

    What would be θ of the last example. Is it
    c'g( n^2 )

  • @mycodeschool
    @mycodeschool  11 років тому

    Thanks Madhu.

  • @shikharsharma6399
    @shikharsharma6399 7 років тому

    So appropriate!!!
    It is so hard to find a correct explanation. There is no certainty of material available on the internet.
    This series seems correct so far!
    VVVVVEEErrrryyyy Good!!!!

  • @vivekshukla5385
    @vivekshukla5385 9 років тому

    really sir all these classes were crystal clear 2 me, although i have joined a separate course for this i barely understood this topic, thank u very much ..but what about the further topics ..... please post them ASAP... looking forward to them

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

    Hi Sir. First Thanks for making things crystal clear. I have a question, at last, we discussed the if and else and we took the worst case which is true for O. Instead of going to big O can we have solved that using theta that gives the tight bound ??

  • @Alexf14
    @Alexf14 9 років тому

    On the last algorithm if the case is different the complexity is going to be O(n)..
    So can we say that the whole algorithm has Ω(n) complexity?

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

    But As you said that big-oh represents the set,then how can they be added?there should be a union between them.And then in set terms,there is nothing like lower order terms,so they can't be ignored.

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

    The only and only explanation that helped me understand this analysis. Really thankful for the effort you put into making these videos.

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

    You guys aer really awesome. Please continue to make. Love 😍

  • @kashback7448
    @kashback7448 8 років тому +1

    Very Clear Explanation... Thanku so Much....

  • @vidi_shaa_
    @vidi_shaa_ 7 років тому

    you dont know but actually you are doing a great service to the student community...lucky to come across your videos...

  • @mrAmal45
    @mrAmal45 8 років тому

    Now im dare bung class. mycodeschool is here to tech me.

  • @yashmaheshwari517
    @yashmaheshwari517 7 років тому +1

    Very good, informative and excellent work. Keep going

  • @vivekpunnad1096
    @vivekpunnad1096 3 роки тому +1

    bestest ever

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

    What is the complexity If the function I derived is O(m^2) + O(n^3) ?

  • @quickfunz5958
    @quickfunz5958 6 років тому

    koi plz bta skta ha k ak statement may jo big power hoti ha wou leani hotI ha koa???
    plz tello quickly
    my quiz is tomorrow

  • @EchoesOfEnglish
    @EchoesOfEnglish 8 років тому +1

    I think first loop execute n+1 time and the statement of this loop execute n times........... If i am right please correction it

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

      loop 0 to n-1.then it goes n,and exits because conditions dont match.total n times

  • @7x34hj
    @7x34hj 6 років тому

    What about time complexity of mathematical functions. In particular, matrix multiplication. Say, vP where v is a (1 x n ) vector and P is an (n x n) permutation matrix.

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

    Great explaination after 9 years it is also clear to understood

  • @ponyosays9861
    @ponyosays9861 6 років тому +1

    U r a grt teaher!!!

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

      he was a great teacher , he's no more now! may god bless his soul

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

    Thats how its done for any practical purposes.

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

    He is one in a million, best among many, most trusted , I almost gave up on trading then I met him through a friend, Austin is the most trusted trading expert who helped the life of my family and I ,.

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

      -+/1/5/3/0/4/2/8/5/8/70/W/h/a/t/s/A/p/p/< With> /
      A/U/s/t/In/.

  • @shahidshaikh4776
    @shahidshaikh4776 7 років тому

    Thanks a lot Bro .... Really Appreciate your Efforts and very well explained.

  • @MadhuKalluri-t2u
    @MadhuKalluri-t2u 7 років тому +2

    best video ever on time complexity

  • @thohoang9383
    @thohoang9383 10 років тому

    I suddenly wonder that if s

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

    Same things have taught in geeksforgeeks video...

  • @Physicsope875
    @Physicsope875 16 днів тому

    Thank you so much for such amazing content!

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

    Wow your explanation is very clear. our lecture spend hours to explain this

  • @supribinhjamir859
    @supribinhjamir859 7 років тому

    why dont you explain that for looping execute n+1 times? not n times

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

    You're among those few who provide playlist link in the description !

  • @anupriya1661
    @anupriya1661 6 років тому

    in case someones wondering why he isnt uploading anymore...welp hes dead :(

  • @mycodeschool
    @mycodeschool  11 років тому

    Thanks a lot Josey !

  • @BlitZnGodzilla117
    @BlitZnGodzilla117 7 років тому +1

    Thank you this cleared up a lot!

  • @NYCcrushinCali
    @NYCcrushinCali 6 років тому

    This was exactly what I needed to hear. This should be taught prior to backward substitution.

  • @nahomnegash5410
    @nahomnegash5410 10 років тому +1

    This was very helpful. Thank you!

  • @guurenez
    @guurenez 8 років тому

    thanks for good video series on time complexity, you said next video, means it will coming into this playlist?

  • @Rohitbhole1
    @Rohitbhole1 7 років тому

    Pjysics Maths Ds everything is based on approximation

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

    It was very helpful thanks a lot to u....

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

    Are you a university professor? If not, you should seriously consider it. You've managed to teach how to calculate time complexity better than any of my professors.

    • @trueresources3847
      @trueresources3847 2 роки тому +2

      well he's harsha s. a top coder in the country of the time. yes the country. we'll always remember him. RIP Harsha Suryanarayana. you may have gone but your work will live on. long live humblefool

    • @walimorris2406
      @walimorris2406 2 роки тому +1

      @@trueresources3847 Thanks for sharing. I just read the story, that's really sad.

  • @007_justgoogleit
    @007_justgoogleit 2 роки тому

    please provide content in python language

  • @Gigi.Gaber91
    @Gigi.Gaber91 9 років тому

    sir in the pseudo code the for loop always starts with i=1
    and since it's (for i=1 , i

    • @rubayetrahmanrongon3526
      @rubayetrahmanrongon3526 9 років тому

      Gehad Gaber in this case yes the overall loop will be executed 1+n+n = 2n+1 times.i,e i=1 this will be executed 1 time, i

    • @aamirkhalifa1902
      @aamirkhalifa1902 9 років тому

      Gehad Gaber You are correct about the number of comparisons. However, even if it was only n-1 comparisons, or even 2n comparisons, they both would be classified as O(n) complexity.

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

    I know this is old but you’re the best!

  • @tanveerakbar7459
    @tanveerakbar7459 7 років тому

    i wish you were my roomate

  • @dipannytanandi8864
    @dipannytanandi8864 8 років тому

    crystal clear !! thanks !! but no follow up videos :/

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

    Sir please clarify that when we are computing the running time of the simple for loop,do we not need to consider the time taken for every comparison and increment by for loop,for n+1 times,including the one time the condition becomes false and loop is exited,as was told in the previous video of model machine??here we are only considering the running time of the simple statements,why so?

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

      Comparison is also a simple statement . So all simple statements add up giving some const times n. So the overall time complexity is O(n)

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

    We need a continuation of the series, please

  • @kasmanialisaad
    @kasmanialisaad 9 років тому +2

    Thanks. Very very helpful.