MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / SqrtDecomposition

Struct SqrtDecomposition

sqrt/sqrtdecomposition.go:21–29  ·  view source on GitHub ↗

Sqrt (or Square Root) Decomposition is a technique used for query an array and perform updates Inside this package is described its most simple data structure, you can find more at: https://cp-algorithms.com/data_structures/sqrt_decomposition.html Formally, You can use SqrtDecomposition only if: G

Source from the content-addressed store, hash-verified

19// - (Only if you want use $update$ function)
20// $\forall n\in \N > 0, E_1,..., E_n\in E \\ query(E_1,...,E_{new},..., E_n)=updateQ(query(E_1,...,E_{old},...,E_n), indexof(E_{old}), E_{new})$
21type SqrtDecomposition[E any, Q any] struct {
22 querySingleElement func(element E) Q
23 unionQ func(q1 Q, q2 Q) Q
24 updateQ func(oldQ Q, oldE E, newE E) (newQ Q)
25
26 elements []E
27 blocks []Q
28 blockSize uint64
29}
30
31// Create a new SqrtDecomposition instance with the parameters as specified by SqrtDecomposition comment
32// Assumptions:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected