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
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
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns 𝒫(1) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) Methods 6.2, pp. 306–318. doi: 10.1137/0606031 1 R. E. Tarjan (Apr. 1985). “Amortized Computational Complexity”. SIAM Journal on Algebraic Discrete Pushdown (Rustomata) Vec (Rust) List (Haskell), vector (C++), examples 𝒫(𝑜) Usage: e.g. in pushdown automata; represent backlinks in graph search clone 𝒫(1) 𝒫(1) (amortised 1 ) push 𝒫(1) 𝒫(1) pop, peek (lazy) linked list growable array Complexities: 3 / 9
Pushdowns – Rustomata pub fn pop(self) -> Result<(Self, A), Self> { 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) } 91 } 90 Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)), 89 ), => Err(Pushdown::Empty Pushdown::Empty 88 match self { 87 86 Idea: share prefixes via pointer + copy on write -- approximately [cf. rustomata on github] use algebraic data type (a.k.a. tagged union) Haskell: data [a] = [] | a : [a] Rust: current element is always unique 10 pub enum Pushdown<A> { 11 Empty, 12 Cons {val: A, below: Rc<Pushdown<A>>}, 13 } 4 / 9
Pushdowns – Rustomata pub fn pop(self) -> Result<(Self, A), Self> { 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) } 91 } 90 Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)), 89 ), => Err(Pushdown::Empty Pushdown::Empty 88 match self { 87 86 Idea: share prefixes via pointer + copy on write -- approximately [cf. rustomata on github] use algebraic data type (a.k.a. tagged union) Haskell: data [a] = [] | a : [a] Rust: current element is always unique 10 pub enum Pushdown<A> { 11 Empty, 12 Cons {val: A, below: Rc<Pushdown<A>>}, 13 } 4 / 9
Pushdowns – Rustomata pub fn pop(self) -> Result<(Self, A), Self> { 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) } 91 } 90 Pushdown::Cons{val,below} => Ok((below.deref().clone(), val)), 89 ), => Err(Pushdown::Empty Pushdown::Empty 88 match self { 87 86 Idea: share prefixes via pointer + copy on write -- approximately [cf. rustomata on github] use algebraic data type (a.k.a. tagged union) Haskell: data [a] = [] | a : [a] Rust: current element is always unique 10 pub enum Pushdown<A> { 11 Empty, 12 Cons {val: A, below: Rc<Pushdown<A>>}, 13 } 4 / 9
Idea: use bijection ln : ℝ ≥0 → ℝ ∪ {∞} Log-domain multiplication becomes addition ⟹ ln (⋅) = (+) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) What about ln (+) ? 218 } LogDomain(self.ln().add(other.ln())) 217 216 fn mul(self, other: Self) -> Self { 70 pub struct LogDomain<F: Float>(F); Usage: represent probabilities (especially small values) use newtype to avoid runtime overhead (e.g. in Haskell and Rust) 94 } LogDomain(value.ln()) 93 92 fn new_unchecked(value: F) -> Self { 91 /// Same as ‘new‘, but without bounds check. [cf. rust-log-domain on github] 5 / 9
Log-domain multiplication becomes addition ⟹ ln (⋅) = (+) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) What about ln (+) ? 218 } LogDomain(self.ln().add(other.ln())) 217 216 fn mul(self, other: Self) -> Self { 70 pub struct LogDomain<F: Float>(F); Usage: represent probabilities (especially small values) use newtype to avoid runtime overhead (e.g. in Haskell and Rust) 94 } LogDomain(value.ln()) 93 92 fn new_unchecked(value: F) -> Self { 91 /// Same as ‘new‘, but without bounds check. [cf. rust-log-domain on github] 5 / 9 Idea: use bijection ln : ℝ ≥0 → ℝ ∪ {∞}
Log-domain multiplication becomes addition ⟹ ln (⋅) = (+) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) What about ln (+) ? 218 } LogDomain(self.ln().add(other.ln())) 217 216 fn mul(self, other: Self) -> Self { 70 pub struct LogDomain<F: Float>(F); Usage: represent probabilities (especially small values) use newtype to avoid runtime overhead (e.g. in Haskell and Rust) 94 } LogDomain(value.ln()) 93 92 fn new_unchecked(value: F) -> Self { 91 /// Same as ‘new‘, but without bounds check. [cf. rust-log-domain on github] 5 / 9 Idea: use bijection ln : ℝ ≥0 → ℝ ∪ {∞}
Log-domain multiplication becomes addition ⟹ ln (⋅) = (+) 2018-11-09 T. Denkinger: Some notes on data structures used in search algorithms (Freitagsseminar) What about ln (+) ? 218 } LogDomain(self.ln().add(other.ln())) 217 216 fn mul(self, other: Self) -> Self { 70 pub struct LogDomain<F: Float>(F); Usage: represent probabilities (especially small values) use newtype to avoid runtime overhead (e.g. in Haskell and Rust) 94 } LogDomain(value.ln()) 93 92 fn new_unchecked(value: F) -> Self { 91 /// Same as ‘new‘, but without bounds check. [cf. rust-log-domain on github] 5 / 9 Idea: use bijection ln : ℝ ≥0 → ℝ ∪ {∞}
Recommend
More recommend