# 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,065 questions
Filter by
Sorted by
Tagged with
59 views

### Need to test for equality on vector clocks

I've heard about vector clocks and how to test if a message was sent before another message. E.g. Message A was sent before message B if every element of the vector of message A is smaller or equal ...
37 views

### Is there a best practice for scheduling forecast notifications?

Let's say we write an application that can use multiple forecasts from different sources. It does not really matter what type of data we are talking about, ofc. it can be weather forecast, stock price ...
100 views

### How to generate “meaningful combinations” from the set of characters?

There is a set of feasible characters, say ABCDEF. Combining some of them, I can generate some "meaningful" combinations, say CAFE. I want to gather all of them. To do that, I can just "walk through" ...
1k views

### How to represent in a flowchart data fetched from a database

I have an existing piece of code that uses a database. In order to understand its algorithm, I try to represent it with a flow chart. In this algorithm I need to fetch some data from the database in ...
65 views

### Algorithm for calculating daily profits from user's balance minus deposits

Calculating a user's daily profits / losses using their previous balance and their current balance (let's say for things like financial portfolios) is pretty trivial. The part I find difficult is how ...
44 views

### Quantity allocation algorithm performance

I have a scenario for which I'll take an analogous example to help understand better. There are N buckets of known varying capacities. We have M balls that we need to put in these buckets to fill ...
21 views

### How to implement item based collaborative filtering on android using CSV dataset

I have developed an android application on food delivery where I have used Firebase to store and retrieve data. I wanted to implement collaborative filtering algorithm on my dataset and I am stuck on ...
145 views

### Detect frequency pattern in a list of dates

I have a list of dates in which a certain event happened. Taking into consideration that a particular occurrence of the event can: Be a one time thing or Be part of a periodic series, which happens ...
101 views

### How to guess which pieces of text belong to which lines in a scanned document?

I want to be able to analyze a five-years archive of supermarket receipts. The receipts are scanned, and thanks to Google Cloud Vision API, the result of an OCR is available. Google's API, however, ...
83 views

### Searching/Hashing Wikipedia - at each position for keys 1..31 long, the fastest way?

A C coder here. My wish is to find the best way to search words and phrases within the ever-growing English Wikipedia XML dump. As a first layer/step, hashing is the answer, yes? The problem is that ...
112 views

### Algorithmic approach to check wordlist phrase against MD5 hash [closed]

Say I have an MD5 hash. I need to decrypt. I also have a wordlist of 100.000 words, in an array. I KNOW that the MD5 hash consists of 3 different words, all present in the array. I dont know which ...
169 views

### Algorithm for random weighted boolean shuffles?

I don't exactly know how to phrase the thing I'm searching for in a succinct way, which also made it hard to research. In my application I need a random list of booleans, say of length five. The ...
79 views

### Designing a generic graph

