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.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
18 views

Finding the Minimum-Step Path from (0,0) to (x,y) with a Cumulative Sum of P

Imagine a 2D plane, where each point represents a position. Your mission is to trace a path from the origin (0,0) to an end point (x,y) following a set of specific rules. Each step in the path can be ...
0 votes
1 answer
279 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
7 votes
2 answers
2k views

How does the GLL parsing algorithm work?

I'm very interested in the topic of parsers, especially in the topic of parser combinators like Superpower. The problem with them is that the grammars that they can work with are a bit limited. For ...
0 votes
1 answer
524 views

Optimized algorithm to match entities together based on heuristics

I've encountered a problem which I think is rather suited to be solved using a Constraint Satisfaction Problem algorithm. I am however, not entirely certain that this is the best approach, as the ...
0 votes
1 answer
117 views

I need to choose records from a database to feed to a model for training, but would like to weigh records beforehand. What's a good strategy for this?

I am currently responsible for feeding data to an STT model. My backend is written in Python/Django and is primarily responsible for managing a Postgress database. The database has a table that saves ...
-1 votes
2 answers
106 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 ...
2 votes
4 answers
8k views

algorithm to print the digits in the correct order

I've been trying to write an algorithm that will print separately the digits from an integer. I have to write it in Pseudocode. I know how to write an algorithm that reverse the digits. digi(n): ...
1652 votes
11 answers
832k views

Which hashing algorithm is best for uniqueness and speed?

Which hashing algorithm is best for uniqueness and speed? Example (good) uses include hash dictionaries. I know there are things like SHA-256 and such, but these algorithms are designed to be secure,...
1 vote
6 answers
971 views

If the whole point of recursion is to break the problem into multiple smaller problems, what if those problems were solved in parallel?

So I was studying here and I was thinking if the whole point of recursion is to break the problem into multiple smaller problems, what if those problems were solved in parallel? A quick search lead me ...
0 votes
3 answers
97 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
503 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, ...
4 votes
3 answers
2k views

Finding common prefixes for a set of strings

I am trying to find common prefixes for a sorted set of strings. i.e. if the following strings are given: AB123456 AB123457 ABCDEFGH ABCDEFGX1 ABCDEFGY XXXX then my function should return three ...
2 votes
1 answer
132 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 ...
5 votes
1 answer
2k views

Using PostgreSQL MD5 hash to calculate a 64 bit hash value for advisory lock functions?

I have a particular problem addressing the PostgreSQL advisory locking functions using the bigint variants. Basically I want to create a 64 bit bigint value from a text type obtained with the ...
1 vote
2 answers
153 views

Dependency resolution of tasks which have crontab information

I want to illustrate my problem statement with a use case. I am building a trading system that acts as a container for deploying trading strategies. The trading strategy comprises dependent tasks. Let'...
1 vote
3 answers
165 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, ...
-1 votes
2 answers
423 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 ...
1 vote
2 answers
550 views

Help on a Dynamic Programming definition in Cormen

I am reading about Dynamic Programming from Cormen. In the beginning of the chapter it says (relating to the term Dynamic Programming): "Programming” in this context refers to a tabular method, ...
6 votes
3 answers
2k views

Matching up articles with similar ones

I am creating a site where people can write on a niche topic. It is almost like a blog, however the area as I mentioned is a small niche with (hopefully) passionate users. I want a functionality ...
2 votes
5 answers
3k views

Looking for monotonically increasing (integer) hash function

I'm looking for a HashFunction(X,Y: Integer): Integer that is monotonically increasing on X, then Y. So: HashFunction(x1,y1) > HashFunction(x2,y2) if x1>x2 HashFunction(x,y1) > HashFunction(x,y2) if ...
74 votes
7 answers
78k views

What is a helper? Is it a design pattern? Is it an algorithm?

Maybe a little tongue-in-cheek, but as I can't find this answer anywhere through Google, so to ensure Software Engineering has the answer: What is a helper? I have seen the name being used ...
-1 votes
1 answer
3k views

How to create a scoring system with time and correct answers for a game?

I have a small mobile quiz game, which consists of 30 questions, and a timer which starts from 0 seconds, and goes all the way up to 1 hour. Below you can see that my timer starts from 0, and it is ...
0 votes
0 answers
79 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 ...
13 votes
3 answers
4k views

Which k-best shortest-path algorithms should I consider?

I'm solving a graph-search optimization problem. I need to find the k best acyclic shortest-paths through a directed weighted graph. I know there are a number of exact and approximate k-best ...
0 votes
1 answer
120 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 ...
27 votes
4 answers
34k views

In pseudo code what does := mean?

The section entitled Algorithmic Implementation has the following code: // Return RC low-pass filter output samples, given input samples, // time interval dt, and time constant RC function ...
0 votes
1 answer
63 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
6k 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
349 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
3 answers
3k views

Algorithm for appointment reminders

My program allows users to store appointments in a calendar. What has been requested of me is the ability for SMS reminders to be sent to people to remind them of their appointment. The SMS would ...
1 vote
2 answers
104 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
446 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
266 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 ...
4 votes
1 answer
670 views

Potential legal issues with lock-free / wait-free structures / algorithms

While researching the subject matter - lock-free and wait-free data structures - I'm seeing a worrying amount of mention of patents with this area. I've hobby-researched compression algorithms years ...
1 vote
7 answers
6k views

Algorithm for recursive evaluation of postfix expressions

I'm reading Sedgewick's book on algorithms in C and I'm looking for an algorithm to evaluate postfix expressions (addition and multiplication only) without using a stack. I tried to implement one but ...
-1 votes
4 answers
450 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
139 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
2 answers
1k views

How to shuffle a large data set without touching every row?

Let’s say I have two larges arrays of users with equals number of rows and I want to match them randomly and one to one(one from the first array,one from the second), I will first need to shuffle one ...
1 vote
1 answer
561 views

Can the Mean Shift Algorithm be used in color quantization?

I have a problem with deciding algorithm for color quantization. The image that I want to do color quantization is an RGB image with resolution 512 x 512. I want to reduce the color value in the pixel ...
3 votes
1 answer
304 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
0 answers
130 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 ...
1 vote
3 answers
167 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
134 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 ...
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 ...
-3 votes
3 answers
160 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
202 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 ...
21 votes
9 answers
8k views

How to turn truth table into smallest possible if / else block

How can I take a truth table and turn it into a compacted if block? For instance, let's say I have this truth table where A and B are conditions and x, y and z are possible actions: A B | x y z -----...
0 votes
3 answers
529 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
90 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 ...

1
2 3 4 5
45