Some notes on data structures used in search algorithms - - PowerPoint PPT Presentation

β–Ά
some notes on data structures used in search algorithms
SMART_READER_LITE
LIVE PREVIEW

Some notes on data structures used in search algorithms - - PowerPoint PPT Presentation

Some notes on data structures used in search algorithms Freitagsseminar Tobias Denkinger tobias.denkinger@tu-dresden.de Institute of Theoretical Computer Science Faculty of Computer Science Technische Universitt Dresden 2018-11-09 T.


slide-1
SLIDE 1

Some notes on data structures used in search algorithms

Freitagsseminar Tobias Denkinger

tobias.denkinger@tu-dresden.de Institute of Theoretical Computer Science Faculty of Computer Science Technische UniversitΓ€t Dresden

2018-11-09

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 1 / 9

slide-2
SLIDE 2

Outline

1

Pushdowns

2

Log-domain

3

Double-ended priority queues

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 2 / 9

slide-3
SLIDE 3

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-4
SLIDE 4

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-5
SLIDE 5

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-6
SLIDE 6

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-7
SLIDE 7

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-8
SLIDE 8

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-9
SLIDE 9

Pushdowns

Usage: e.g. in pushdown automata; represent backlinks in graph search Complexities: growable array (lazy) linked list pop, peek 𝒫(1) 𝒫(1) push 𝒫(1) (amortised1) 𝒫(1) clone 𝒫(π‘œ) 𝒫(1) examples vector (C++), List (Haskell), Vec (Rust) Pushdown (Rustomata)

  • 1R. E. Tarjan (Apr. 1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic Discrete

Methods 6.2, pp. 306–318. doi: 10.1137/0606031

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 3 / 9

slide-10
SLIDE 10

Pushdowns – Rustomata

Idea: share prefixes via pointer + copy on write

[cf. rustomata on github]

use algebraic data type (a.k.a. tagged union) Haskell:

data [a] = [] | a : [a]

  • - approximately

Rust:

10 pub enum Pushdown<A> { 11

Empty,

12

Cons {val: A, below: Rc<Pushdown<A>>},

13 }

current element is always unique

86

pub fn pop(self) -> Result<(Self, A), Self> {

87

match self {

88

Pushdown::Empty => Err(Pushdown::Empty ),

89

Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)),

90

}

91

}

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 4 / 9

slide-11
SLIDE 11

Pushdowns – Rustomata

Idea: share prefixes via pointer + copy on write

[cf. rustomata on github]

use algebraic data type (a.k.a. tagged union) Haskell:

data [a] = [] | a : [a]

  • - approximately

Rust:

10 pub enum Pushdown<A> { 11

Empty,

12

Cons {val: A, below: Rc<Pushdown<A>>},

13 }

current element is always unique

86

pub fn pop(self) -> Result<(Self, A), Self> {

87

match self {

88

Pushdown::Empty => Err(Pushdown::Empty ),

89

Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)),

90

}

91

}

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 4 / 9

slide-12
SLIDE 12

Pushdowns – Rustomata

Idea: share prefixes via pointer + copy on write

[cf. rustomata on github]

use algebraic data type (a.k.a. tagged union) Haskell:

data [a] = [] | a : [a]

  • - approximately

Rust:

10 pub enum Pushdown<A> { 11

Empty,

12

Cons {val: A, below: Rc<Pushdown<A>>},

13 }

current element is always unique

86

pub fn pop(self) -> Result<(Self, A), Self> {

87

match self {

88

Pushdown::Empty => Err(Pushdown::Empty ),

89

Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)),

90

}

91

}

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 4 / 9

slide-13
SLIDE 13

Log-domain

Usage: represent probabilities (especially small values) Idea: use bijection ln: ℝβ‰₯0 β†’ ℝ βˆͺ {∞}

[cf. rust-log-domain on github]

91 /// Same as β€˜newβ€˜, but without bounds check. 92 fn new_unchecked(value: F) -> Self { 93

LogDomain(value.ln())

94 }

use newtype to avoid runtime overhead (e.g. in Haskell and Rust)

70 pub struct LogDomain<F: Float>(F);

multiplication becomes addition ⟹ ln(β‹…) = (+)

216 fn mul(self, other: Self) -> Self { 217

LogDomain(self.ln().add(other.ln()))

218 }

What about ln(+)?

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 5 / 9

slide-14
SLIDE 14

Log-domain

Usage: represent probabilities (especially small values) Idea: use bijection ln: ℝβ‰₯0 β†’ ℝ βˆͺ {∞}

[cf. rust-log-domain on github]

91 /// Same as β€˜newβ€˜, but without bounds check. 92 fn new_unchecked(value: F) -> Self { 93

LogDomain(value.ln())

94 }

use newtype to avoid runtime overhead (e.g. in Haskell and Rust)

70 pub struct LogDomain<F: Float>(F);

multiplication becomes addition ⟹ ln(β‹…) = (+)

216 fn mul(self, other: Self) -> Self { 217

LogDomain(self.ln().add(other.ln()))

218 }

What about ln(+)?

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 5 / 9

slide-15
SLIDE 15

Log-domain

Usage: represent probabilities (especially small values) Idea: use bijection ln: ℝβ‰₯0 β†’ ℝ βˆͺ {∞}

[cf. rust-log-domain on github]

91 /// Same as β€˜newβ€˜, but without bounds check. 92 fn new_unchecked(value: F) -> Self { 93

LogDomain(value.ln())

94 }

use newtype to avoid runtime overhead (e.g. in Haskell and Rust)

70 pub struct LogDomain<F: Float>(F);

multiplication becomes addition ⟹ ln(β‹…) = (+)

216 fn mul(self, other: Self) -> Self { 217

LogDomain(self.ln().add(other.ln()))

218 }

What about ln(+)?

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 5 / 9

slide-16
SLIDE 16

Log-domain

Usage: represent probabilities (especially small values) Idea: use bijection ln: ℝβ‰₯0 β†’ ℝ βˆͺ {∞}

[cf. rust-log-domain on github]

91 /// Same as β€˜newβ€˜, but without bounds check. 92 fn new_unchecked(value: F) -> Self { 93

LogDomain(value.ln())

94 }

use newtype to avoid runtime overhead (e.g. in Haskell and Rust)

70 pub struct LogDomain<F: Float>(F);

multiplication becomes addition ⟹ ln(β‹…) = (+)

216 fn mul(self, other: Self) -> Self { 217

LogDomain(self.ln().add(other.ln()))

218 }

What about ln(+)?

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 5 / 9

slide-17
SLIDE 17

Log-domain

Usage: represent probabilities (especially small values) Idea: use bijection ln: ℝβ‰₯0 β†’ ℝ βˆͺ {∞}

[cf. rust-log-domain on github]

91 /// Same as β€˜newβ€˜, but without bounds check. 92 fn new_unchecked(value: F) -> Self { 93

LogDomain(value.ln())

94 }

use newtype to avoid runtime overhead (e.g. in Haskell and Rust)

70 pub struct LogDomain<F: Float>(F);

multiplication becomes addition ⟹ ln(β‹…) = (+)

216 fn mul(self, other: Self) -> Self { 217

LogDomain(self.ln().add(other.ln()))

218 }

What about ln(+)?

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 5 / 9

slide-18
SLIDE 18

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹…

exp(𝑧) exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-19
SLIDE 19

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-20
SLIDE 20

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-21
SLIDE 21

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-22
SLIDE 22

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-23
SLIDE 23

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-24
SLIDE 24

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-25
SLIDE 25

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-26
SLIDE 26

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-27
SLIDE 27

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-28
SLIDE 28

Log-domain – What about ln(+)?

determine 𝑨 s.t.

LogDomain(𝑨) = LogDomain(𝑦) + LogDomain(𝑧)

i.e.

exp(𝑨) = exp(𝑦) + exp(𝑧)

𝑨 = ln (exp(𝑦) + exp(𝑧)) (3 transcendentals) = ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧)

exp(𝑦))

= ln (exp(𝑦) + exp(𝑦) β‹… exp(𝑧 βˆ’ 𝑦)) = ln (exp(𝑦) β‹… (1 + exp(𝑧 βˆ’ 𝑦))) = 𝑦 + ln (1 + exp(𝑧 βˆ’ 𝑦)) = 𝑦 + ln_1p (exp(𝑧 βˆ’ 𝑦)) (2 transcendentals) implementation:

173 LogDomain(x + (y - x).exp().ln_1p())

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 6 / 9

slide-29
SLIDE 29

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-30
SLIDE 30

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-31
SLIDE 31

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-32
SLIDE 32

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-33
SLIDE 33

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-34
SLIDE 34

Double-ended priority queues

Usage: e.g. beam search Complexities:

[cf. Atkinson, Sack, Santoro, and Strothotue 1986] min-heap balanced search tree min-max-heap enqueue 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMin 𝒫(1) 𝒫(log π‘œ) 𝒫(1) dequeueMin 𝒫(log π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ) peekMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(1) dequeueMax 𝒫(π‘œ) 𝒫(log π‘œ) 𝒫(log π‘œ)

Idea: shufgle a max-heap into a min-heap

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 7 / 9

slide-35
SLIDE 35

Double-ended priority queues – min-max-heap

data structure: 5 65 25 57 36 37 45 59 80 8 20 14 15 32 18 max-level2 min-level2 max-level1 min-level1 Hasse diagram: 5 25 57 36 37 45 59 8 20 14 15 32 18 65 80 max-level2 min-level2 max-level1 min-level1

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 8 / 9

slide-36
SLIDE 36

Double-ended priority queues – min-max-heap

data structure: 5 65 25 57 36 37 45 59 80 8 20 14 15 32 18 max-level2 min-level2 max-level1 min-level1 Hasse diagram: 5 25 57 36 37 45 59 8 20 14 15 32 18 65 80 max-level2 min-level2 max-level1 min-level1

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 8 / 9

slide-37
SLIDE 37

References

  • M. D. Atkinson, J.-R. Sack, B. Santoro, and T. Strothotue (1986). β€œMin-max heaps and

generalized priority queues”. Communications of the ACM. doi: 10.1145/6617.6621.

  • D. H. Larkin, S. Sen, and R. E. Tarjan (2013). β€œA Back-to-Basics Empirical Study of

Priority Qveues”. doi: 10.1137/1.9781611973198.7. Professur GDP (2018a). Log-domain in Rust (referenced version). url:

https://github.com/tud-fop/rust-log- domain/blob/9568c5b7db6992fc11151829f236bc91337b182a/src/lib.rs.

Professur GDP (2018b). Pushdowns in rustomata (referenced version). url:

https://github.com/tud-fop/rustomata/blob/ d8cb2798688ea1345735b08236441097e0757788/src/util/push_down.rs.

  • R. E. Tarjan (1985). β€œAmortized Computational Complexity”. SIAM Journal on Algebraic

Discrete Methods. doi: 10.1137/0606031.

  • T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar)

2018-11-09 9 / 9