I am looking at designing a Graph class, that should work for both lists and matrix. For ex: something like, class Graph { public: virtual ~Graph() = 0; virtual bool AddEdge(int src, int dest)...
148 views

### Does a Self-Balancing Self-Sorting Binary Search Tree exist?

When we are inserting into a self-balancing tree, can we also assume it is sorting itself using those same operations? Or rather is there a traversal method that gets us the elements as a sorted list?
291 views

### Scrabble Grid Word Detection Algorithm

I am building a scrabble game, and I have already a dictionary working. When the user will place letters on grid, I need to check that all the words are valid. Which algorithm can I use or how can I ...
78 views

### Algorithm that maps consecutive whole numbers to sets of numbers

Where would I begin if I wanted to develop an algorithm that maps consecutive whole numbers to a long list of unique sets of whole numbers. For example: 0 = {0, 0, 0} 1 = {0, 0, 1} 2 = {0, 0, 2} ...
115 views

### Map synchronization algorithm

Say I have two Map instances in JavaScript (or HashMap in Java, or Dictionary in C#), A and B. I want to synchronize B to A, so that B is a copy of A. I can't copy the reference and I don't want to ...
92 views

### Fuse 3D-Points in Bundle Adjustment?

I'm actually implementing my own Pose-Estimation/- and -Refinement pipeline. For this purpose I use one moving mono-camera. Then I take the consecutive images to estimate the pose and triangulate the ...
1k views

### Time complexity of a Nested While loop in a for loop

I'm trying to derive the simplified asymptotic running time in Theta() notation for the two nested loops below. For i <-- 1 to n do j <-- 1 while j*j <= i j = j+1 For i <...
353 views

### Is LRU still a good algorithm for a cache with diferent size elements?

I am currently working on a project where I need to implement a cache with limited size. The most common eviction policy seems to be Least recently used (LRU), that simply discards the least recently ...
128 views

### Do I have do use HashTables/Maps/Hashmaps in this algorithm?

I am doing the Ransom Note algorithm in Hackerrank. The thing is I am not using maps and all the tests pass except for three which execution time takes a lot more. (Kotlin language) I have two ...
421 views

### Finding largest sequence in 2D array

I'm practicing problems and found this weird one. I can't figure out the best way to solve it. You are given a 2D matrix size n*n with only 1's and 0's, you have to find the longest sequence of 1's ...
73 views

### Solutions to sort series based on smallest difference of derivatives

Consider a table of m columns where columns represents some smooth functions with potentially some minor noise. Each function is given for the same set of argument values. However, the rows in the ...
204 views

### Group overlapping intervals

Given a number of intervals: -- (1, 3) a - (2, 3) b -- (2, 4) c -- (3, 5) d intervals = [(1, 3), (2, 3), (2, 4), (3, 5)] I would like to generate the minimum number of groups so that in ...
440 views

### Failure to understand logic behind dice roll permutation problem

I am having a lot of trouble understanding the logic behind the infamous "Find total ways to achieve given sum with n throws of dice having k faces" question. After extensively searching for ...
188 views

### Given an arbitrary function f, how would you go about writing a function g that replicates f's implementation?

You are given an arbitrary function f. You may invoke it with arbitrary parameters and read the return values, as well as record any exceptions it raises, but you may not read its implementation. How ...
182 views

### Big-O Notation and Calculus [closed]

I was wondering if there are any calculus relationships implicit in Big-O notation. For example, an algorithm linear according to Big-O notation reduces the size of the problem by a constant amount ...
174 views

### Generating all possible permutations in the fox, goose and beans problem

I have learned graph theory, and am using it to solve the classic Fox, goose and bag of beans puzzle. If we consider that there are three locations for each of the fox (X), goose (G), farmer (F) and ...
42 views

### Affiliate Marketing - How to track all sales on 3rd party website made via my application

I'm looking forward to the possibility of an algorithm or a way to track how much sale has been made on 3rd party's website because of my client so I can get the commission. For example if a user "A" ...
39 views

### What is the most efficient way to find filesystem changes in percentage?

I am planning to write a program that will produce digest logs for file changes in a particular directory. The idea is that whenever a file is deleted in a particular directory, it will show up in the ...
81 views

### Algorithm for picking seedbox to put torrent on

Which algorithm would be best for deciding which seedbox each torrent should go on? It must be able to fit the torrents in the minimum number of seedboxes, but also maximize the free space on each ...
136 views

### Architecture/algorithm for unusual recommendation system

There are thousands (or tens of thousands) of possible movie titles. New user enters my website and selects hundreds of titles that he likes. The only single goal of my website is to output the list ...
618 views

### How to create a league scheduling algorithm?

Our requirement was to create an auto fixture generation tool that creates fixtures for a league with any number of teams, and where they have a fair distribution of home and away games so that: ...
107 views

### I have a data set of over a million addresses and I want to display the closest N locations to a given address or current location

I am a student working on a personal project which is essentially a location finder that will be on a website. I have a data set of over a million addresses and I want to display the closest N ...
442 views

### What are some disadvantages for a hashmap with timestamp as key? [closed]

"What are some problems that can arise from using a HashMap with timestamp as keys"? I, for one, do not see any major issues with this kind of "setup". Is this "setup" a no-go/an anti-pattern/...
237 views

### Move the onscreen circle when camera moves

I have a script that accesses my webcam and displays the captured video on the screen. I can also very easily draw a circle (a rectangle, it doesn't matter) over the video. When I move the camera ...
628 views

### What is the most effective algorithm to evenly distribute n points on a 2 dimensional array so they are as separated as possible?

I am trying to code a game which currently uses a matrix ( that I am calling a map). On this map are islands which can be generated n times. The purpose of the algorithm is to distribute the islands ...
2k views

### C# How to correctly work with ProgressBar? Architecture look

I am wondering about the correct architecture to work with a progress bar in C#. But maybe it applies not only to C#, because I need an architectural look at this. I'll explain my question with an ...
130 views

### Algorithm for finding optimal appointment times

There are multiple types of appointments, each with their own length. The goal is to find 'optimal' placements for a given appointment type on a given day - optimal meaning leaving as little 'wasted ...
527 views

### What do I not understand about Alpha-Beta-Pruning in Chess?

I'm trying to write a chess engine, Min-Maxing works. Now I wanted to implement Alpha-Beta-Pruning, but despite reading about it and watching videos, I must have a severe misunderstanding somewhere. ...
163 views

### Simulate running/resting heart rate BPM

I need to simulate & output the human heartrate BPM with real-world like values. I've been looking at a gaussian random approach but don't believe this fits my use case. I'm not concerned about ...
55 views

### Marrying disparate datasets in stream

Caveat: I'm conscious that this question may not be a great fit for stack-exchange platform as maybe 'too broad' but will try & structure it that it helps people in the future I have 2 event ...
113 views

### How large-scale production web crawlers improve performance when it comes to running into already visited links

I have built a very basic webcrawler running off my laptop so it has limited memory and limited hard drive space. The way I have it now is I'm using MongoDB to store the links I find on pages. I make ...
316 views

### How to check for ID uniqueness on large dataset that can't fit into memory or on a single disk

Say I have 500MB of memory to work with, but 100 terabytes of IDs I want to generate. I want these IDs (GUIDs) to be randomly selected and applied to records, so they shouldn't appear in order when ...
56 views

### What algorithm to count user click/read/turnover for a period of time?

We tried to develop a kinda-real-time statistics module to measure how hot/trend a content is. We know it is hard to achieve high end stuff like youtube/FB/twitter, our goal is simpler : Count click/...
75 views

### Calculation On Large File Data

I have a task where I need to read a big data file and process the data in it. Every row in the file looks like this: CustomerId ItemId Amount Price I need to calculate the total cost for the ...
510 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 ...
272 views

### Algorithm for permutations of a string of characters, with no duplicate orders

I've seen a lot of good questions about similar problems but not exactly what I'm looking for. Given: a non-unique set of symbols (or characters) (1, 1, 2, 3) Expected: an output similar to this (...
133 views

### Bin packing with “flexible” items: Does this algorithmic problem have a name? [closed]

I have stumbled upon the following problem: I have one list of containers with "capacities", and a list of items with quantities. I want to assign those items to the containers. The total capacity of ...
130 views

### Arranging blocks of data for efficient memory access

suppose I have an algorthm that has N blocks of data, and an operation needs to be performed on all blocks such that requires 2 blocks to be in memory at any given time to be done for all possible ...

1
2
3 4 5
ā¦
42