Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
VloĆŸit
- Äas pĆidĂĄn 27. 07. 2024
- iPad PDF Notes - github.com/MAZHARMIK/Intervie...
Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 7th video of our playlist "Segment Tree Concepts & Questions". Find the Details below :
Video Name : Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
Video # : 7
đ Unraveling Segment Tree : A Journey into the Depths of it.
đ„ Welcome to the 7th Video of my Segment Tree Concepts & Questions Playlist! đ In this enlightening video, we will finally start solving Qns on Segment Tree. In this one, we will solve - Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
đ What's Inside ?
đ We will see how we can use Segment Tree concepts to easily solve this problem - Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
đ©âđ» Who Should Watch ?
This playlist is for everyone but best suited for Freshers who are new to Segment Tree.
đ Embark on the Segment Tree Adventure Now!
Problem Name : Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
Company Tags : Google and many other companies ask problems based on this topic
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
GfG Link : www.geeksforgeeks.org/lazy-pr...
My DP Concepts Playlist : âą Roadmap for DP | How t...
My Graph Concepts Playlist : âą Graph Concepts & Qns -...
My Recursion Concepts Playlist : âą Introduction | Recursi...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Summary :
The provided code implements a segment tree with lazy propagation for efficiently updating a range of values and querying the sum over a range. Here's a brief summary:
Time and Space Complexity
Time Complexity (T.C): O(logn)
Space Complexity (S.C): O(n)
Segment Tree and Lazy Propagation
Segment Tree: An array representation of the segment tree where each node stores the sum of a segment of the array.
Lazy Tree: An auxiliary array that helps in propagating updates to avoid unnecessary updates to nodes that don't need immediate updates.
Function updateRange
This function updates a given range [start, end] by adding a specified value val to all elements within that range.
Lazy Propagation:
If there is a pending update in the lazyTree for the current node (lazyTree[i] != 0), it is applied to segTree[i].
If the current node is not a leaf node, propagate the pending update to its children in the lazyTree.
Reset the current node's lazy value to 0.
Range Check:
If the current range [l, r] is completely outside the update range [start, end], return without doing anything.
If the current range [l, r] is completely inside the update range [start, end], update segTree[i] and propagate the update to its children in lazyTree.
Partial Overlap:
If there is a partial overlap, recursively call updateRange for the left and right children.
After updating the children, update the current node's value to the sum of its children.
Key Operations:
âââŠâââŠââââŠââŠâŠâŠâŠââââ
âââŁâââââŁââŁââŁââŁâââŁââŁ
â âââââââ ââââŁâââââââŁ
âââ©âââ©ââ©ââ©ââ©âââ©ââ©ââ
âš Timelinesâš
00:00 - Introduction
00:11 - Motivation
01:49 - Recap of Point Update Query
06:42 - How to do Range Update using Lazy Propagation
36:19 - Story To Code
#codestorywithMIK
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear #RecursionExplained #CodingJourney #Programming101 #TechTalks #AlgorithmMastery #Recursion #Programming #Algorithm #Code #ComputerScience #SoftwareDevelopment #CodingTips #RecursiveFunctions #TechExplained #ProgrammingConcepts #CodeTutorial #LearnToCode #TechEducation #DeveloperCommunity #RecursiveThinking #ProgrammingLogic #ProblemSolving #AlgorithmDesign #CSEducation
#segmenttree #segment #rangequeries
Bawal Video hai bhaiya , eekdam jhakkas
This segment tree playlist is a gem
hello bhaiya,sde ke liye dsa and system design ke alawa aur kya kya padhna hota hain.
best explanation. extremely underrated.
Thanku bhaiya â€
God!!đ
Amazing bhaiya
mast. samajh me agaya.
hats off bro
Dated 7-7 and its video num 7 đ đđ Thanks for Such wonderful videos â€
achha hua aapne thala for a reason nahi bol diya đ€Łđ€Ł. but yes, this man is actually great.
Hello Could you please make video solution for 2407. Longest Increasing Subsequence II. This playlist is amazingđ„
Sir..please jaldi videos daliye..
TYSM for this!! I was stuck on the 6th ques of CSES Range section as it was based on range update. Also just a small query, can we expect Fenwick tree in this playlist?
Bangaya kya 6th ques bhai ?
@@aws_handles try hi nhi kiya bhai, Aaj krunga
sir plz contest solution bhi start krdo
humble request of many struggling people
i was waiting for the next video. thank you so much
thank you so much sir
Thanks a lot đđđ
bro please solve 406 question. I am unable to understand segment tree approach.
Bhaiya today's contest question no 4 please