Lazy Propagation Segment Tree

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ม.ค. 2025

ความคิดเห็น • 114

  • @ngc35ster
    @ngc35ster 2 ปีที่แล้ว +26

    Dude, your explanation on these complicated algorithm is so clear to me compared to other youtube channels. Still super helpful 7 years later and I really appreciate your time and passion.

    • @The_Promised_Neverland...
      @The_Promised_Neverland... 2 ปีที่แล้ว +2

      people come and go, but their contribution remains... this channel proves it... Literally even after so many years, his vids still helping people

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

      The whole italian community of the IOI used this video to learn Segment Trees.

  • @danielyeh2984
    @danielyeh2984 8 ปีที่แล้ว +15

    This video enables me to fully understand the concept of Lazy Propagation. Thank you!

  • @RaviRaj-zz3bt
    @RaviRaj-zz3bt 8 ปีที่แล้ว +3

    I am preparing for interview at best IT firms. Your videos are best source of learning than any channel i ever visited. Thanks a lot and keep teaching with such a great dedication and ease :)

  • @Sandeep-gv2qk
    @Sandeep-gv2qk 7 ปีที่แล้ว +7

    This is the best explanation of lazy propagation on the internet!
    Thanks mahn, keep up the good work!

  • @tahanimachowdhury
    @tahanimachowdhury 9 ปีที่แล้ว +8

    Your tutorials are the best as usual. I was struggling with the simulation part of lazy propagation. Thanks to you things are clear now. Please take out some time to make a video on Lowest Common Ancestor. Thank you for your hard work, really appreciate it.

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

    Thanks a lot Tushar.
    I have been searching a video lecture on segment tree for months and now u have done this.
    Great explanation. GOOD JOB !!!

  • @tarunanand2455
    @tarunanand2455 8 ปีที่แล้ว +30

    Really man hats off to you..able to understand in one go!!

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

    its quite good explanation of lazy propagation.....thanks ..

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

    Your videos are awesome Sir!..Very much easier to understand than TopCoder tutorials!

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

    Thanks, this is one of the best video tutorial of lazy propagation in youtube!

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

    Thanks for great video Tushar. Your explanations are incredibly helpful !

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

    Your explanation is pro level! It helped me so much to understand such a difficult concept.

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

    Very informative channel Tushar. Feels great to realise (after seeing your LinkedIn) that you did your bachelors from MNNIT as well.

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

    this all, 8 yrs ago.
    gotta appreciate the 1080p res and the screen sharing at that time!

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

    Excellent explanation. Thank you sir. You made actually a diffucult topic to an eaay one with your clear explanation

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

    Thanks for the simple explanation, it helped me a lot!

  • @vishalsheth1888
    @vishalsheth1888 9 ปีที่แล้ว

    Finally,lazy propagation! Your videos are the best thanks.

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

    Bhaiyya video kaafi sahi tha... Especially wo effects

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

    You are the man! Can;t have a better explanation than this.

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

    Understood easily from this video. Can you also provide complexity analysis of these functions in the future videos? It would be very helpful

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

    The only video I understood about LP

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

    Hey Tushar! amazing work. you make people understand the concepts.
    One request, can you please make a video on persistent segment tree?

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

    Such an awesome explanation with examples.

  • @himanshusagar115
    @himanshusagar115 9 ปีที่แล้ว

    Thanks man for this video..
    Now i am able to solve the problems based on lazy propagation

  • @varunsinghania3683
    @varunsinghania3683 8 ปีที่แล้ว

    Tushar really appreciate your work. Thank you!

  • @saidattathallam
    @saidattathallam 9 ปีที่แล้ว

    this video is cool. :D
    perfect and clear explanation easily understandable .
    thanks for this and i expect some more that could help understand data structures that generally used in competitive coding

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

    It's still nice even it has been 4 years since the date the video was uploaded....

  • @Sandeepg255
    @Sandeepg255 9 ปีที่แล้ว

    Your videos are really helpful..Thank you very much n keep up the good work...

  • @adityasingh5002
    @adityasingh5002 7 ปีที่แล้ว

    thanks for the video, keep uploading new videos it helps very much...

  • @RajMishra-mq5zm
    @RajMishra-mq5zm 3 ปีที่แล้ว

    difficult topic explained in easy way. I don't know how many are there who watch your coding part but for me i always stop after your algo explanation.

  • @adityakumarghosh433
    @adityakumarghosh433 9 ปีที่แล้ว

    Awesome Video for any beginner in segment Trees !!! :)

  • @tino96ptv
    @tino96ptv 7 ปีที่แล้ว

    Great explanation, and thanks very much for the code, it was very useful

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

    Thank you sir....for making such a useful video....

  • @nitinpaliwal9196
    @nitinpaliwal9196 9 ปีที่แล้ว

    the best tutorial by the best teacher thanks a lot :)

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

    Thanks. Very useful and properly explained.

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

    Thank you so much man, you are the best.

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

    I am a fan of your videos! Could you please explain somehow "Find the median of two sorted arrays in log (Min(m,n)) time?" I've really had a hard time in understanding this solution but still couldn't understand. I look forward to you for this.

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

    At 14:49, we have a condition about low>high but if mid = (low+high)/2, then why would ever the value of low be greater than high. The condition seems somewhat useless? Am I missing something?

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

      You are right, low>high will always be false and you can remove the condition if you want.
      That statement is a simple check at the last leaf node in the segment tree at (n-1,n-1) where the function COULD make a recursive call to its right side (we know this wont actually happen though) and therefore its just added in as a sanity check.
      Although Tushar does mention while going through the code at 14:51 saying "at this point it doesn't happen" which is very misleading because it implies that there is a point where it could happen which we now know is not true. Cheers :P

  • @devanshuLitoria
    @devanshuLitoria 9 ปีที่แล้ว

    Your videos are amazing..thanks a ton sir.

  • @leightonchoi8644
    @leightonchoi8644 7 ปีที่แล้ว

    Looking forward to your update.

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

    ABSOLUTELY RELIABLE

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

    This dude is legend!!!!!

  • @IshanSharma0019
    @IshanSharma0019 9 ปีที่แล้ว

    Much needed tutorial ..thanks Tushar bhai... Can you make a video on Mo's algorithm and how it is compared to segment trees wid lazy propagatn.

  • @dipankardey7917
    @dipankardey7917 8 ปีที่แล้ว

    Thanks man ! ...Awesome lectures !!

  • @ashish3192
    @ashish3192 8 ปีที่แล้ว

    Awesome one!! thank you very much Sir.

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

    lazy prop feels like a bureaucrat came up with a algorithm for seg tree

  • @meganlee5897
    @meganlee5897 7 ปีที่แล้ว

    this tutorial is awesome!as the title segment tree made simple

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

    is if(low>high) return necesasary? great video btw

  • @roh9934
    @roh9934 7 ปีที่แล้ว

    at 24:42 , is there a way to not update element. when there is no overlap, it can save some time.
    Please Enlighten me if i am wrong?

  • @genuineprofile6400
    @genuineprofile6400 8 ปีที่แล้ว

    awesome Video.... and max here meant INFINITY right??

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

    What if we have to update an interval with different values , for eg. to add i to an interval [l,r] where i is the index of the respective element to which it is added.

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

      okay then i think we update node value as node[l,r]=(l+l+1+l+2.......r) and lazy[2*n]=(l=l+1+l+2...(l+r)/2) and lazy[2*n+1]=((l+r)/2+1+.....r).in short we can write formula for node[l,r] as sum of AP terms and reduce in beautiful expression ,cheers!

  • @visheshsrivastav2107
    @visheshsrivastav2107 7 ปีที่แล้ว

    Thankyou sir....The video helped me alot

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

    Excellent Explanation!!

  • @shivshankarjha4818
    @shivshankarjha4818 8 ปีที่แล้ว

    Awesome explanation

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

    Thank you Tushar!!

  • @offchan
    @offchan 9 ปีที่แล้ว

    Can we store the minimum index instead of the value and still use lazy propagation technique?

  • @GautamKumar-tn7ev
    @GautamKumar-tn7ev 9 ปีที่แล้ว

    Nice Lecture.
    Have you made any video on Binary Indexed Tree(BIT)?

  • @mail2shandilya
    @mail2shandilya 9 ปีที่แล้ว

    Hey Tushar, how are you doing? This Friday I have got my first online code screen (90 mins one) with Amazon, Can you please share some advice on topics I should cover? and how I should go about it? I have learnt a lot from your sessions on you tube, thanks in advance and have a good one.

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

      how your code screen was?

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

    please add one video for " updating values in segment tree "

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

    Thank you for this great explanation! :)
    But, what should I do when I have to divide leaves by different numbers? (for e.g. let's say, I have to divide elements 1 to 5 of input array by Least Prime Divisor of that particular number)

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

      I want to know how much your coding improved in these three years?

  • @puneetkumar9609
    @puneetkumar9609 7 ปีที่แล้ว

    Only one word! Amazing!

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

    Great explanation....thanks

  • @sarwarjahan05
    @sarwarjahan05 7 ปีที่แล้ว

    nice. finally i understood lazy :)

  • @talalal-hamidi3093
    @talalal-hamidi3093 9 ปีที่แล้ว

    hey i wanna ask if you got a video that explain the " balanced binary search tree "
    which solve the proplem like if you got Q query and in each query you got
    left and right and you must print the most Freq(the value that appears most) between
    left and right inclusive

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

    Thank you.....Great work.!!

  • @axehai
    @axehai 9 ปีที่แล้ว

    what if, we were required to update ranges (and not know which element is minimum in that particular range) before printing the final array. How would the algorithm change then to get better optimization.

    • @axehai
      @axehai 9 ปีที่แล้ว

      There is a huge array with all elements set to 0, initially. We are required to update portions of array (from some left index to right index) multiple times. If we choose to do it over loop (brute force it) complexity would be O(N square). How do we update it optimally? example
      arr[10]={0};
      update [2,7] by 1
      update [4,10] by 2
      update [3,4] by 3
      and finally, print the array:
      0 1 4 6 3 3 3 1 1 1

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

    fantastic! thanks a lot

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

    you really, nailed it!!

  • @PengLi53
    @PengLi53 9 ปีที่แล้ว

    Great lesson!

  • @promethuser
    @promethuser 9 ปีที่แล้ว

    how would lazy propagation change the complexity? on an average case, it should still take the same time, i think. can anyone explain this to me?

    • @promethuser
      @promethuser 9 ปีที่แล้ว

      alright, Thanks!

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

    SegmentTree[pos] += (high-low+1)*Lazy[pos];
    I have seen a C++ code of Lazy Propagtion where the above line has been used while updating the "pos"ition of the Segment Tree when the value at the same "pos"ition in the Lazy tree is non-zero. I have run that program with the same input and getting the desired answer. Can anyone tell the meaning of this line and why it has been not been used in the video?

  • @saumya1857
    @saumya1857 7 ปีที่แล้ว

    awsome explanation :)

  • @rishabhthakur1031
    @rishabhthakur1031 9 ปีที่แล้ว

    thanks man ,you are great..

  • @TheUnknownExplorerr
    @TheUnknownExplorerr 8 ปีที่แล้ว

    hey man! awesome explaination!
    could you help me in some other scenario?
    I have max range queries which i can deal with but for updates i dont have increment updates but updates related to factors of a number so i am not able to think on how to apply lazy propagation there. could you help me out?

  • @khoatruong9751
    @khoatruong9751 8 ปีที่แล้ว

    Nice Posting! Thanks

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

    You are Too good bro

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

    Thank you so much !

  • @sarthakgupta7273
    @sarthakgupta7273 9 ปีที่แล้ว

    if after incrementing from [0,0] to 2, we do the query to find minimum between [2,3] then according to your concept the answer should be 5 but the actual answer will be 1.
    Please justify it. I am highly confused.

    • @sarthakgupta7273
      @sarthakgupta7273 9 ปีที่แล้ว

      sarthak gupta Sorry.. I was wrong..got it

  • @abdulquaumopu1126
    @abdulquaumopu1126 8 ปีที่แล้ว

    Can you upload any video for persistent segment tree?

  • @hope-jh7bv
    @hope-jh7bv 4 ปีที่แล้ว

    Thank you so much.

  • @vipulsharma1897
    @vipulsharma1897 9 ปีที่แล้ว

    can u please tell me what are startrange, endrange and low, high?
    thanks in advance

  • @AbhaySingh-dm4zr
    @AbhaySingh-dm4zr 7 ปีที่แล้ว

    how can i do something like after update original array should also gets changed ...
    any thoughts ?

  • @atishnarlawar1177
    @atishnarlawar1177 7 ปีที่แล้ว

    Beautiful!

  • @firefox-zzz
    @firefox-zzz 9 ปีที่แล้ว

    thank you so much you are the best ^_^

  • @nehapoonia8080
    @nehapoonia8080 8 ปีที่แล้ว

    sir, can u plz explain the implicit treaps using split and merge functions.

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

    Bro i really appreciate your hard work but about those data structure which is not taught in our B.tech syllabus such as fusion tree, AEB tree which is more and more faster than these tree 😔😔😔 and that's why we didn't get a job in the company 🤔🤔🤔

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

    good job!

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

    Why we need if(low > high) condition, there won't be such cases if a query is already low

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

    thank you so much

  • @PankajKumar-hp5gc
    @PankajKumar-hp5gc 7 ปีที่แล้ว

    you are awesome...

  • @the343totalitarian
    @the343totalitarian 7 ปีที่แล้ว

    Thanks a lot.

  • @vaibhavkhandelwal737
    @vaibhavkhandelwal737 7 ปีที่แล้ว

    What is low>high condition?

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

    It is very hard algoritim.

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

    can i get some examples ... links please

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

    Best one

  • @ashish3192
    @ashish3192 8 ปีที่แล้ว

    Please post some videos on how to approach the problems of Dynamic Programming

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

    thx!

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

    Hello bro!...I am you, from the past, when you'll see this comment after 5-6 years✌️..
    Just wanna say, everything will be alright bro. And you'll realise then, that the time right now was not that tough than you thought in your past

  • @akashjain4184
    @akashjain4184 8 ปีที่แล้ว

    Awesome _ / \ _

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

    please talk slower