Questions tagged [persistent-data-structure]

A persistent data structure is a data structure that is never modified in place, but by creating a new data structure.

A persistent data structure is a data structure which is immutable: modifications of the data structure work by creating a new data structure (which typically shares most of its memory with the previous one).

Not to be confused with other meanings of the word “persistence”, such as serialization (marshalling).

19 questions
23
votes
4 answers

Why do we use persistent data structures in functional programming?

Functional programming employs persistent data structures and immutable objects. My question is why is it crucial to have such data structures here? I want to understand at a low level what would happen if the data structure is not persistent? Would…
21
votes
1 answer

What classes of data structures can be made persistent?

Persistent data structures are immutable data structures. Operations on them return a new "copy" of the data structure, but altered by the operation; the old data structure remains unchanged though. Efficiency is generally accomplished by sharing…
11
votes
2 answers

Array-like immutable (persistent) data structure implementation with fast indexing, append, prepend, iteration

I'm looking for a persistent data structure similar to array (but immutable), allowing for fast indexing, append, prepend, and iteration (good locality) operations. Clojure provides persistent Vector, but it's only for fast append. Scala's Vector…
6
votes
1 answer

What progress has been made on persistent catenable deques in the last decade?

I'm interested in persistent catenable deques: deques that can be concatenated. Kaplan and Tarjan came up with the first such data structure in 1995; Okasaki came up with a simpler, amortized version in 1997 using lazy evaluation (see Okasaki for…
5
votes
2 answers

Is it possible to build a heap from the root to the leaves?

Most books on data-structures will briefly introduce heaps (aka priority queues) and then move to describe the "trick" allowing heaps to be implemented as arrays. I've been looking for a way to implement a heap as an actual tree (call it pointers to…
wvxvw
  • 1,388
  • 9
  • 13
4
votes
1 answer

How do confluently persistent data structures handle merge conflicts?

From my limited understanding fully persistent data structures allow changes to be made to previous nodes, with new nodes creating a branch rooted at the changed node, resulting in a tree of nodes and also disallowing the remerging of these…
Bauhaus
  • 143
  • 4
4
votes
2 answers

How append, prepend, and generally insertAt work in RRB-tree

I read the paper about Relaxed Radix Balanced trees (RRB trees) and am trying to implement them. What I can't get is how insertion at an index should be performed step by step. Can anyone proficient in this data structure describe this procedure?
Tvaroh
  • 255
  • 2
  • 6
3
votes
0 answers

Persistent data structures representing a directed graph's paths

Are there any standard persistent data structures that facilitate the following? tabulating, for each arc in a rooted, oriented, acyclic multigraph, the set of root-emanating paths containing the arc keeping accurate tallies of path collections as…
Polytope
  • 113
  • 4
3
votes
2 answers

What is the "Chairman Tree"?

My competitive programming coach told me of a balanced binary tree used by a lot of Chinese competitors that has all the functions of any other balanced binary tree and is fully persistent and runs queries and updates in ${O(log^2N)}.$ What…
Jack Pan
  • 133
  • 5
3
votes
2 answers

Using persistence on a constant database

I'm quite new to understanding persistent data structures, so bear with me. Consider some database with data of the form $(\text{id}, d_1, d_2)$. The last two could e.g. mean production data and sales date, respectively. The database is constant,…
Eff
  • 219
  • 1
  • 9
3
votes
1 answer

Guessing the structure of a finger tree from the number of elements

I'm writing a data structure library, and I want to write an efficient algorithm for adding many elements to a finger tree (from an iterable sequence). I'm going to do this by constructing a finger tree from the sequence efficiently, as described…
3
votes
1 answer

Formal semantics of a mutable/imperative stack

When introducing formal semantics for data structures, immutable stacks are a nice simple example : $\mathit{is\_empty}(\mathit{create()})=\mathrm{True}$ $\mathit{is\_empty}(\mathit{push}(e, s))=\mathrm{False}$ $\mathit{top}(\mathit{push}(e, s)) =…
2
votes
0 answers

Distributed Computing: Persistent Data Structures in Functional Programming versus Wait-Free Data Structures

Persistent (aka immutable) data structures in functional programming sidestep issues of shared memory mutual exclusion, and thus also issues such as data races that arise and which may be difficult to debug. But persistence requires more memory…
2
votes
0 answers

Persistent data structure with double and subtract operations

I am seeking a data structure that maintains an array of N numbers and supports the following two operations: Double the first i numbers Subtract the first i numbers of a previous version from the current version. It always starts with an array…
sunny-lan
  • 121
  • 3
1
vote
0 answers

combine divergent persistent red-black tree instances

Given a persistent red-black tree, I've been searching for an algorithm, approach, or equivalent data structure that allows me to efficiently merge two instances of the tree produced by divergent modification of a common ancestor. For instance, tree…
1
2