Segment Tree - Range Queries with Lazy Updates
Explanation of the Segment Tree data structure. This has recently become quite popular for coding contests and interview questions. It is used to make range queries and updates.
The segment tree consists of a base array and it's ancestors. Each ancestor holds information to answer a query involving all of its descendants. This works only when the function at ancestor is an aggregate function like sum, max, min, xor etc...
Construction requires O(N) space and time complexity.
Queries can be answered in O(logN) time. Updates can be made lazily by storing the information at parent and propagating only when required. Hence, the complexity of an update is also O(logN).
We explain with the help of an example: Flipping coins. This question is ideal to understand about range query and update data structures.
Flipping Coins:
https://www.codechef.com/problems/FLIPCOIN/
Code for Flipping Coins:
https://www.codechef.com/viewsolution/12145491
Tutorial by Utkarsh Lath:
http://letuskode.blogspot.in/2013/01/segtrees.html
Видео Segment Tree - Range Queries with Lazy Updates канала Gaurav Sen
The segment tree consists of a base array and it's ancestors. Each ancestor holds information to answer a query involving all of its descendants. This works only when the function at ancestor is an aggregate function like sum, max, min, xor etc...
Construction requires O(N) space and time complexity.
Queries can be answered in O(logN) time. Updates can be made lazily by storing the information at parent and propagating only when required. Hence, the complexity of an update is also O(logN).
We explain with the help of an example: Flipping coins. This question is ideal to understand about range query and update data structures.
Flipping Coins:
https://www.codechef.com/problems/FLIPCOIN/
Code for Flipping Coins:
https://www.codechef.com/viewsolution/12145491
Tutorial by Utkarsh Lath:
http://letuskode.blogspot.in/2013/01/segtrees.html
Видео Segment Tree - Range Queries with Lazy Updates канала Gaurav Sen
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Segment Tree Range Minimum QueryMyths every Competitive Programmer should knowSegment Tree Data Structure - Min Max Queries - Java source codeThe World's Best Mathematician (*) - NumberphileSEGMENT TREE Implementation / Construction (Sum of range query and update query)Data Consistency and Tradeoffs in Distributed SystemsLazy Propagation Segment TreeSum of given range | Segment tree construction and update | Simplest explanationA&DS S02E02. Segment Trees, Lazy PropagationWhat is Consistent Hashing and Where is it used?Hard interview problems #AlgoWorkout with @Kartik AroraSegment Trees - The Best Introduction in 10 minsHow I Learned to Code in 6 Months - And Got Into GoogleHow I mastered Data Structures and Algorithms from scratch | MUST WATCHSegment Trees explained - LIVEAlgorithmsThread 3: Segment TreesRange XOR Queries - CodeChef - BEAR AND XOR SUMS - Part 110.2 B Trees and B+ Trees. How they are useful in DatabasesLazy Propagation in Segment Tree | Point and Range Updates | Live Coding