Remarks: By default, we show e-Lecture Mode for first time (or non logged-in) visitor.
Please login if you are a repeated visitor or register for an (optional) free account first.
To toggle between the RMinQ/RMaxQ/RSumQ Segment Tree, select the respective header.
Pro-tip: Since you are not logged-in, you may be a first time visitor who are not aware of the following keyboard shortcuts to navigate this e-Lecture mode: [PageDown] to advance to the next slide, [PageUp] to go back to the previous slide, [Esc] to toggle between this e-Lecture mode and exploration mode.
View the visualisation of Segment Tree here!
The top side shows the Segment Tree structure where each vertex shows the Min/Max/Sum value of the corresponding range (red colored with this format [L,R]).
The bottom row shows the original array A content (yellow colored) from which the Segment Tree structure is built.
Vertices that are lazily updated will have this purple ring highlight.
Each leaf vertex in the Segment Tree corresponds to an individual index in the corresponding array A.
Another pro-tip: We designed this visualization and this e-Lecture mode to look good on 1366x768 resolution or larger (typical modern laptop resolution in 2017). We recommend using Google Chrome to access VisuAlgo. Go to full screen mode (F11) to enjoy this setup. However, you can use zoom-in (Ctrl +) or zoom-out (Ctrl -) to calibrate this.
There are three basic operations that are available in Segment Tree data structure visualization (for all 3 modes: RMinQ/RMaxQ/RSumQ):
1. You can create RMinQ/RMaxQ/RSumQ Segment Tree from either a user-defined array of integers (maximum of 16 two-digits integer), or let the system provide a small random integer array or a small random but sorted integer array.
2. You can do RMinQ/RMaxQ/RSumQ by specifying a left (L) and a right (R) indices.
3. You can do Range Update by specifying a left (L) index, a right (R) index, and a new VALUE for this range [L,R]. We employ lazy update strategy for fast performance.
Unfortunately, this data structure is not yet available in C++ STL, Java API, Python or OCaml Standard Library as of 2020. Therefore, we have to write our own implementation.
Please look at the following C++/Java/Python/OCaml implementations of this Segment Tree data structure in Object-Oriented Programming (OOP) fashion:
segmenttree_ds.cpp
segmenttree_ds.java
segmenttree_ds.py
segmenttree_ds.ml
Again, you are free to customize this custom library implementation to suit your needs.
e-Lecture: The content of this slide is hidden and only available for legitimate CS lecturer worldwide. Drop an email to visualgo.info at gmail dot com if you want to activate this CS lecturer-only feature and you are really a CS lecturer (show your University staff profile).
Erstellen
Range Query
Range Update