Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Treap
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Find sum, minimum or maximum in a given range ==== To perform this calculation we will proceed as follows: * First we will create an additional field F to store the value of the target function for the range represented by that node. we will create a function that calculates the value F based on the values of the L and R children of the node. We will call this target function at the end of all functions that modify the tree, ''i.e.'', split and join. * Second we need to process a query for a given range [A..B]: We will call the '''s''plit''''' function twice and split the treap into <math>T1</math> which contains <math>\{1..A-1\} </math>, <math>T2 </math> which contains <math>\{A..B\} </math>, and '''''<math>T3</math>''''' which contains <math>\{B+1..n\} </math>. After the query is answered we will call the '''''join''''' function twice to restore the original treap.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)