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:

886 questions
105
votes
15 answers

Why are data structures so important in interviews?

I must confess that I was not so strong in data structures when I graduated out of college. Throughout the campus placements during my graduation, I've witnessed that most of the biggie tech companies like Amazon, Microsoft etc focused mainly on…
Vamsi Emani
  • 1,745
  • 7
  • 21
  • 21
86
votes
7 answers

EAV - is it really bad in all scenarios?

I'm thinking to use an entity-attribute-value (EAV) model for some of the stuff in one of the projects, but all questions about it in Stack Overflow end up to answers calling EAV an anti-pattern. But I'm wondering if it is that wrong in all…
Giedrius
  • 1,304
  • 1
  • 10
  • 15
76
votes
3 answers

Sets Data Structure in Golang

I really like google golang but could some one explain what the rationale is for the implementors having left out a basic data structure such as sets from the standard library?
cobie
  • 3,237
  • 5
  • 23
  • 21
76
votes
7 answers

Configuration data: single-row table vs. name-value-pair table

Let's say you write an application that can be configured by the user. For storing this "configuration data" into a database, two patterns are commonly used. The single-row table CompanyName | StartFullScreen | RefreshSeconds | …
Heinzi
  • 9,646
  • 3
  • 46
  • 59
69
votes
4 answers

Which algorithms/data structures should I "recognize" and know by name?

I'd like to consider myself a fairly experienced programmer. I've been programming for over 5 years now. My weak point though is terminology. I'm self-taught, so while I know how to program, I don't know some of the more formal aspects of computer…
Earlz
  • 22,658
  • 7
  • 46
  • 60
62
votes
1 answer

Treating a 1D data structure as 2D grid

I am working with a native class that represents a 2D image as a 1D array. If you want to change one pixel, for example, you need to now how to derive the index from the x,y coordinates. So, let's say we have a 1D array array1d like this: array1d =…
GladstoneKeep
  • 2,629
  • 4
  • 19
  • 15
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
  • 4
  • 12
  • 14
58
votes
16 answers

How should I store "unknown" and "missing" values in a variable, while still retaining the difference between "unknown" and "missing"?

Consider this an "academic" question. I have been wondering about about avoiding NULLs from time to time and this is an example where I can't come up with a satisfactory solution. Let's assume I store measurements where on occasions the measurement…
exhuma
  • 1,191
  • 1
  • 10
  • 16
58
votes
6 answers

Why do many functions that return structures in C, actually return pointers to structures?

What is the advantage of returning a pointer to a structure as opposed to returning the whole structure in the return statement of the function? I am talking about functions like fopen and other low level functions but probably there are higher…
yoyo_fun
  • 2,267
  • 3
  • 17
  • 22
56
votes
4 answers

Why is using MySQL for a dictionary website a bad idea?

I'm planning to design and set up a database to store dictionary entries (usually single words) and their meaning in another language. So, for example, the table Glossary must have entry and definition and each table record has a reference to the id…
55
votes
7 answers

Why do so many standards for JSON API response formats contain a "success" property in the response body instead of just using HTTP status codes?

I was researching about best practices for standardised JSON response formats for APIs, according to various sources available online general consensus looks something like this: //Successful request: { "success": true, "data": { /*…
53
votes
4 answers

What is the difference between a hash and a dictionary?

What is the difference between Hash and Dictionary? Coming from a scripting background, I feel that they are similar, but I wanted to find out the exact differences. Googling did not help me much.
Sairam
  • 641
  • 1
  • 5
  • 8
51
votes
4 answers

How exactly is an Abstract Syntax Tree created?

I think I understand the goal of an AST, and I've built a couple of tree structures before, but never an AST. I'm mostly confused because the nodes are text and not number, so I can't think of a nice way to input a token/string as I'm parsing some…
Howcan
  • 721
  • 2
  • 7
  • 7
48
votes
4 answers

Abstract Data Type and Data Structure

It's quite difficult for me to understand these terms. I searched on google and read a little on Wikipedia but I'm still not sure. I've determined so far that: Abstract Data Type is a definition of new type, describes its properties and…
user42183
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
  • 809
  • 1
  • 7
  • 11
1
2 3
59 60