Questions tagged [data-structures]

Questions regarding efficient storage and representation of data within a software application.

In computer science, a data structure is a data organization and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.

Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks. For example, relational databases commonly use B-tree indexes for data retrieval, while compiler implementations usually use hash tables to look up identifiers.

Data structures provide a means to manage large amounts of data efficiently for uses such as large databases and internet indexing services. Usually, efficient data structures are key to designing efficient algorithms.

Below is a list of some of the data structures and their variants:

  • Dynamic arrays
  • Linked lists
  • Hash tables
  • Binary trees
  • Priority queues
  • Radix trees
  • Multiway trees
  • Geometric trees
  • Geometric structures
  • Network connectivity structures
  • Graphs

References:

900 questions
60
votes
11 answers

How to represent a Rubik's Cube in a data structure

If I am attempting to simulate a Rubik's Cube, how would you create a data structure to store the cube's state in memory, with X number of tiles per side? Things to consider: the cube can be of any size it is a Rubik's cube, so layers can be…
Mel
  • 1,121
46
votes
4 answers

Difference between a heap and a priority queue

I always thought that heaps and priority queues were synonyms - an abstract data structure that supports the insert, findMin and deleteMin operations. Some literature seems to agree with me - Chris Okasaki's Purely Functional Data Structures…
Nicolas Rinaudo
  • 824
  • 1
  • 7
  • 11
25
votes
2 answers

Where would I typically use a Deque in production software?

I'm fairly familiar with where to use Stacks, Queues, and Trees in software applications but I've never used a Deque (Double Ended Queue) before. Where would I typically encounter them in the wild? Would it be in the same places as a Queue but with…
user28988
18
votes
11 answers

What is the most complicated data structure you have used in a practical situation?

The germ for this question came up from a discussion I was having with couple of fellow developers from the industry. Turns out that in a lot of places project managers are wary about complex data structures, and generally insist on whatever exists…
Fanatic23
  • 7,493
18
votes
1 answer

How does a skip list work?

For a homework assignment, I need to understand how a skip list works. I've been programming for a little over 2 years now (I know that's not that long in reality), and I have never even heard of a skip list. I've looked over all of the guides…
18
votes
8 answers

What's the difference between a stream and a queue?

What's the difference between a stream and a queue? They both have the concept of an ordered set of elements, but tend to have different implementations and a different vocabulary of 'insert'/'extract' (streams) vs. 'enqueue'/'dequeue' (queue). …
elliot42
  • 871
17
votes
2 answers

Are bloom filters actually faster than hashes, even taking in account cache?

Bloom filters look really great when you consider you can determine if an Int is in a set with 99% certainty in constant time. But so can hashes, with the only difference that, in a hash, most of the time you are accessing the memory only once. With…
MaiaVictor
  • 5,830
17
votes
2 answers

What is the canonical reference on probabilistic data structures?

I've heard of probabilistic data structures like Skip Lists and Bloom Filters being immensely useful and I'd like to learn more about them in general. Is there a canonical reference on the subject on the level of Cormen et al.?
user28988
14
votes
2 answers

What is the most space efficient way to implement a graph data structure?

I typically implement graphs as doubly linked lists but this is fairly space inefficient in my experience as I need k pointers/references for k neighbors so for an undirected graph I'd have ~2k neighbor links within the lists if my math is right. Is…
user28988
12
votes
4 answers

Are trees organised by a "firstchild, nextsibling" structure? If not, why not?

Usually, tree data structures are organised in a way that each node contains pointers to all its children. +-----------------------------------------+ | root | | child1 child2 …
user281377
  • 28,382
11
votes
2 answers

What data structure would you use to represent an organic compound?

Are there any good data structures out there that can be used to represent a molecule? I was thinking maybe I represent it as a Graph by making every atom a vertex, however, it's common for organic compounds to have lots of Carbons and Hydrogens.…
6
votes
4 answers

Is there a way to track data structure dependencies from the database, through the tiers, all the way out to a web page?

When we design applications, we generally end up with the same tiered sets of data structures: A persistent data structure that is described using DDL and implemented as RDBMS tables and columns. A set of domain objects that consist primarily of…
Sean Mickey
  • 301
  • 1
  • 7
6
votes
4 answers

Understanding the Macro Aspects of Data Structures

I am studying data structures right now, but I still need to find a teacher/site/book with a clear explanation of the macro aspects of this topic. What I mean is: most lessons/text books mix everything together, with no logical structure. They start…
5
votes
1 answer

Use dictionary value property as the dictionary key

I am creating an AST, and I am currently introducing the concept of "scope". By implementing a scope, wherever an identifier (variable name) is used, I am able to determine its original declaration. For the scope object, I was going to implement a…
4
votes
3 answers

Picking powers of two for sizes/limits

A habit I've observed among programmers, and a habit I sometimes subconsciously exhibit myself, is to pick powers of two (or powers of two minus one) when defining a database schema, a data buffer, etc. Have you made the same observation? If I'm not…
Ates Goral
  • 1,090
1
2 3 4