Questions tagged [algorithms]
In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.
2,213 questions
1
vote
2
answers
87
views
Finding a subset of vertices in graph
I have a graph: undirected, unweighted, no leaves, no disconnected edges or vertices.
The graph is populated with vertices of 3 types: A, B, C.
Let's say, I hold a vertex of type A, denoted as A0.
I ...
-4
votes
2
answers
247
views
How to design a Transfer-Encoding: chunked parser of Uint8Array's in JavaScript? [closed]
I'm working on implementing parsing a series of Uint8Arrays that contain Transfer-Encoding: chunked data sent from the client using WHATWG Fetch over a single connection.
For example, writing 1 MB ...
0
votes
1
answer
158
views
Optimal way to avoid iterating through each row in a dictionary of data/arrays?
I have an excel macro that imports daily share price files, and finds the highest price for a share after a given date.
Each of these daily stock price files has ~1000 rows of data. Currently I have ...
1
vote
1
answer
232
views
Elegant solution to a graph problem
Given a line in a 2d coordinate system, we can create a dependency graph like this:
The black nodes represent a logical graph that is a-cyclic and therefore "stable" in the sense that if we ...
-2
votes
3
answers
354
views
What is beyond ordinary c++, when trying to optimize a function?
Backstory:
Writing a QImage to Sixel renderer.
Feel like I have optimized it the best I can using basic c++.
I have heard suggestions here or there that you can utilize things like GPU, SIMD, insert ...
1
vote
1
answer
152
views
Optimal way to match prioritized list of tasks with available workers
Problem
Match prioritized tasks with suitable workers.
Details
Consider a task with following properties - type and size. Based on task type, tasks are prioritized.
While a worker has following ...
1
vote
1
answer
192
views
Data structure for grouping strings in a collection when they share common substrings [closed]
I am looking for a data structure and an algorithm to manage a dynamic collection of strings, but grouping strings that have a substring in common. I try to describe it through an example.
@Christophe:...
0
votes
2
answers
429
views
How to translate points on a path relative to two other points?
I'm trying to make a curved line move relative to the movement of a straight line.
I'm thinking that I want the points on the curved line to keep their relative positions to the two points on the ...
-2
votes
1
answer
204
views
algorithm needed for historical backups
I back up important paths from my PC each day with an automated process that creates zip files. On the 20 terabyte drive I can have close to three years worth. Each weekend I make a VHDX backup of my ...
-1
votes
2
answers
106
views
Looking for clarification on the process of playing audio files [closed]
I've been working on a software project recently that's meant to include an audio player, and my plans for it definitely are to simply use an off-the-shelf player library, and go with that. However, ...
0
votes
0
answers
80
views
approximating a shape with a line
I have an image that has been converted to an svg.
The conversion looks fine, but it has prefered to use fill instead of stroke.
This in itself is not a bad thing in terms of converting a raster image ...
-1
votes
2
answers
146
views
Algorithm for realtime database listener replacement?
I have a time-series database where I put all my data in it in timely-ordered fashion. Unfortunately, the database doesn't have any realtime listener capability built into it, and I need to make an ...
0
votes
3
answers
197
views
Optimize reservation system algorithm
Im am developing a logistics application and at the moment, I try to solve the following problem:
In the system, there are multiple machines.
Each machine has one or more skills. For example, machine ...
2
votes
2
answers
589
views
Is this architecture overkill? What is a good way to architect this software?
I have an algorithm I am trying to implement that has steps 1 to 5. There are several different ways I could implement each step. Each calculation step is essentially just an astronomy calculation, ...
2
votes
1
answer
728
views
Algorithm for finding all combinations with constraints
I'm looking for a way in C# that finds all the possible combinations with constraints.
I've got a list of machines. The machines have capabilities and limitations. I also have a document that defines ...
1
vote
3
answers
255
views
Merge Sort Concept Understanding
Merge Sort contains basically two important routines:
(i) split
(ii) merge.
I get the general idea. But I dont understand how this is more efficient than some random bad sort algorithm, like selection ...
5
votes
9
answers
3k
views
Methods to increase the amount of data sent in a packet
I have been working on launching high-altitude balloons (HABs, or weather balloons) and I have been using LoRa to enable long-range communication with my balloons. It's been great and pretty reliable, ...
0
votes
0
answers
100
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 ...
0
votes
1
answer
231
views
Match making algorithm respecting players' choices
I am currently developing an application in Python that has a match making functionality to form sports teams of 4 and group them by skill. The following has been implemented and works.
E.g.
Form ...
0
votes
1
answer
110
views
What do you do with the hash code after running a word through the Double Metaphone algorithm used in fuzzy text search?
I found this Python code implementing Double Metaphone, and it basically has a bunch of if statements handling each letter, though I'm not exactly sure the decisions that went into each branch yet. ...
11
votes
4
answers
8k
views
Is there an algorithm for matchmaking?
I am interested to know if there is an existing algorithm to start a multiplayer game, for example, poker. What steps do we need to take when the player enters the "matchmaking phase"?
I ...
1
vote
2
answers
483
views
Most efficient mapping of pixel to colors with colormaps
I'm working on a module that handles colormaps and I want to make the mapping of pixel to colors as efficient as possible. It is a performance critical section of our app. Our current solution works ...
1
vote
2
answers
177
views
Culling edges from a triangulation while maintaining a connected graph?
I'm working on a small project and I'm randomly generating "world maps", with nodes you can fast travel to along given routes.
The basics of this aren't complicated; throw random points on a ...
1
vote
3
answers
489
views
What algorithm can I use in order to not let there be two rows with same "mobile number" in database?
The issue that I'm facing is on a banking app. There are two ways to register for internet banking.
A) Self Register
B) Ask for bank to register via their GUI panel backend.
Consider this scenario:
...
3
votes
2
answers
294
views
Moving chunks of text until they stop colliding
I'm working on a component that needs to draw chart-like structures like this:
One issue I have is when multiple values are too close with each other. Here's an illustration:
The last values for the ...
-1
votes
4
answers
737
views
Leetcode: 2327. Number of People Aware of a Secret and Problem with programming skill in general
On day 1, one person discovers a secret.
You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the ...
2
votes
3
answers
160
views
Please help with this maze of fencepost problems ( vector across window )
I'm trying to implement LOGO with a physical turtle. I got all the basics done, but I got completely sunk when implementing the "Window" mode.
Original LOGO had 3 modes: "Border" - ...
1
vote
0
answers
146
views
Ideal Profits in companies in Perfect Binary Search tree
I'm trying to solve the following problems here:
In the X world, companies have a hierarchical structure to form a large binary tree network (can be assumed to be a perfect binary tree). Thus every ...
3
votes
1
answer
508
views
Simulated Annealing
In relation to another question I had, I have been researching Simulated Annealing.
The general example used with this algorithm is the traveling salesman example. I have been testing the code ...
1
vote
3
answers
250
views
Graph layout positioning
Given a graph layout like the following image, where the layers/rows (y coordinate) and ordering of nodes within each layer have already been computed, what algorithm can I use to make it look "...
-1
votes
1
answer
187
views
Optimizing algorithm for categorizing pictures of Magic the Gathering Cards by type? [closed]
I'm making a piece of software that is able to recognize Magic the Gathering Cards from a picture or the actual camera.
The codebase scans for rectangular shapes (cards) in an image and calculates ...
-3
votes
3
answers
212
views
NP-complete problem (subset sum) featured in Netflix series "Suits" S1 E8? [closed]
In the Netflix series Suits, Season 1, Episode 8 (Identity Crisis), the legal team, with the help of a hacker, is tasked with proving that a business magnate embezzled funds, splitting them and ...
-3
votes
1
answer
299
views
How to find the shortest common superstring [closed]
Problem statement:
You are given an array of strings. Each element (string) of array is of size 2. You are supposed to find the length of shortest possible string such that every element of the array ...
6
votes
7
answers
7k
views
How to avoid repeating "a==b" when comparing "condition a" and then "condition b" and then...?
For example, I have an object:
public class Obj{
public int a;
public float b;
public String c;
}
I need to find best "Obj": largest a and then largest b and then longest c:
int ...
0
votes
3
answers
951
views
Mapping a range of values to a single value
So I have this problem where a specific ValuesA enum value is to be mapped to a respective ValuesB enum value, The trick is there can be multiple ValuesA mapping to a single ValuesB enum.
So for the ...
0
votes
1
answer
129
views
Monte Carlo Tree Search with Cops and Robber Game
I recently started trying to implement a monte carlo tree search based algorithm for playing cops and robber.
The game is based on the cops and robber game and is played on an arbitrary graph (not ...
0
votes
1
answer
131
views
Multi dimensional lookups
I am looking to see if there is a general design pattern or strategy to handle a use case I see often in our codebases. My best attempt to generalize this use case is "Map permutations of n ...
3
votes
1
answer
320
views
Algorithms: How do I sum O(n) and O(mlog(n)) together?
I'm doing a running time analysis using the aggregate method and I'm a bit confused about what would be the result in this case. I have some intuition in inferring that it would be O(mlog(n)) but I'm ...
-1
votes
2
answers
581
views
what algorithm does the malloc function in the c language standard library use? And why it so fast?
Based on the data structure of the AVL tree, I implemented a memory manager that does the best matching according to the size. I originally thought that the speed would be fast and the length of the ...
3
votes
2
answers
370
views
Efficient way to Decouple classes in class design
I am working on a class design question - design a simple grocery store with a self-checkout system
I am a beginner
After briefly jotting down requirements, I started with the Product class as follows ...
1
vote
1
answer
217
views
How do I narrow down a search space if symmetries are equivalent?
I have an algorithm that runs a search through every combination of a 5x5 grid where each cell can have 3 values, looking to see which combinations meet certain conditions. This gives 3^25 naive ...
2
votes
2
answers
586
views
Scheduling Algorithm that Maximizes Gaps Between Participants’ Appearances
I’m currently tackling a programming challenge to schedule a series of “performances” (a set of dancers together on a stage for a period of time, concretely) that each involve a set of “participants” (...
30
votes
7
answers
17k
views
How can lossless compression ever exist?
If all data is essentially just a bit string, then all data can be represented as a number. Because a compression algorithm, c(x), must reduce or keep the same length of the input, then the compressed ...
0
votes
1
answer
105
views
Generating grid shell coordinates
I need to generate grid shells for a given level. For example, the 2d grid "shell" at level 0 is just the cell (0,0).
The level 1 shell would be every cell surrounding (0,0), the level 2 ...
2
votes
1
answer
187
views
can partial optimized Bozosort improve speed of sorting?
First of all, I am serious :)
You have array of N elements and we can compare them (e.g. operator > works).
Let's try to (unstable) sort it using following brand new sorting algorithm.
First, ...
1
vote
4
answers
369
views
Most efficient way to represent a random ordering of the numbers 0-10
I am currently looking for a way to encode a list of random numbers most efficently (as in length).
To be specific, I have an array of 11 numbers containing each number from 0 to 10. The order will be ...
0
votes
1
answer
215
views
Many if conditions
I have the code but I want to be pseudo as possible so I learn from other ways as much as possible.
So what I am building is web based tool and in one section we have a table.
This table renders lines ...
1
vote
1
answer
130
views
Some questions about shortest-path algorithms
I'm trying to understand why anyone would prefer Floyd-Warshal over Dijkstra:
Dijkstra gives a correct result, using an understandable system, combined with backtracking.
Floyd-Warshal makes an ...
0
votes
1
answer
160
views
How to implement converters without needing to implement every permutation
I've got this class:
[UsedImplicitly]
public class ClassicalKeplerian
{
public ClassicalKeplerian(Angle argumentOfPeriapsis, Angle inclination, UnitFraction eccentricity, Angle ...
1
vote
3
answers
239
views
How can I mix this grid to guarantee it being solvable in X minimum steps?
Note: This question is not about this particular instance of this grid with these exact words, but about any combination of words.
I am programming a puzzle game where you have to arrange a grid of ...