Questions tagged [data-structures]

A data structure is a way of organizing data in a fashion that allows particular properties of that data to be queried and/or updated efficiently.

Data structures are ubiquitous in software. Hash tables, balanced trees, and dynamic arrays are essential building blocks for large, complicated systems and almost all programmers have encountered them at some point. More complicated structures like binary heaps can speed up complicated systems, while simpler concepts like stacks and queues make it possible to more elegantly and concisely encode algorithms.

Of course, this is just the tip of the iceberg when it comes to data structures. Theoreticians have been developing progressively better and better data structures over the past years, many of which are used extensively in modern software, and many are only useful from a theoretical perspective.

Data structures are closely related to algorithms. Often, a good choice of data structure can lead to a marked improvement in an algorithm's runtime. For example, Dijkstra's algorithm with a naive implementation of a priority queue runs in quadratic time, but with a fast Fibonacci heap can be shown to run in O(m + n lg n).

Below is a (not at all comprehensive) list of some of the more popular data structures and their variants:

  • Dynamic arrays
    • Dynamic table
    • Tiered vector
    • Hashed array tree
    • Extendible array
  • Linked lists
    • Singly-linked lists
    • Doubly-linked lists
    • XOR-linked lists
    • Skip lists
  • Hash tables
    • Chained hash tables
    • Linear probing hash tables
    • Quadratic probing hash tables
    • Double hash tables
    • Cuckoo hash tables
    • Perfect hash tables
    • Dynamic perfect hash tables
  • Binary trees
    • Red/black trees
    • Interval trees
    • Binary search trees
    • Segment trees
    • AVL trees
    • AA trees
    • Splay trees
    • Scapegoat trees
    • Treap
  • Priority queues
    • Binary heap
    • Binomial heap
    • Fibonacci heap
    • van Emde Boas tree
    • Skew binomial heap
    • Brodal queue
  • Radix trees
    • Trie
    • Patricia tree
    • Ternary search tree
  • Multiway trees
    • B tree
    • B+ tree
    • B* tree
  • Geometric trees
    • Quadtree
    • Octree
    • kd-Tree
    • BSP-tree
    • R-tree
  • Geometric structures
    • Winged-edge
    • Quadedge
  • Network connectivity structures
    • Disjoint-set forest
    • Link/cut tree
    • Top tree
  • Graphs
    • DAG
    • Directed graph
    • Undirected graph
    • Hypergraph

Links:

33477 questions
10
votes
4 answers

Programmatical approach in Java for file comparison

What would be the best approach to compare two hexadecimal file signatures against each other for similarities. More specifically, what I would like to do is to take the hexadecimal representation of an .exe file and compare it against a series of…
Carlos
  • 5,405
  • 21
  • 68
  • 114
10
votes
6 answers

In what circumstances lock free data structures are faster than lock based ones?

I'm currently reading C++ Concurrency in Action book by Anthony Williams and there are several lock free data structures implementations. In the forward of the chapter about lock free data structures in the book Anthony is writing: This brings us…
bobeff
  • 3,543
  • 3
  • 34
  • 62
10
votes
3 answers

What is the mathematical significance of "all (==1) [1,1..]" not terminating?

Intuitively, I would expect the "mathematical" answer to all (==1) [1,1..] to be True because all of the elements in a list that only contains 1s are equal to 1. However I understand that "computationally", the process of evaluating the infinite…
10
votes
2 answers

Disk-based trie?

I'm trying to build a Trie but on a mobile phone which has very limited memory capacity. I figured that it is probably best that the whole structure be stored on disk, and only loaded as necessary since I can tolerate a few disk reads. But, after a…
chakrit
  • 61,017
  • 25
  • 133
  • 162
10
votes
6 answers

C# Dictionary Memory Management

I have a Dictionary that has the potential to contain upwards of 10+ million unique keys. I am trying to reduce the amount of memory that this takes, while still maintaining the functionality of the dictionary. I had the idea of storing…
blogsdon
  • 125
  • 2
  • 8
10
votes
7 answers

C++: Sum of all node values of a binary tree

I'm preparing for a job interview. I was stuck at one of the binary tree questions: How can we calculate the sum of the values present in all the nodes of a binary tree?
csguy11
  • 5,007
  • 6
  • 22
  • 20
10
votes
7 answers

Least Recently Used cache using C++

I am trying to implement LRU Cache using C++ . I would like to know what is the best design for implementing them. I know LRU should provide find(), add an element and remove an element. The remove should remove the LRU element. what is the best…
brett
  • 5,379
  • 12
  • 43
  • 48
10
votes
2 answers

Accessing next element in Treeset in Java

Is there any way to access the successor or the predecessor of an element in Treeset of Java. Or is there any way of getting the iterator of a particular element so that we can use iterator.next() to get the next element.
kaushalpranav
  • 1,725
  • 24
  • 39
10
votes
5 answers

Binary Tree Transfer

How to transfer a binary tree (not a balanced tree) across two different systems efficiently, retaining its complete structure?
Avinash
  • 119
  • 1
  • 3
10
votes
4 answers

Many-to-many data structure in Python

I have a data set of books and authors, with a many-to-many relationship. There are about 10^6 books and 10^5 authors, with an average of 10 authors per book. I need to perform a series of operations on the data set, such as counting the number of…
GJ.
  • 5,226
  • 13
  • 59
  • 82
10
votes
1 answer

Heuristics for estimating the efficiency of Reduced Ordered Binary Decision Diagrams?

Reduced Ordered Binary Decision Diagrams (ROBDD) are an efficient data structure for boolean functions of multiple variables f(x1,x2,...,xn). I would like to get an intuition for how efficient they are. For instance, for data compression, we know…
10
votes
1 answer

Is it safe to use pointers as map keys in Go?

Suppose we add a value to a map using a pointer as the key. Could the memory address of this pointer ever change? If so, will looking it up in the map fail because when it was inserted, it had a different memory address?
skoush
  • 380
  • 2
  • 10
10
votes
1 answer

How do you formalize the numeric tower on functional languages?

Everyone knows the elegant way to express natural numbers on dependently typed functional languages: data Nat = Zero | Succ Nat Integer, Fraction, Real, Complex and Quaternion are, too, very important for practical programming application. One…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
10
votes
1 answer

Space-efficient probabilistic data structures for number retrieval

Consider we have an algorithm that receives a hypothetically long stream of keys. It then generates a value between 0 and 1 for each key, as we process it, for posterior retrieval. The input set is large enough that we can't afford to store one…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
10
votes
5 answers

What is size of my Bitset?

I want to store System.currentTimeInMillis in memory with minimum space possible. because I have to store millions of them in memory. I converted it to binaryString which gave me 41 bits Here is my program public class BitSetSize { public static…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
1 2 3
99
100