Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Red–black tree
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
==== Join-based ==== This approach can be applied to every sorted sequence data structure that supports efficient join- and split-operations.<ref>{{cite book | last=Sanders | first=Peter | editor1-last=Mehlhorn | editor1-first=Kurt | editor2-last=Dietzfelbinger | editor2-first=Martin | editor3-last=Dementiev | editor3-first=Roman | year=2019 | title=Sequential and Parallel Algorithms and Data Structures : The Basic Toolbox | series=Springer eBooks | location=Cham | publisher=Springer | pages=252–253 | isbn=9783030252090 | doi=10.1007/978-3-030-25209-0 | s2cid=201692657 }}</ref> The general idea is to split {{mvar|I}} and {{mvar|T}} in multiple parts and perform the insertions on these parts in parallel. # First the bulk {{mvar|I}} of elements to insert must be sorted. # After that, the algorithm splits {{mvar|I}} into <math>k \in \mathbb{N}^+</math> parts <math>\langle I_1, \cdots, I_k \rangle</math> of about equal sizes. # Next the tree {{mvar|T}} must be split into {{mvar|k}} parts <math>\langle T_1, \cdots, T_k \rangle</math> in a way, so that for every <math>j \in \mathbb{N}^+ | \, 1 \leq j < k</math> following constraints hold: ##<math>\text{last}(I_j) < \text{first}(T_{j + 1})</math> ## <math>\text{last}(T_j) < \text{first}(I_{j + 1})</math> # Now the algorithm inserts each element of <math>I_j</math> into <math>T_j</math> sequentially. This step must be performed for every {{mvar|j}}, which can be done by up to {{mvar|k}} processors in parallel. # Finally, the resulting trees will be joined to form the final result of the entire operation. Note that in Step 3 the constraints for splitting {{mvar|I}} assure that in Step 5 the trees can be joined again and the resulting sequence is sorted. <gallery widths="400px" heights="250px" perrow="2"> BulkInsert JoinBased InitialTree.svg|initial tree BulkInsert JoinBased SplitTree.svg|split I and T BulkInsert JoinBased SplitTreeInserted.svg|insert into the split T BulkInsert JoinBased JoinedTree.svg|join T </gallery> The pseudo code shows a simple divide-and-conquer implementation of the join-based algorithm for bulk-insert. Both recursive calls can be executed in parallel. The join operation used here differs from the version explained in this article, instead [[Join-based tree algorithms#Join2|join2]] is used, which misses the second parameter k. '''bulkInsert'''(T, I, k): I.sort() bulklInsertRec(T, I, k) '''bulkInsertRec'''(T, I, k): '''if''' k = 1: '''forall''' e '''in''' I: T.insert(e) '''else''' m := ⌊size(I) / 2⌋ (T<sub>1</sub>, _, T<sub>2</sub>) := split(T, I[m]) bulkInsertRec(T<sub>1</sub>, I[0 .. m], ⌈k / 2⌉) || bulkInsertRec(T<sub>2</sub>, I[m + 1 .. size(I) - 1], ⌊k / 2⌋) T ← join2(T<sub>1</sub>, T<sub>2</sub>) ===== Execution time ===== Sorting {{mvar|I}} is not considered in this analysis. :{| |- | #recursion levels || <math>\in O(\log k)</math> |- | T(split) + T(join) || <math>\in O(\log |T|)</math> |- | insertions per thread || <math>\in O\left(\frac{|I|}{k}\right)</math> |- | T(insert) || <math>\in O(\log |T|)</math> |- | {{nowrap|1='''T(bulkInsert) with {{mvar|k}} = #processors'''}} || <math>\in O\left(\log k \log |T| + \frac{|I|}{k} \log |T|\right)</math> |} This can be improved by using parallel algorithms for splitting and joining. In this case the execution time is <math>\in O\left(\log |T| + \frac{|I|}{k} \log |T|\right)</math>.<ref>{{cite journal | title=Fast Parallel Operations on Search Trees | last1=Akhremtsev | first1=Yaroslav | last2=Sanders | first2=Peter | journal=HiPC 2016, the 23rd IEEE International Conference on High Performance Computing, Data, and Analytics, Hyderabad, India, December, 19-22 | pages=291–300 | publisher=IEEE, Piscataway (NJ) | year=2016 | isbn=978-1-5090-5411-4 | arxiv=1510.05433 | bibcode=2015arXiv151005433A }}</ref> ===== Work ===== :{| |- | #splits, #joins || <math>\in O(k)</math> |- | W(split) + W(join) || <math>\in O(\log |T|)</math> |- | #insertions || <math>\in O(|I|)</math> |- | W(insert) || <math>\in O(\log |T|)</math> |- | '''W(bulkInsert)''' || <math>\in O(k \log |T| + |I| \log |T|)</math> |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Red–black tree
(section)
Add topic