Questions tagged [data-structures]
Questions regarding efficient storage and representation of data within a software application.
892
questions
0
votes
1
answer
138
views
Tagged pointers vs. fat pointers
I'm writing my own dynamic programming language. So far I've been using a tagged union for all values. Since this boxes primitive types needlessly, I've begun researching tagged pointers which seem to ...
-1
votes
0
answers
69
views
What is the Big O notation of modifying an existing element in a heap data structure?
Wikipedia says "increase key" is O(log n) for a binary heap, but it is referring to an internal function. I'm not asking about that: Imagine the data structure had an external/public ...
1
vote
1
answer
101
views
Unordered Map with indexing and range based loops [closed]
I am creating a C++ library (more of a passion project to be honest). Its aim is to enhance the existing unordered_map STL by giving it indexing abilities and range-based loops, based on the order of ...
1
vote
1
answer
137
views
High Throughput Concurrent Map Access and Periodic Updates Causing Contention and Latency Spikes
I am working on a Go application where two concurrent maps, products and productCatalog, are accessed by numerous threads in live traffic to retrieve data at high throughput. These maps are populated ...
10
votes
6
answers
3k
views
How to ensure data consistency in system with multiple databases?
Let's say, in a rather big application suite with multiple more or less integrated products, data is stored across multiple databases. Some of them are SQL-ish DB clusters, some are MongoDB clusters.
...
0
votes
1
answer
121
views
C++ creating a class with self referencing custom comparator [closed]
This is the node for a tree
class Node {
public:
string name;
map<string, string> attribute;
Node* parent;
set<Node*, customComparison> children;
};
Where customComparison in ...
-1
votes
1
answer
201
views
What is the best way to store a recursive data structure? [closed]
What is the best way to store a recursive data structure in a program? (in C++)
I'm reading data from file, and want to keep it in memory while I validate the data and the user can manipulate it. It ...
0
votes
1
answer
113
views
Why is `WeakSet` great for tracking circular references?
In MDN article on WeakSets, an example is given for using weak sets to avoid infinite recursion on circular references:
// Execute a callback on everything stored inside an object
function ...
6
votes
2
answers
410
views
Object immutability and persistence
While I was learning functional programming I have encounterd two for me very similar terms: immutability and persistence. Also I have read simular questions from stackoverflow, but I am still ...
0
votes
0
answers
33
views
Is there any reason to namespace structure members in C?
In C, such as in many POSIX structures, the structure members are prefixed with an abbreviated version of the structure such as:
struct passwd {
char *pw_name;
char *pw_passwd;
uid_t ...
0
votes
2
answers
81
views
How do I control many datasets that are related and can change independently?
Background: I'm a scientist working with a small team on data analytics. No one on our team has any experience with software engineering, though I'm trying to change that.
Suppose I have an array A ...
0
votes
1
answer
149
views
Trie data for searches in time ranges
I am developing an API responsible for returning the distinct searches made on a service given a date prefix.
Example data:
2015-08-01 00:00:18 %22http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%...
0
votes
1
answer
252
views
How is it possible to store the AST nodes location in the source code?
I created a simple parser in Rust and defined the AST like this:
enum Expression {
Number(i32),
BinaryOperator(Box<Expression>, Operator, Box<Expression>),
Identifier(String),
}...
-2
votes
1
answer
60
views
Assigning Relationships between various objects in a collection
Similarly to a sports team chemistry or even a better example would be fifa ultimate team chemistry where putting certain players in the team would improve the team's overall chemistry
Say there are ...
0
votes
1
answer
156
views
Are self-written queues and linked lists really worth it (better than built-in arrays)?
Let's say I need a queue for my project and the language I use does not have a built-in queue structure. So I decided to implement one myself.
So I create an object with elements positions as the ...
0
votes
2
answers
324
views
How to create an interface in C that can work on two identical structs with differently named fields
Question Background
Consider a scenario in which I have two structs. Both consist of three fields for doubles. The only difference is the names used to refer to these fields. The first struct is for ...
0
votes
1
answer
89
views
How is model reconstructed with event sourcing in CQRS principle?
I'm trying to understand the CQRS design.
As far as I know now, every time a change to a model is saved, the (state) change is stored as a separate record.
When reading a model, the model is ...
-3
votes
1
answer
501
views
What's the right data structure to combine iteration of key-value pairs, and iteration of values
I'm looking for a pre-existing or easy-to-build data structure available in Java, which can do these 2 things efficiently:
Fetch all the values stored in the collection quickly.
Iterate over the data ...
13
votes
2
answers
3k
views
Is there a common term for a fixed-length, fifo, "push through" array or list?
Here's a ubiquitous data structure in, say, game and UX programming:
there're a fixed number of items (say, "5")
they're all "zero" to begin with
you can put one in on the "...
-1
votes
1
answer
33
views
How to model multiple requirement scenario
I want to store and analyze university course requirements. Lets say, students to register for ABC123 course following requirements should satisfy.
Must pass CBA321
Should be taken with XYZ123
Must ...
3
votes
4
answers
500
views
Iterating through stacks and queues?
Are stacks and queues allowed to be iterated over, conceptually?
It “feels wrong” for some reason but I can't come up with a reason why it would be bad to see through the whole thing that's stacked/...
2
votes
3
answers
197
views
Eliminating combinations based on user input
I am stuck with this particular problem. To give context to the problem, I am developing a mobile app which helps with loading dangerous goods onto a truck. Ignore the size and weight of the dangerous ...
3
votes
3
answers
224
views
What are the existing theories or methodologies around synchronizing tree structures?
I need to compare and synchronize two tree data structures.
I have Tree A (the "Reference Tree") and Tree B (the "Target Tree"). I need to bring the Target Tree into compliance ...
0
votes
1
answer
165
views
How is B-Tree used in DBMS-s if WHERE condition can be anything?
The most of the database management systems use B-tree as a data structure for increasing the performance.
Let's imagine that we have a table users with the following columns: id (int), name (string), ...
1
vote
1
answer
237
views
Best practise for designing REST API endpoint that accepts a nested resource POST
What's the recommended design for an endpoint that accepts a nested resource as the following:
POST /account
{
"name": "Project John Doe",
"description": "...
0
votes
0
answers
130
views
Is there a known algorithm for reducing a tree based on a list of its leaves?
For a given, tree-like data structure:
- Alan
- Barbara
- Charlie
- Cecil
- Brian
- Chris
- Candice
- Cohen
- Boromir
- Corcoran
-...
0
votes
1
answer
89
views
Help required in the right data structure for faster look up of data
I have the below given data model
itemid - name - collectionitemid
example:
itemid |name | collectionItemId
-------------------------------
101 | abc | null
102 | def | 101
103 | ghi | 101
...
1
vote
2
answers
820
views
Efficient data structure to index a collection of unique values shared among objects
I have a collection of many millions of objects, each with a unique id, each composed of tens to thousands of values. Values in this case are simply arrays of floats, with dimensions in the tens to a ...
55
votes
7
answers
11k
views
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:...
0
votes
1
answer
1k
views
Why is there no Hashmap in C++ like Java? [closed]
I know that the C++ standard library includes the ordered and the unordered map (std::map and std::unordered_map) containers, but why is there no hashmap available on C++? I was asked this questions ...
1
vote
0
answers
337
views
Design MySQL database to store user workout data for Workout App
I am building a fitness app and I'm trying to figure out the optimal way to store the data is a MySQL database.
I would like to have specific programs (for example, 'get jacked'), I would like a users ...
0
votes
1
answer
85
views
Data Class: spread boilerplate for each different database over multiple class copies, or add complexity to original class?
I'm creating a prototype mobile app that will store data locally in an sqLite database and also on the cloud (CloudKit for now). The cloud storage uses a certain way of storing the data, and sqlite ...
0
votes
0
answers
43
views
Query for each doucment or include IDs in document itself and query for all documents with ID?
I am working on a project where there will be different kinds of accounts that use Auth0 for auth and authz. I want to have it so that an account will query my backend to get back documents that ...
-1
votes
1
answer
201
views
A data structure / algorithm to combine search tree and hash table?
I have a two dimensional data with one dimension is ordered and another one is categorical, for example, country and city_age:
country
age
city
Italy
2773
Rome
Germany
784
Berlin
USA
397
New York
...
1
vote
3
answers
394
views
What makes a data pipeline scalable? Best practices for scalable design?
I have been searching about this topic for a few days and have not yet found anything on books, courses or tutorials.
What is a way to make data pipelines more scalable, that doesn't involve NoSql or ...
4
votes
1
answer
957
views
Text adventure game: is there a more elegant way to store data & control logic?
so for the past several months, I've been working on a personal project. It's a comically large, highly open, handcrafted text adventure game packed with inside jokes and fun little surprises for my ...
2
votes
1
answer
251
views
Should a data class manipulate its input?
Background
I'm a scientist and trying to incorporate better software development practices in my work. In my niche field there's a standard model everyone uses that accepts a whopping 56 arguments. I'...
-1
votes
1
answer
326
views
Best way to store and fetch image bytes?
I have a case in my startup where I need to fetch images in bytes as fast as possible.
At the moment I'm storing the images in Azure Storage then I fetch them on the run and cache them into my ...
0
votes
2
answers
80
views
Restructuring a “processing slip” like object used in many steps
I have worked on a library which processed data through multiple steps. It was written in R, a dynamic programming language where one could just add fields to existing “objects”, which were just ...
4
votes
1
answer
797
views
What is the most suitable data structure for IPv4 addresses with intersecting ranges?
Mostly in all routers and operating systems the Longest Prefix Match algorithm is used for searching the trie of IPv4 addresses.
Packet filters like Iptables don't need some special data structure for ...
2
votes
2
answers
90
views
Do calculations based off of already-included fields belong in a data-structure?
Say I have the following data-structure describing a given widget sold by my company, which contains fields of purely atomic information (i.e. data that cannot be otherwise derived from other ...
1
vote
2
answers
478
views
Can you create a hash table made of binary trees?
For instance, if you have a hash table with the array of buckets 26 nodes long, one for each letter of the alphabet. You use that to keep track of names. So when a name "Jed" is added to the ...
-1
votes
1
answer
312
views
search message in a conversation like messenger
I want to implement a search feature in my chat application like a messenger, skype, whatsapp has done. What they have done is when we search a word then it would not only show the message with that ...
2
votes
1
answer
200
views
Implementing a persistent searchable "queue"
I'm receiving a lot of a data entries from different (IOT) devices. I need to temporarily and persistently store this data until it is polled by the matching clients, after which it will be deleted.
...
0
votes
2
answers
924
views
About layered architecture and the persistence layer
I’m pretty sure I’ve made some wrong assumptions in my questions so bear that in mind.
At some point, the methods inside objects that are part of the persistence layer will be called/accessed for say… ...
1
vote
4
answers
341
views
Thinking about data as object vs table row [closed]
It often happens that we have a set of structured data. Let's say our data is about charitable organizations. I could turn it into a list/set of objects/structs:
struct Charity {
let name: String
...
-1
votes
3
answers
266
views
Design pattern for creating and scheduling tests/exams
I have an Exam class that represents an examination/test:
public class Exam
{
public int Id { get; set; }
[Required]
[StringLength(maximumLength: 30, MinimumLength = 1]
public string ...
0
votes
1
answer
394
views
How can I represent a graph for a visual programming language in JSON?
I am in the process of implementing a visual programming language similar to Blender's node editor or Unreal Engine Blueprints. It will be implemented as a SPA that will communicate with a JSON based ...
1
vote
2
answers
445
views
Efficient set method in run length encoded C++ map
I have been designing a C++ class that maps an integer to an integer using a vector. Because there is a lot of repetitive data (for example 11115555666222), I am using a compression scheme where I am ...
0
votes
1
answer
55
views
Best data structure for searching best color match? (4D space)
My current color distance formula is a modified version of Euclidian distance (eDist) because with eDist I was noticing weird issues where blue could be used instead of green in some situations when ...