Комментарии •

  • @takeUforward
    @takeUforward 2 года назад +78

    Let's continue the habit of commenting “understood” if you got the entire video. Please give it a like too, you don't 😞
    Do follow me on Instagram: striver_79

    • @unknown-cj8gv
      @unknown-cj8gv 2 года назад +1

      Dil me baste ho tum yr ♥️ humare

    • @raysdev
      @raysdev 2 года назад

      Understood! Wow, your mathematical deductive reasoning was very sound & easily followed!
      I appreciate the step by step analysis w/o skipping over any steps. 🙌

    • @rushikeshpol5844
      @rushikeshpol5844 2 года назад

      can you solve skiplist problem on leetcode

    • @deviprasad_bal
      @deviprasad_bal Год назад

      At any time, a heap can't have same vertex twice, then the heapsize must be log(V) instead of log(V^2). therefore, the maximum heap size can be equal to the number of vertices in the graph, V, and not V^2. Please correct me if I am wrong.

    • @priyanshkumar17
      @priyanshkumar17 4 месяца назад

      understood!!

  • @JayPatel-sn7it
    @JayPatel-sn7it Год назад +31

    Bro ne pura phd kar diya Time Complexity pe 😂.
    Thanks bhai for such a nice explanation.

  • @ishanshah3309
    @ishanshah3309 Год назад +91

    this TC explanation is brilliant. have never seen such an amazing video of calculating Time complexity. This Graph series I've seen so far is definitely the best (I bet even any paid course wont be able to beat it ) and is on another level.

  • @yatendraupadhyay2180
    @yatendraupadhyay2180 2 месяца назад +14

    Bhaiya you deserve Bharat Ratna for this quality content.

  • @darkstudio3170
    @darkstudio3170 10 месяцев назад +12

    Guys many of you having doubt that heap size is worst case V2 then while loop should also run V2 times. First of all, the assumption taken that Max Heap Size will be in worst case V2 is itself is wrong . Adding V2 node in any case is not possible. You can dry run , you will find that the distance condition wont allow V2 node to the queue in any case possible + the every node we will processed (pQ.poll()) wont be added to the queue again (you can marked those node vis also , wont have any effect on ans), In worst case heap size can go nV where nELogV. Period

    • @janedoe1721
      @janedoe1721 7 месяцев назад +2

      I agree, the only difference I think is that a node at max will have V-1 edges, not E. so, V(logV + (V-1).logV) = V^2.logV=ElogV. Let me know if this makes sense

    • @vaisakh5802
      @vaisakh5802 4 месяца назад

      @@janedoe1721 im not able to understand how v2=E. can you explain?

    • @jotsinghbindra8317
      @jotsinghbindra8317 3 месяца назад

      @@vaisakh5802 in densest graph there will be V nodes and each of them connected to V-1 nodes => total edges=v*v-1

    • @ps123abc6
      @ps123abc6 5 дней назад

      @@vaisakh5802 IT Would be v2 = 2*Edges= (aprrox=E)

  • @abdulqadirboxwala5414
    @abdulqadirboxwala5414 Год назад +3

    this is a type of content that I would not give a second thought for even paying for it

  • @CodeMode9313
    @CodeMode9313 Год назад +4

    habibi tum time complexity mast samjai ho ....hum khush hui ..tum accha kaam karti

  • @codinghustler6771
    @codinghustler6771 2 года назад +35

    I Understood this by your previous graph series. But from this it just make everything clear. Thank you Raj bhaiya for all of your effort.

  • @adityan5302
    @adityan5302 4 месяца назад +3

    I suspect that you're the creator of these Data Structures bro.... Just simply amazing... Love u bro. I succeded in one of the interviews because of u. This is because of you♥

  • @RahulKumar-qy7pz
    @RahulKumar-qy7pz Месяц назад

    in T.C , at starting it's looking impossible that it reaches to Elog(V) to me , but as video ends , it clears my mind thanx striver😘

  • @sunny_23561
    @sunny_23561 10 месяцев назад +2

    This video just blew my mind.... Huge thanks Raj bhaiya... Now I am really willing to spend next 2-3 hours to concrete all the concepts on my own regarding this Dijkstra's Algo and shortest path.... "UNDERSTOOD"

  • @amantripathi4100
    @amantripathi4100 Год назад +4

    brother u nailed it>>>>> RESPECT

  • @Ritik_Mangal
    @Ritik_Mangal 3 месяца назад

    striver bhai, you will become a person which will be remembered in history forever.😊

  • @DHRUVBOHARA-z4i
    @DHRUVBOHARA-z4i Год назад +9

    immense amount of efforts put in by you!! hats -off raj bhaiya.

  • @nikhilkrishna643
    @nikhilkrishna643 Год назад +3

    The explanation of the time complexity is just amazing! Thank you so much!

  • @ranjeet_sohanpal
    @ranjeet_sohanpal 2 месяца назад

    Seriously ,you are the best. The deep work you did to become skillful is inspirational

  • @algorithmsbyaditi
    @algorithmsbyaditi 11 месяцев назад +2

    You explained it really well ! I tried to understand it by reading a lot of blogs and discussions but was not able to but got your explanation. Thank you for this great great video.

  • @chirayusanghvi8885
    @chirayusanghvi8885 3 месяца назад

    One of the best time complexity analysis explanation, thank you !! 🙏

  • @SmitShah-m1m
    @SmitShah-m1m 10 месяцев назад

    this is the top 1 rating video from my perspective for understanding of working flow time complexity throughout the code.

  • @mdyousufgazi4030
    @mdyousufgazi4030 Год назад +4

    amazing. i really appreciate it how you explained the whole dijktra's algorithm. and the last part where you showed the the time complexity is O(E log V)

  • @nishanthazarikab9166
    @nishanthazarikab9166 10 месяцев назад

    Amazing explanation of the derivation .I have never seen any RUclipsr going into such a deep concept..

  • @parvmunjal7986
    @parvmunjal7986 2 месяца назад

    This is the best explanation I have ever seen in my life. Thanks Striver :)

  • @amanasrani6405
    @amanasrani6405 3 месяца назад +1

    Striver, Shiv Baba Bless you , you are like God's swarup

  • @niteshverma8281
    @niteshverma8281 2 года назад +2

    you are the best youtuber in the world for coding ♥♥♥♥♥♥

  • @piyushk_071
    @piyushk_071 Год назад +1

    Best Explaination of Time complexity!✨

  • @rpdesigns3545
    @rpdesigns3545 4 месяца назад

    I think the time complexity with queue will be same as of the priority queue just take the queueq and instead taking distance from the pair take it from the distance matrix. for the eg u took we will have node 3 twice in the queue and the distance matrix will have min distance of 3 to node 3. And we will calculate the distance to node 4 and 5 and pop and now when we will come to the next node 3 in queue the condition distance[node 3]+edgewt of 5

  • @adityagandhi4712
    @adityagandhi4712 Год назад +3

    The effort you have put are shown clearly in this video !
    Great explanations.

  • @vijethkashyap151
    @vijethkashyap151 4 месяца назад

    Time complexity explanation is the best! Thanks!

  • @kaichang8186
    @kaichang8186 Месяц назад

    understood, thanks for the awesome derivation of the time complexity

  • @alibozkurt-i5r
    @alibozkurt-i5r Месяц назад

    explanation of time complexity perfect
    thank you so much

  • @sambhavagarwal5871
    @sambhavagarwal5871 2 года назад +6

    understood all 3 videos. amazing striver this graph Series is best in the best as well as paid courses
    Please upload more videos if its there thanks a lot striver

  • @shigoeditz7079
    @shigoeditz7079 9 месяцев назад

    What an Explanation man hat's off to you 🤯🤯🤯

  • @avi7629
    @avi7629 Год назад +2

    Kya padhaya hain bhyii 🔥🔥🔥🔥🔥🔥🔥 aag ekdum

  • @ekanshlohiya98
    @ekanshlohiya98 Год назад +5

    If the outer loop is running while the heap is not empty then it will also run for the size of heap times i.e., O(v2). I think one optimization is possible here.
    maintain the count of visited nodes say ct and as soon as the ct becomes n, just break from the priority queue.
    Now we know, that priority queue picks only least cost path for the node, so mark it as visited since the least cost for that node is already done and increase the count of visited nodes.
    So, as soon as shortest path for all nodes is calculated from priority queue, the entries which are not optimal will not need to be popped out and we will save the extra time.
    vector dijkstra(int n, vector adj[], int src)
    {
    priority_queue pq;
    vector dist(n,INT_MAX);
    dist[src] = 0;
    pq.push({0,src});
    int ct = 0;
    vector vis(n,0);
    // vis[src]=1;
    while(!pq.empty()) //o(v)
    {
    if(ct==n) break;
    auto d = pq.top().first;
    auto node = pq.top().second;
    pq.pop();
    //log(heap size) -> log(v2)
    //worst case heap size O(v2)
    //everyone is connected to every other one so v-1 edges for v nodes each
    if(vis[node]) continue;
    vis[node]=1;
    ct++;
    for(auto it:adj[node]) //o(v-1)
    {
    int u = node;
    int v = it[0];
    int wt = it[1];
    if(!vis[v] and dist[v]>dist[u]+wt)
    {
    dist[v] = dist[u] + wt;
    pq.push({dist[v],v}); //log(v2)
    }
    }
    }
    return dist;
    //O(v * (log(v2)+(v-1)(log(v2))))
    //O(v * log(v2)*(v))
    //O(v2 log(v2))
    //O(2 v2logv)
    //O(ElogV)
    }

    • @spydycoder6668
      @spydycoder6668 Год назад

      correct bro

    • @gouravgarg1069
      @gouravgarg1069 Год назад

      if its so,why we need to check and update for same node again again i think pq picks "node with least cost from source" not "least cost path for the node"

    • @anmoljain8327
      @anmoljain8327 Год назад +2

      I also had the same doubt, that if we will allow the loop to run till priority_queue becomes empty then, the normal queue and priority_queue will take the same time. you found the solution.

    • @darkstudio3170
      @darkstudio3170 10 месяцев назад

      this wont work , you correct about the time complexity part though . The thing you may have V2 node in queue but not all of them will be processed hence V2 wont be multiplied to inner part . In generall in it is fair to say that nV node will be process where n

    • @prathyush6508
      @prathyush6508 4 месяца назад

      You're right bro, but if that is the case then priority queue should be faster than set as we are still doing the same thing as set but not removing any elements.

  • @aadharjain313
    @aadharjain313 Год назад +12

    those who cannot understand or digest why TC is O(ElogE) for priority queue and O(ElogV) for set.
    Think in this manner that for priority queue , there is no way we can erase duplicate or recurring nodes, so in worst case heap will be having V*(V-1) nodes i.e = E . and hence "logE"
    for set method, we will be erasing the node from the set first before inserting it with a better distance, that means even in worst case , we won't be having duplicate nodes. hence, at worst (hypothetically) all vertices can be present in the set (but no single vertex will be present twice) . hence maximum heap size boils down to "V'.
    that is why "log V".

  • @harshkilaji
    @harshkilaji 8 месяцев назад

    The derivation was marvelous

  • @RahulSharma-ht2xz
    @RahulSharma-ht2xz Год назад

    TC explanation was on another level

  • @visase2036
    @visase2036 2 года назад +3

    Finally after days! We were awaiting for the new videos in the Graph playlist! Thank you so much for your immense efforts, Striver.

  • @satraprathore5349
    @satraprathore5349 3 месяца назад

    Awesome derivation, Hats off

  • @top_g755
    @top_g755 Год назад +1

    We take PQ instead of q to reduce no. Traversal (unnecessary) using PQ what we do is in initial traversal we used to choose the minimum one

  • @shreyarawatvlogs6920
    @shreyarawatvlogs6920 9 месяцев назад +1

    JUST MINDBLOWING!!! Thanks a ton!!!!

  • @NiveditaKar-xj6ew
    @NiveditaKar-xj6ew 5 месяцев назад

    Thank you so much for this amazing explanation Raj

  • @rohitn6333
    @rohitn6333 Год назад +1

    sir the time complexity explanation was very good. thank you :)

  • @tanya8353
    @tanya8353 Месяц назад

    Wonderful Explanation!!

  • @mightygerman
    @mightygerman 3 месяца назад

    Very very very nice explanation....

  • @piyushsaxena6243
    @piyushsaxena6243 Год назад +1

    really love your explanations

  • @snvlogger4169
    @snvlogger4169 Год назад

    the explanation of T.C. is OP .

  • @ShivamKumar-zn4uc
    @ShivamKumar-zn4uc Год назад

    After watching this video I came to realize why striver is the goat..🐐🐐

  • @priyanshajmera3177
    @priyanshajmera3177 Год назад

    number of edges in worst case will be n*(n-1)/2 please check it in last segment of video . But Great lecture By the way

  • @UCSSaloni
    @UCSSaloni Год назад +3

    00:00 Explaining Dijkstra's algorithm and why priority queue is used
    01:58 Using a priority queue can save time in pathfinding
    03:47 Optimize distance calculation by using minimal distance
    05:40 Using priority queue to reach minimal nodes first reduces unnecessary exploration of parts.
    07:25 The while loop runs for V, which is the total number of nodes.
    09:16 Optimizing priority queue operations in graph algorithms
    11:12 Pushing nodes in worst-case scenario results in V^2 Heap size
    12:59 Explaining the time complexity of Dijkstra's algorithm
    Crafted by Merlin AI.

  • @gauristar4094
    @gauristar4094 3 месяца назад

    commedable job once again striver!!!

  • @piyushjaiswal9192
    @piyushjaiswal9192 Год назад +1

    One of the best videos of Dijkstra's Algorithm on the internet.

  • @hemachel175
    @hemachel175 4 месяца назад

    Understood. Thanks for all the effort.👌

  • @athangkulkarni8245
    @athangkulkarni8245 7 месяцев назад

    Understood.
    Thank you Striver!

  • @Kokowangmini
    @Kokowangmini Год назад +1

    Understood. Thank you so much.

  • @prathamkapoor2513
    @prathamkapoor2513 2 года назад +1

    Time Complexity explanation was awesome

  • @Nirala_414
    @Nirala_414 2 года назад +1

    Mastering Graph ❤️🙌🏻

  • @arjunju469
    @arjunju469 8 месяцев назад +2

    God level explanantion

  • @itz_me_imraan02
    @itz_me_imraan02 Год назад

    It got clear now...i was wondering the same dat even Queue gives the same answer...understood now dat it gets TLE due to too many unnecessary paths calculations....

  • @cinime
    @cinime 2 года назад +1

    Understood! Wooow! Super fantastic explanation as always, thank you very much!!

  • @meetkgp
    @meetkgp Год назад +1

    I want to ask a question regarding the time complexity derivation. It seems that during the process, V^2 was substituted with E. However, in the case of a tree graph or sparse graph, where our scenario aligns, O(V) is equivalent to O(E). Therefore, it would be considered incorrect to substitute V^2 with E in this particular situation.

  • @user-tl5cs7dx1c
    @user-tl5cs7dx1c 2 месяца назад

    wonderfull explanation sir

  • @bageshwardham-1M
    @bageshwardham-1M Год назад +2

    GUYs please dont compare love and striver. Both are great on their own
    •meko graph striver se padhna psnd hai
    •aur trees love babbar ka
    aisa hi kuch scene boht logo ka hoga...
    To jisko jiska smjh aata hai usse padho...koi dakka mukki ni😊

  • @vakhariyajay2224
    @vakhariyajay2224 Год назад +1

    Thank you very much. You are a genius.

  • @aasifali9139
    @aasifali9139 Год назад +1

    fully understood. Thx a lot

  • @AJ-xc3ks
    @AJ-xc3ks 10 месяцев назад

    Striver U are just Op..❤❤❤🙏

  • @lakshaysharma852
    @lakshaysharma852 Год назад +1

    Much needed Awesome explanation !!!!

  • @prithvisen6560
    @prithvisen6560 4 месяца назад

    Great Explanation ❤

  • @abhijeetbasfore6816
    @abhijeetbasfore6816 2 года назад +2

    understood all 3 videos. time complexity part was awesome

  • @KUMARSAURABH-s5i
    @KUMARSAURABH-s5i 4 месяца назад

    Amazing explaination

  • @BiswajitDas__0
    @BiswajitDas__0 4 месяца назад

    Amazing Explanation.

  • @shivamgupta-ch8kw
    @shivamgupta-ch8kw Год назад +7

    Hey, If we have taken the heap size as V^2 then the while( !pq.empty()) this loop should also run for V^2 times, not V. Please correct me If I am wrong.

  • @KapilMaan-vw9sd
    @KapilMaan-vw9sd 2 месяца назад

    understood sir,
    thanks for making this video sir 🩷

  • @VrundLeuva-g5s
    @VrundLeuva-g5s 3 месяца назад

    very nice explanation

  • @b_01_aditidonode43
    @b_01_aditidonode43 Год назад

    understood sir...amazing one

  • @tasneemayham974
    @tasneemayham974 6 месяцев назад

    AMAZING TIME COMPLEXITY EXPLANATIONNN!!! I wrote everything downn!!
    I have one question though please. I didn't get how you converted V^2 to E. (V-1) which is Edges * V which is Vertices = V^2. So how can E*V = E? I think I missed something. If anyone would be willing to explain please?
    AS USUAL, UNBEATABLE WORK STRIVER!! Thx for the amazing efforts!!!

  • @codingisfun-pranayharishch3001
    @codingisfun-pranayharishch3001 6 месяцев назад

    Amazing explanation sir

  • @g51661
    @g51661 11 месяцев назад +2

    Bhaiya, I have one doubt. If we're taking Heap size = V^2 appx. then while loop will also run for V^2 times, no? So, jo humne V assume kia hai doesn't that contradict with later heap size?

    • @abhilash6661
      @abhilash6661 10 месяцев назад

      I too got the same doubt.

  • @rishabhagarwal8049
    @rishabhagarwal8049 2 года назад +1

    Understood Sir, Thank you very much

  • @kehsihba2716
    @kehsihba2716 7 месяцев назад +1

    Great Video. Thanks.
    But I am a bit confused. If the heap size could go upto V^2, why are we considering the complexity for the main loop (while(!PQ.empty)) as O(V)? And according to this logic, wouldn't a normal queue have better time complexity in any case, since we are saving the PQ dequeue & enqueue operations there (2 * log(V^2))?

    • @tasneemayham974
      @tasneemayham974 6 месяцев назад

      I think in PQ we are considering worst case TC and according to that I think both Q and PQ would be the same TC, but the thing is PQ calculates shortest paths first. Maybe.

    • @TheRandomPerson49
      @TheRandomPerson49 3 месяца назад

      @@tasneemayham974 At the end PQ and Q both do the same number of iteration only difference is that, PQ choose the smallest distance first to traverse

  • @VISHALMISHRA-ff2ih
    @VISHALMISHRA-ff2ih Год назад +2

    Although (3,3) wiil be at top we will also inserting the element in the Priority_queue like (7,3) and (3,3) both then the Node 3 is traversed two times..then how the complexity reduces in Priority queue only thing is better that the minm we will get everytime.

  • @prashantrai5102
    @prashantrai5102 Год назад +2

    Sir it was awesome but there is a doubt in taking pq as O(V) time and taking time of heap.size as O(V^2). Please reply .

  • @MaheshKumar-ur8hq
    @MaheshKumar-ur8hq Год назад +1

    Bhaya,Although (3,3) wiil be at top we will also inserting the element in the Priority_queue like (7,3) and (3,3) both then the Node 3 is traversed two times..then how the complexity reduces in Priority queue only thing is better that the minm we will get everytime.

  • @poojithkumar2283
    @poojithkumar2283 Год назад +1

    Hey striver I have understood the time complexity very well can you please explain time complexity of bfs and dfs once🙂🙂

  • @parvahuja7618
    @parvahuja7618 4 месяца назад

    very indepth explaintion

  • @yaswanthkosuru
    @yaswanthkosuru Год назад +1

    This is really good❤❤❤❤❤❤

  • @yatendraupadhyay2180
    @yatendraupadhyay2180 2 месяца назад

    Bhaiya Bharat Ratna is waiting for you ..

  • @mriduljain6809
    @mriduljain6809 Год назад

    Amazing Explanation Bhaiya

  • @visheshagrawal8676
    @visheshagrawal8676 Год назад

    bhai content hai maja aagya ✨✨✨✨

  • @saibunny1253
    @saibunny1253 5 месяцев назад

    understood striver bhai

  • @mahirneema136
    @mahirneema136 2 года назад +2

    great explanation 😇

  • @manishadodeja2014
    @manishadodeja2014 Год назад +5

    if heap here is the priority queue and if heap size is v^2 then the complexity for while(pq is not empty) should also be v^2 and not v right?

  • @avi7629
    @avi7629 Год назад

    Dedication level op 🔥

  • @NishilPatel-d2m
    @NishilPatel-d2m 3 месяца назад

    Best explanation

  • @MdSakib-w3s4t
    @MdSakib-w3s4t 3 месяца назад

    Boossssssssssssssss❤ this is called quality education

  • @utkarshajadhav7998
    @utkarshajadhav7998 8 месяцев назад +1

    I have doubt . they said in worst case we will have v*(v-1) entries in queue, but how is it possible? for example if we take 4 node graph and starting with zero . lets consider whenn we pop out node zero from queue , and remaining 3 nodes pushed into queue. now when next node will be popped out there is no way it will push 0(parent of it ) . At most it will be able to push the remaining 2 nodes right?

    • @sahulraj9536
      @sahulraj9536 8 месяцев назад

      yes you are right,but for a larger number the queue will be definitely much greater than V and some what lesser than v*v ,so he done the approximation to v*v

  • @lucifersamrat6280
    @lucifersamrat6280 16 дней назад

    burrapadu explanation guru

  • @AniRec-e8u
    @AniRec-e8u Год назад +2

    My mind is fucking blown right now i never ever thought I will ever be able to understand anything like this........ Thank you very very much you are a god for me bro...

  • @techgamer4291
    @techgamer4291 6 месяцев назад

    Great work !!

  • @susmitsingh1775
    @susmitsingh1775 11 месяцев назад

    you are always amazing man!!