Adjustable navigation pile Jyrki Katajainen 1 Tetsuo Asano 2 Omar - - PowerPoint PPT Presentation

adjustable navigation pile
SMART_READER_LITE
LIVE PREVIEW

Adjustable navigation pile Jyrki Katajainen 1 Tetsuo Asano 2 Omar - - PowerPoint PPT Presentation

20 November, 2015 ARCO Meeting, Lyngby Adjustable navigation pile Jyrki Katajainen 1 Tetsuo Asano 2 Omar Darwish 3 Amr Elmasry 4 Fabio Vitale 5 1 University of Copenhagen 2 Japan Advanced Institute for Science and Technology 3 Max-Planck Institute


slide-1
SLIDE 1

20 November, 2015 ARCO Meeting, Lyngby

Adjustable navigation pile

Jyrki Katajainen1 Tetsuo Asano2 Omar Darwish3 Amr Elmasry4 Fabio Vitale5

1 University of Copenhagen 2 Japan Advanced Institute for Science and Technology 3 Max-Planck Institute for Informatics 4 Alexandria University 5 University of Lille

These slides are available via my research information system http://www.diku.dk/~jyrki/Myris/slides-by-year.html

slide-2
SLIDE 2

Restricted SAM

SAM: sequential-access machine input tape; read only work tape; read write

  • utput tape; write only
  • ne-way read head

two-way read/write head

  • ne-way write head
slide-3
SLIDE 3

Restricted RAM

RAM: random-access machine input; read only; random access work space; read write; random access

  • utput; write only; sequential access
  • ne-way printing
slide-4
SLIDE 4

Sch¨

  • nhage et al.’s order notation

N: problem size a number sets of functions O

! lg N

O(lg N) Ω(lg N) O

! read: bounded

O

! read: an unspecified constant

silly question: What is 5N2 + 20N? A number or a function?

slide-5
SLIDE 5

Space-time trade-offs

input size: N (measured in elements) working space: S(N) bits; S(N) ≥ lg N running time: T(N) expected: S(N) − − − − − → = = ⇒ T(N) − − − − − → typical question: What is the fastest algorithm for the problem P of size N when working space of S(N) bits is available?

slide-6
SLIDE 6

Sorting

input size: N (measured in elements) working space: S(N) bits; S(N) ≥ lg N running time: T(N) comparison-based lower bound: T(N) ≥ O

! N lg N

[Beame 1991] S(N) · T(N) ≥ O

! N2

[Pagter & Rauhe 1998] T(N) ≤ O

! N2/S(N)+O ! N lg(S(N)), for any

S(N) ≥ O

! lg N

slide-7
SLIDE 7

Questions

(1) How would you sort N elements in O

! N2/ lg N worst-case time

when only working space of O

! lg N bits is available?

(2) How would you sort N elements in O

! N lg N worst-case time when

working space of O

! N/ lg N bits is available?

  • ptimally adjustable: How to achieve optimal worst-case running

time O

! N2/S(N) for every S(N) ∈ [O ! lg N . . O ! N/ lg N]?

slide-8
SLIDE 8

Our answer

procedure: pilesort input: A[0 . . N − 1]: read-only array of N elements S: workspace size P ← navigation-pile(A, S) for i ∈ {0, 1, . . . , N − 1}: P.insert(i) while |P| > 0: j ← P.minimum() P.extract(j)

print(A[j])

slide-9
SLIDE 9

Tournament tree

¯ S := 2⌈lg S⌉

1

  • 2
  • 4
  • 5
  • 8
  • 9
  • 10
  • 11
  • · · ·

1 2 3

invariant: index to the min inside the buckets covered ¯ S buckets

N/¯

S

elements per bucket

# bits: about 2¯ S · lg N; a log factor too much

slide-10
SLIDE 10

procedure: path-update input: bucket-start: index of the beginning of the bucket changed

bucket-min: index of the minimum alive element within this bucket

data: N: number of elements ¯ S: workspace size rounded to a power of 2 A[0 . . N − 1]: read-only array of elements T[1 . . 2¯ S − 1]: array of indices from {none, 0, 1, . . . , N − 1}

current ← ¯

S + bucket-start/

N/¯

S

  • T[current] ← bucket-min

for ℓ ∈

lg ¯

S, lg ¯ S − 1, . . . , 1

:

parent ← ⌊current/2⌋ sibling ← if current mod 2 = 0: this + 1 else this − 1

if T[sibling] = none: T[parent] ← T[current] else if T[current] = none: T[parent] ← T[sibling] else if A[T[current]] < A[T[sibling]]: Reestablishing the invariants after a bucket gets a new min T[parent] ← T[current] else: T[parent] ← T[sibling]

current ← parent

slide-11
SLIDE 11

Operations

insert:

  • add the new element to the

last bucket

  • update

the min

  • f

that bucket, if necessary

  • run path-update for this bucket

worst-case running time: O

! lg ¯

S

insert improved:

  • divide the work of path-update

for

N/¯

S

insertions

extract:

  • find

the new min

  • f

the bucket where a change was made

  • run path-update for this bucket

worst-case running time: O

! N/¯

S + O

! lg ¯

S

slide-12
SLIDE 12

Navigation pile

1

001

2

01

4

1

5

1 · · ·

1 2 3

invariant: relative index of the bucket containing the min in the covered set ¯ S buckets

N/¯

S

elements per bucket

Bits stored in breadth-first order in a bit vector # bits:

¯ S 2 · 1 + ¯ S 4 · 2 + ¯ S 8 · 3 + . . . ≤ 2¯

S

update: O

! lg ¯

S · N/¯ S; a log factor too slow

slide-13
SLIDE 13

Quantile thinning

quantile size b/16 b/8 b/4 b/2 bucket | quantile

⌊i/8⌋

1010 | 1101

⌊i/4⌋

010 | 110

⌊i/2⌋

10 | 11

i

0 | 1 ¯ S buckets b :=

N/¯

S

elements per bucket

# bits: ≤ 4¯ S

slide-14
SLIDE 14

Running time per update

new bucket min: O

! N/¯

S

path-update: (1

2N/¯

S+O

! )+(1 4N/¯

S+O

! )+(1 8N/¯

S+O

! )+. . . ≤ O ! N/¯

S+O

! lg ¯

S

insert: O

! N/¯

S + O

! lg ¯

S; can be improved to O

! , if wanted

extract: O

! N/¯

S + O

! lg ¯

S

minimum: can be supported in O

!

worst-case time by maintaining a cursor to the overall min

slide-15
SLIDE 15

Remarks

slow! fun! application: In a word RAM, an adjustable navigation pile that uses O

! N/ lg N bits of extra space supports insert in O ! worst-case time

and extract-min in O

! lg N worst-case time involving at most O !

element moves.

  • pen: For almost any problem, the exact space-time trade-off is not

known in the restricted RAM model.

slide-16
SLIDE 16

Further reading

[Beame 1991] sorting lower bound [Pagter & Rauhe 1998] sorting upper bound [Sch¨

  • nhage et al. 1994] order notation

[Knuth 2011] Vol. 4A, bit manipulation, mentions navigation piles [Katajainen & Vitale 2003] original N-bit version [Asano et al. 2013] conference version [Darwish et al. 2015] journal version http://arxiv.org/abs/1510.07185 [Elmasry et al. 2014] selection [Elmasry et al. 2015] graph algorithms [Elmasry & Kammer 2015] geometric algorithms