Project Manager Emily Sheffer: [email protected]@irbshare.org IRBshare Liaison Training.
An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender,...
-
Upload
cory-joseph -
Category
Documents
-
view
230 -
download
0
Transcript of An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender,...
![Page 1: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/1.jpg)
An Optimal Cache-Oblivious Priority Queue and Its
Applications in Graph Algorithms
By Arge, Bender, Demaine, Holland-Minkley, Munro
Presented by Adam Sheffer
![Page 2: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/2.jpg)
Priority Queue – A Reminder
• Maintains a set of elements, each with a priority. • Supports insert and delete-min operations.
Priority Queue
•Insert(A,2)•Insert(B,4)
•Insert(D,3)
•Insert(C,4)
•Delete-min•Insert(E,7)
•Delete-min
•Insert(F,4)
A
D
![Page 3: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/3.jpg)
Cache Oblivious Alg. – A Reminder
• and are defined as usual.• The algorithm cannot use and • An optimal paging strategy is assumed.• The “tall-cache” assumption:• The analysis can assume memory.• Standard Notations:
,B N
B
2.M B
/( ) logM B
N Nsort N
B B
( )
Nscan N
B
( )O M
![Page 4: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/4.jpg)
“An Optimal Cache-Oblivious "Priority Queue
• In order to discuss optimality, a lower
bound is required.• In [Aggarwal & Vitter ’88], it was
proved that the number of memory
transfers required for sorting is
• If we can perform both insert and delete-min with only memory transfers, we can achieve a more efficient sorting.
/( / ) log /M BN B N B
/(1/ ) log /M Bo B N B
![Page 5: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/5.jpg)
An Optimal Solution?
• Why not just use a cache-oblivious B-tree?
• Inserting elements into a B-tree takes
• We are lacking a factor of:
N(log ) ( log )B BN O N O N N
/ /
log log
( / ) log / log /B B
M B M B
N N B N
N B N B N B
![Page 6: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/6.jpg)
The Optimal Priority Queue
• We want a queue which performs both insert and delete-min with
memory transfers.
• For certain reasonable values:
• We need an amortized analysis. ?
/(1/ ) log /M BO B N B
/(1/ ) log / 1.M BB N B
![Page 7: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/7.jpg)
Similar Work
• [Brodal and Fagerberg ‘02] presents the funnel heap. This is a cache oblivious priority queue, with exactly the same results.
• [Brodal et al. ‘04] presents a cache oblivious priority queue which also supports the update operation, with memory transfers.
• [Chowdhury and Ramachandran ’04] supports the decrease-key operation, with the same results.
(1/ ) log( / )B N B
![Page 8: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/8.jpg)
The Main Data Structure
• • Level holds cells.• The last level holds at most cells.
0 ( )N Ni 1(2/3)
0
i
N
c
![Page 9: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/9.jpg)
The Inside of a Single Level
• The elements inside a buffer are not ordered.
…
X elements
2/32X 2/3
2/3
2X
X
2/3
2/3
2X
X
Buffers1/3X
X
![Page 10: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/10.jpg)
An Order Between Levels• Elements in the last down-buffer of level have
a smaller priority than elements in the first down-buffer of level .
• There is no order between up buffers.
X
3/2X
![Page 11: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/11.jpg)
The Space Complexity of the DS
• We verify that the size of the largest buffer is , by occasionally performing a global rebuilding (explained later on).
• We can store the buffers consecutively in a large array, with a size of
0 ( )N N
3/2 0log log(2/3)0 0
0
( ) ( ) ( )c
iN
i
O N O N O N
![Page 12: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/12.jpg)
The Push Operation
• The operation pushes input elements into level . Works as follows:– First, the input elements are sorted.– By scanning through the down buffers, each
input element is appended to the end of the appropriate buffer.
– Input elements with a larger priority than the elements in the down buffer, are appended into the end of the up buffer.
X3/2X
![Page 13: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/13.jpg)
An Illustrated Push
7 12 25 30 33
44 5 11 5 33 34
5 5 11 33 34 44
![Page 14: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/14.jpg)
The Push Operation (cont.)
• When a down-buffer grows to a size of , it will be split into two buffers with a size of .
• If there are already down buffers, the last down-buffer is moved into the up-buffer.
• When the up-buffer is full, its elements are recursively pushed into level .
2XX
1/2 1X
3/2X9/4X
![Page 15: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/15.jpg)
Another Illustrated Push
3/2X …
1/2 1X Buffers
Push
2X
1/2 2X
X X
Too Much
![Page 16: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/16.jpg)
Another Illustrated Push
3/2X …
1/2 1X Buffers1/2 2X
X X
Too Much
3/2 1X Recursive push
![Page 17: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/17.jpg)
The Pull Operation
• The operation pulls the elements with the lowest priority from level . – When there are not enough elements in the
down buffers, a recursive pull is performed.
X3/2X
![Page 18: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/18.jpg)
Finally, The Algorithm
• Two additional buffers, each with cells:– The insertion buffer holds the most recently
inserted elements.– The deletion buffer holds the elements with
the smallest priority (sorted).
• Both buffers are constantly maintained in the memory.
2/3c
![Page 19: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/19.jpg)
The Insert Operation
• An insert operation moves the new element into the end of the insertion buffer.
• When the buffer is full, its elements are pushed into the lowest level of the DS.
Insertion buffer
Insert(A,5)
Push
2/3c
![Page 20: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/20.jpg)
The Delete-Min Operation
• A delete-min removes the first element of the deletion buffer.
• When the buffer is empty, we pull elements from the lowest level of the DS (and sort them).
Deletion buffer
delete-min()
Pull2/3c
![Page 21: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/21.jpg)
A Slight Correction
• What if an inserted element has a lower priority than the last element in the deletion buffer?
• The last element from the deletion buffer is moved into the insertion buffer.
• The new element is moved into the deletion buffer.
-
10
10
6
2
2
34
14
35
14
-
-
7
Deletion Insertion
Insert
![Page 22: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/22.jpg)
Amortized Analysis of a Push Inserting elements into level .
• Sorting the input elements.
• Scanning through the down buffers, and appending the appropriate elements to them.
• Appending the rest of the elements to the end of the up buffer.
• Splitting overfull down-buffers.• Moving down-buffers to the end of the up-buffer.• Recursive pushes.
X 3/2X( ( ))O sort X
?( / )O X B
??
Ignore
![Page 23: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/23.jpg)
Amortized Analysis of a Push
• Splitting one down-buffer with elements, into two with
elements. • In [Frigo et al. ’99], it was shown how to compute a median
in • Therefore, a split takes memory transfers.• At least elements are inserted into a buffer before it
splits. For each element that a push operation inserts into a block, it will pay .
• This can also pay for the moving of a down buffer into the up buffer.
2XX
( / ).O X B( / )O X B
X
(1/ )O B
![Page 24: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/24.jpg)
Amortized Analysis of a Push Inserting elements into level .
• Sorting the input elements.
• Scanning through the down buffers, and appending the appropriate elements to them.
• Appending the rest of the elements to the end of the up buffer.
• Splitting overfull down-buffers.• Moving down-buffers to the end of the up-buffer.• Recursive pushes.
X 3/2X( ( ))O sort X
?( / )O X B
??
Ignore
( / )O X B( / )O X B
![Page 25: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/25.jpg)
Amortized Analysis of a Push Scanning through the down buffers, and appending the
appropriate elements to them:• There are down buffers.• Tall cache assumption – • All levels of size can be constantly kept in memory.• Therefore, we may assume that • If then • We are left with the case where• Applies for a single level, with at most down
buffers. A block from each buffer can permanently kept in memory.
2.M B2B
3/2 2.X B
1/33/2 1/21 1X X
2X B 1/2 1 ( / ).X O X B 2 3/2 3.B X B
1/2( )B O M
![Page 26: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/26.jpg)
Amortized Analysis of a Push Inserting elements into level .
• Sorting the input elements.
• Scanning through the down buffers, and appending the appropriate elements to them.
• Appending the rest of the elements to the end of the up buffer.
• Splitting overfull down-buffers.• Moving down-buffers to the end of the up-buffer.• Recursive pushes.
X 3/2X( ( ))O sort X
?( / )O X B
Ignore
( / )O X B( / )O X B
( / )O X B
![Page 27: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/27.jpg)
Amortized Analysis of a Push
• A push of elements into level can be performed in amortized number of memory transfers, not counting recursive push operations.
• A pull of elements from level , can be analyzed for the results.
X 3/2X /( / ) log ( / )M BO X B X B
X 3/2X
![Page 28: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/28.jpg)
Analysis of Insert
• Increases the size of the insertion buffer by one.
• Causes memory transfers if and only if the insertion buffer is full.
• We need the amortized number of memory transfers to be /(1/ ) log /M BO B N B
![Page 29: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/29.jpg)
A Potential Function
/
1logM B
X
B B Level -
Push coinLevel - Pull coin
X 3/2X
![Page 30: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/30.jpg)
Spreading the Coins?• Each element in the insertion buffer has a push
coin and a pull coin for every level of the DS.
• On level , each element in the first half of a down buffer has a pull coin for every level
• On level , each element in the second half of a down buffer, or in the up buffer, has a push coin for every level , and a pull coin for all levels.
X.X
X
X
![Page 31: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/31.jpg)
Amortized Cost of an Insert
• An insert operation adds a single element to the insertion buffer. This element needs a push coin and a pull coin for every level in the DS.
• The cost of an insert is:
(2/3) 0/ 0 /
0
1 1log / log
i
M B M Bi
NO N B O
B B B
![Page 32: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/32.jpg)
Paying for a Push Operation
• Pushing the elements of the up buffer of level
into level .• Before the push, each element had a push coin for
every level and a pull coin for every level.• After the push, in the worst case, each element
needs a push coin for every level and a pull coin for every level.
• We get at least spare coins, each worth
• These pay for the memory transfers of the push.
X3/2X
X
3/2X
X
/(1/ ) log ( / ) .M BB X B
X
![Page 33: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/33.jpg)
Splitting a Buffer
X elements X elements
X elements X elements
![Page 34: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/34.jpg)
Moving Up a Down Buffer
• When moving a down buffer into an up buffer, we will need additional push coins for each level , and additional pull coins for each level .
• This is exactly the number of coins which were released due to the split.
XX XX
![Page 35: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/35.jpg)
Summing Up the Analysis
• A similar analysis shows that the coins pay for the pull operations.
• An insert operation costs
amortized memory transfers.
• A delete-min operation is free, since it does not add any coins.
/ 0(1/ ) log /M BO B N B
![Page 36: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/36.jpg)
Global Rebuilding
• In order to maintain , we rebuild the DS after every operations.
• At each rebuild, we define• Level holds an empty up buffer, and
down buffers, each with elements. Level has at most down buffers with elements, and a single buffer with fewer elements.
• The global rebuilding can be done by sorting and scanning, using memory transfers.
0 ( )N N
1/3X
0 / 4N
0 2 .N N
2/3X 0N1/30N
X
( )Sort N
2/30N
![Page 37: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/37.jpg)
Global Rebuilding (cont.)
• After the rebuilding, every element is in the first half of a down buffer, so there are no push coins.
• We bound the cost of all the pull coins, by assuming that they are all in level 0.N
(2/3) 0 00 / 0 /
0
1log / log
i
M B M Bi
N NO N N B O
B B B
![Page 38: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/38.jpg)
Global Rebuilding (cont.)
• The cost of the global rebuilding is
• We will split it between the operations that occurred since the last rebuilding. This means that both insert and delete-min take
(amortized memory transfers)
0 0/logM B
N NO
B B
0( )O N
0/
1logM B
NOB B
![Page 39: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/39.jpg)
The Delete Operation
• It is possible to support a delete operation, which takes amortized memory transfers.
• The input for the operation is the id of the element and its priority.
/ 0(1/ ) log ( / )M BO B N B
![Page 40: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/40.jpg)
The Delete Operation (cont.)
• Elements with the same priority are ordered according to their id.
• When a delete operation occurs, a special delete element is inserted, with the priority and id of the input.
![Page 41: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/41.jpg)
The Delete Operation (cont.)
• A delete-min operation checks if the two first elements in the deletion buffer have the same id. If so, it throws them away and starts over.
-
{9,G}
{9,G}
{6,E}
{2,D}
{2,D}
Deletionbuffer
Delete-min()
![Page 42: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/42.jpg)
The Delete Operation (cont.)
• A delete-min operation will check if the two first elements in the deletion buffer have the same id. If so, it will throw them away and start over.
-
{9,G}
{9,G}
{6,E}
Deletionbuffer
Delete-min()
-
-
E
![Page 43: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/43.jpg)
The Delete Operation (cont.)
• In a global rebuilding, every element pair with the same id will be removed before choosing 0.N
5,E 5,F 5,E 3,J 5,K 7,A7,A9,B
8N
5,E 5,F5,E3,J 5,K 7,A 7,A 9,B
4N
![Page 44: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/44.jpg)
Application for the Priority Queue.
![Page 45: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/45.jpg)
List Ranking
• We are given a linked list with weights on the edges (or an array, with each of its cells containing the position of the next).
• We need to rank each node according to its weighted distance from the end of the list.
![Page 46: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/46.jpg)
List Ranking
• We are given a linked list with weights on the edges (or an array, with each of its cells containing the position of the next).
7 1 6 0 2 5 3 4
• We need to rank each node according to its weighted distance from the end of the list.
![Page 47: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/47.jpg)
High-Level Algorithm
• Find an independent set of size / 3.N
• Bridge-out the nodes from the set.
![Page 48: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/48.jpg)
High-Level Algorithm
• Find an independent set of size
• Bridge-out the nodes from the set.• Remove nodes from list and solve recursively.
/ 3.N
![Page 49: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/49.jpg)
High-Level Algorithm
• Find an independent set of size
4 1 0 3 2
• Bridge-out the nodes from the set.• Remove nodes from list and solve recursively.• Reinsert the nodes and fix the list.
/ 3.N
![Page 50: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/50.jpg)
High-Level Algorithm
• Find an independent set of size
• Bridge-out the nodes from the set.• Remove nodes from list and solve recursively.• Reinsert the nodes and fix the list.
7 1 6 0 2 5 3 4
/ 3.N
![Page 51: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/51.jpg)
Bridging Out
• Create a second copy of the list and sort it by successor position.
A B C D E F G H
E A B G C H F D
( ( ))O sort N
![Page 52: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/52.jpg)
Bridging Out (cont)
• Traverse both lists simultaneously. For each node which precedes a marked cell, add the position of the marked node’s successor.
A B C D E F G H
E A B G C H F D
( / )O N B
![Page 53: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/53.jpg)
Removing Marked Elements• Scan the list again, and move the unmarked
nodes into a new list. During the scan, maintain another list of old and new node positions.
• Sort the first list by successor position. Scan the two lists simultaneously to fix the successors positions.
( / )O N B
( ( ))O sort N
![Page 54: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/54.jpg)
Reinserting Marked Elements
• Reinsert the nodes from the independent set, and update the ranks.
• This can be done by using a few scans and sorts, as in the bridge-out phase.
7 1 6 0 2 5 3 4
![Page 55: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/55.jpg)
List Ranking Analysis
• Assuming that the independent set can be found in memory transfers, we achieve the following recurrence relation:
( ( ))O sort N
( ) ( ( )) ( / 3)T N O sort N T N
( ) ( ( ))T N O sort N
![Page 56: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/56.jpg)
Independent Set
• We will show how to compute a 3-coloring of the list.
• We can choose the most common color to be the independent set.
A B C D E F G H
![Page 57: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/57.jpg)
3-Coloring
• Split the list into forward running sub-lists and backward running sub-lists.
A B C D E F G H
• Each node is a member of a single list, unless it is the head of one list and the tail of another.
![Page 58: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/58.jpg)
Coloring a Forward List
• In a forward list, we color the first node in grey, and then alternate between red and grey.
A C F H
![Page 59: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/59.jpg)
Coloring a Backward List
B E G H
• In a backward list, we color the first node in orange, and then alternate between red and orange.
![Page 60: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/60.jpg)
3-Coloring (cont.)
• A node which gets a color as a head and a different color as a tail, is colored with the color of the head.
A B C D E F G H
![Page 61: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/61.jpg)
Cache Oblivious 3-Coloring• We show how to cache-obliviously color the
forward lists:– Find all the head nodes. (Can be achieved by making a
duplicated list, sorting it by successor position, and performing a simultaneous scan on both lists).
– Color the head nodes in grey.
– Create a priority queue. For each head node, insert a red element with the position of the node’s successor as its priority.
– While the queue is not empty, remove the minimum node, color it, and if its successor is in a higher position in the list, enter it into the queue (with the other color).
( ( ))O sort N
( ( ))O sort N
( ( ))O sort N
![Page 62: An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ee65503460f94bf6cef/html5/thumbnails/62.jpg)
Summing Up
• We can find a 3-coloring with (amortized) memory transfers.
• We can find an independent set with
(amortized) memory transfers.
• We can perform a list ranking with (amortized) memory transfers.
( ( ))O sort N
( ( ))O sort N
( ( ))O sort N