Questions tagged [data-structures]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
465 views

Which datastructure to use for temporary storage of intermittent and asynchronous sensor data?

Here an outline of the setup: Input data: I have several sources for sensor input data (GPS, and a bunch of other sensor data from different sources). All of those individual inputs consist of a ...
0
votes
1answer
114 views

Express unique recursive task system

I would like to express a task as either itself or a container for other tasks (recursively). The problem is that each task has to be one of two fundamental types: a goal or a routine. And, children ...
58
votes
16answers
13k views

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 ...
8
votes
2answers
5k views

How would you design a “multithreaded” LRU cache using C++ (unordered_map and Linkedlist)?

Please note that this is about a thread-safe LRU cache (not simply a LRU cache as specified in https://leetcode.com/problems/lru-cache/description/). It isn't a duplicate of LRU cache design question ...
1
vote
1answer
158 views

Find a string in list of strings

Background: I am writing an application for a small embedded device. There is a static list of strings: currently about 500 strings and string length is 12 characters on average. The list might ...
1
vote
3answers
1k views

how can i return the median of a threaded binary search tree in constant time?

I'm having a trouble with understanding how to implement and find the median of a threaded binary search tree in constant time. The tree consists of a worker's id and name. The given details are ...
18
votes
9answers
4k views

How is polymorphism used in the real world? [closed]

I am trying to understand how Polymorphism is used in a real life project, but I can only find the classical example (or something similar to it) of having an Animal parent class with a methodspeak(), ...
2
votes
1answer
384 views

Data Structure for "Intuitive" Text Matching

I've noticed that text editors and such have a more-than-prefix/suffix-based pattern matching algorithm going on behind the scenes. And StackOverflow's tag matching algorithm does more than just ...
0
votes
1answer
311 views

Limitations of Tries in Comparison to B-Trees for a Database

I am wondering about how range queries work, and the standard solution is to use B+trees. However, I am a fan of tries as a general data structure and would like to know if they (or variations of them)...
45
votes
8answers
13k views

Before OOP, were data structure members left public?

When a data structure (for example, a queue) is implemented using an OOP language, some members of the data structure need to be private (for example, the number of items in the queue). A queue can ...
1
vote
2answers
109 views

Should static and historical data be split in the API? To what extend?

The project is a read-only interface for a company database. In the database, there is some 'static' data about departments, in a Departments table. The value of these fields don't change with time (...
3
votes
2answers
565 views

Multiple data structures containing the same references

I was wondering what the best practice is for creating multiple different data structure which can all contain references to the same objects. As an example, consider a video game with many entities. ...
1
vote
1answer
212 views

Parnas' Paper on Modularization and Workflow Engines

In a Software Engineering class, we had an assignment to read Parnas' seminal paper on modularization [0]. In this paper, two approaches of dividing a software into modules are discussed: Traditional ...
1
vote
1answer
116 views

How to fetch data based on id from isolated code cleanest way?

I'm working on client-server application. Client architecture (class hierarchy) looks like this: System (name is of course different, more descriptive) - represents whole system Module A - a class ...
-1
votes
1answer
181 views

Is Tree the right data structure?

I must create a basic calendar of one year. I thought to use a generic Tree with the year like root, months as children of root, days as children of months etc... Is it the right way? I receive data ...
-3
votes
1answer
129 views

Determining MPG over a range of time using Dictionary and Class Objects

A group of friends are tracking the miles per gallon for each of their cars. Each time one of them fills up their gas tank, they record the following in a file: His or her name, The type of car they ...
3
votes
3answers
6k views

Advantages of using an array over a hash table?

I am wondering about the following question. To simulate an array via a hash table, one can simply set the keys of the hash table to be the indices of the array, and set the value of each key to be ...
1
vote
1answer
56 views

Flexable Table, or multiple tables?

In my application, I have many things that use images in different ways. For example, a product may have a logo and many screenshots, a user can have a profile image, and a company can have a logo. I ...
1
vote
2answers
212 views

Large matrix manipulation in multithreaded environment

I have: matrix 20*40000 of floats M - std::vector<std::vector<float>>; 1000 values X; ~2000000 POD structures S. A typical situation is: for each value from X I take several structs from ...
4
votes
3answers
1k views

Optimal way of storing sorted tree in memory

Wondering what the general structure is for storing a tree in memory most efficiently (for access operation, and space). For the access operation, it should take advantage of contiguous memory (...
10
votes
4answers
729 views

Good code style to introduce data checks everywhere?

I have a project that is sufficiently large in size that I can't keep every aspect in my head any more. I'm dealing with a number of classes and functions in it, and I'm passing data around. With ...
0
votes
1answer
50 views

Question about memory handling of trees and certain sorts on large data sets.

If data structures such as trees and certain sorts(quick sort, merge sort) work using recursive algorithms and recursive algorithms take up a lot of memory space in the stack and can only work on a ...
7
votes
2answers
633 views

FIFO Min-Max-Heap for Rolling Median

I'm working on a system with hard real-time constraints in c++ and I need a very fast way to calculate the rolling/moving/streaming median of a set of numbers of size N=100 to 300. Normally this size ...
1
vote
1answer
141 views

What is the most efficient way to represent resizable adjacecny matrix

I'm building a simple app that represents some matrix, where nodes are added quite often. Currently I have following code for adding a new node: let mut new_edges = Array2::default((position + 1, ...
1
vote
2answers
1k views

How is a quadtree stored in a file?

I'm trying to understand how a 2d or 3d map would be saved, and I'm trying to figure out quad trees. So like is each node represented by characters in a file and inside of that is the next one? What ...
-2
votes
1answer
407 views

Is Clojure a wrong choice for implementing Data Structures?

I am planning to improve my knowledge of Clojure and algorithms at the same time by implementing some known data structures in Clojure (e.g. linked lists, skip lists, bloom filter, etc.). However, I ...
1
vote
2answers
2k views

Storing a temporary data outside of DbContext in Entity Framework

I have a performance issue with a few methods in my Service Layer. Methods that are causing me troubles have some logic, but it's db connection that takes over 95% exec time. The problem is ...
8
votes
4answers
1k views

Web Applications REST API: Should the data be structured to meet the UI's requirements on the client or on the server?

For a web app I am working on I have a pretty basic relational database. I access this database through a RESTful API and generate the markup in React once the data is retrieved. If I find myself ...
0
votes
5answers
2k views

What is a good format to store a table of data

This is for one of my personal projects. I want to store a table of data in a BLOB/TEXT column in the database. I don't want to store the data in its own database table because the schema of this data ...
-3
votes
2answers
7k views

Why we use top== -1 for implementation of stack using simple array?

I am a newbie at data structures. I have read an implementation of a stack using a simple array. The algorithm for this implementation is presented below. Stack implementation in terms of an array ...
0
votes
2answers
127 views

Version checking when reading deeply nested structures

I need to open a game save file, read it, maybe modify it and then save it. The structure of the save is quite simple: it is an object with some members, some of which are data, while others are ...
1
vote
0answers
194 views

Best practice to handle input and output with several csv-like files

I am currently writing an application with the following structure: input: the equivalent of an excel workbook, i.e. a few tables with different headers and a few scalar values. They represent ...
0
votes
1answer
45 views

Journal Entries vs Entities - what should be the source of truth?

So, this is going to sound like an accounting question, and on top of that might be a little too opinion or discussion-based for Stack Exchange. But we've been going back and forth on this a little ...
4
votes
2answers
232 views

How should I name the fields in a class representing 2D and 3D sizes?

I'm working on a display library which in most cases works on a 2D plane but it has some components which display 2D projections of a 3D space. This domain has the notion of Position, Size, ...
0
votes
1answer
84 views

Server load/capacity based on data structure

Using PHP, I created a chatbox, and I used an unorthodox way of storing chat messages in MySQL. The tbl_chat_messages has the following columns: id | sender_id | receiver_id | message | date The ...
2
votes
2answers
172 views

Receive data in random order, send in order

I am facing an issue where I have a data stream that sends unordered data. I'm trying to find a way to receive the data in random order, but send it in order. As an example, I'll receive object4 and ...
10
votes
3answers
2k views

Is it good practice to wrap a related set of properties into its own struct/class?

Writing a User object in Swift, though my question relates to any strongly typed language. A User can have a bunch of links (FacebookProfile, InstagramProfile, etc). A few questions around this. Is ...
0
votes
0answers
61 views

Correct way-data structure for advertising peers in a p2p network

Underlying problem In a case of a peer-to-peer discovery protocol,suppose we need to advertise peers in a manner that the network graph will grow such that we avoid cases of both too dense areas (e.g ...
2
votes
1answer
371 views

Architecture for a scoring and commentary apps

About the app: This is an android app. The app has two components/ two different users, scorers who score the game and fans who view commentary of the game. Scoring User : A scorer watches a live ...
0
votes
1answer
809 views

Computing the shortest path in a labyrinth

I'm currently trying to map how to make a good algorithm that won't have issues to find the shortest path. The labyrinth consists of an X and Y dimensions as input; However, the labyrinth will ...
7
votes
1answer
3k views

How do I refactor a Data Class to not be one?

We recently upgrade to PMD 6.0.0 and are getting several classes flagged as "Data Classes"? It argues that it breaks encapsulation and makes for brittle design (I understand that this site has a ...
4
votes
2answers
127 views

Is there a name for a data structure/concept where certain regions of a data set are loaded?

At work I'm dealing with a situation where we have a large amount of time series data and need to display sections of it to the user at a time. The data essentially has an infinite number of records, ...
2
votes
1answer
414 views

What data structure is this?

Imagine I have a set of houses I want to sell and I want to present then on a website. The user should be able to filter the house they want by price, city, number of floors, area etc. However, I don'...
0
votes
3answers
2k views

If there would be no stack, would the 16 byte limit for structs still make sense?

From the official docs: AVOID defining a struct unless the type has all of the following characteristics: [...] It has an instance size under 16 bytes. [...] I know that one ...
1
vote
1answer
315 views

What is the best way to store message threads?

I'm integrating a messaging feature into an application written in Javascript and would like to know which is the preferred data structure of storing messages. The two structures I can think of so ...
5
votes
2answers
445 views

What are efficient algorithms for immutable dictionaries/sets? [closed]

What are efficient algorithms for immutable dictionaries/sets? By efficient I mean they either have better or comparable time and/or memory performance compared to their mutable versions. I don't ...
3
votes
4answers
102 views

Store csv data as rows or columns in view of the needed processing?

Assume I have some data a csv-Files like ObjectName, PropertyA, PropertyB, PropertyC "Name1", 3, 1, 4 "Name2", 1, 5, 9 "Name3", 2, 6, 5 ... and a typical question I want to answer would be For ...
1
vote
2answers
122 views

Database Modeling Question

I am having a doubt while creating a DB, and I would like to know if there are objective arguments that could help me mak a better decision. Case A project that can have several revisions, so I ...
5
votes
2answers
2k views

Why do many CMS use a database and not local files?

Most open source Content Management Systems use a database to store field data and then use files in the server's directory for config settings. Why is this model chosen so often and why would it not ...
3
votes
1answer
350 views

Data access design pattern

I've several cases where a single entity has multiple tables in the underlying database. When reading or writing I want to handle all of the DB queries with a single class for that object, e.g., the ...

1 2 3
4
5
18