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
4 votes
3 answers
2k 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 ...
1 vote
4 answers
3k 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 ...
0 votes
0 answers
353 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 ...
  • 109
5 votes
1 answer
838 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. ...
1 vote
1 answer
268 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 ...
  • 135
0 votes
2 answers
60 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 ...
  • 135
0 votes
1 answer
146 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 ...
-4 votes
7 answers
642 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 ...
1 vote
0 answers
133 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/...
1 vote
1 answer
83 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 ...
  • 171
2 votes
5 answers
593 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 ...
2 votes
4 answers
931 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 (...
1 vote
1 answer
177 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 ...
  • 9,596
3 votes
1 answer
164 views

Arranging blocks of data for efficient memory access

Suppose I have an algorithm that has N blocks of data, and an operation needs to be performed on all blocks such that it requires 2 blocks to be in memory at any given time to be done for all possible ...
  • 141
-3 votes
1 answer
1k views

Is algorithm performance dependent on the programming language used? [closed]

I have studied complexity of algorithms that how long an algorithm will take to execute completely, then why it is said that certain programming languages are faster than others such as C++ is faster ...
1 vote
1 answer
615 views

How to design a high-scale, reliable, distributed and periodic task (cronjob) execution service?

Assume you are tasked with implementing a "cronjob as a service" where you are supposed to be able to run potentially millions of periodical tasks (to simplify, making HTTP requests to URLs) with ...
0 votes
1 answer
82 views

How to implement adaptive routing?

I need to send jobs to worker queues according to resource usage and other metrics like how many jobs have been processed and how successful they were. There is also the need to “weight” these ...
  • 11
2 votes
1 answer
106 views

How to create a recommendation algorithm ("If you like X and Y, you might like Z")? [closed]

How to create a recommendation algorithm ("If you like X and Y, you might like Z")? I want to create an algorithm which recommends "You might also like" items from an itemlist, based on user's ...
  • 131
-2 votes
2 answers
255 views

When to use Quicksort instead of MergeSort? [closed]

I have the following homework question: You develop a video surveillance software that must run on real-time data. In one of the steps of the algorithm executed with each image captured by the camera, ...
1 vote
2 answers
725 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 ...
  • 121
3 votes
1 answer
163 views

Transforming a long-running operation into a step by step operation?

I am working on a video game in Unity and at some point I'm facing a tough problem to solve: The game freezes while loading level data. Let me lay down what's happening in that process that takes a ...
  • 727
3 votes
2 answers
834 views

Algorithm for Parking Space Allocator System

In my office, there are 200 employees who come to the office in their car. But my parking space has slots for parking 160 cars only. Now I want to design and develop an application that issues parking ...
user avatar
1 vote
1 answer
223 views

What is the right algorithm to solve this problem?

The problem is - We have a series of boxes (A, B, C, D, ...). Each box contains bricks of different colours. For eg. Box A - red, blue Box B - blue, red, green ... and so on... and there are ...
0 votes
1 answer
944 views

Distribute jobs evenly among a set of servers

I have the need to distribute a set of long running jobs across a cluster of containers in ECS. These jobs essentially would need to open a socket connection with a remote server and begin streaming ...
3 votes
1 answer
6k views

How to Define the Bandwidth in Mean Shift Clustering?

I am making a program using Java todo colo quantization using mean shift clustering algorithm and the image is RGB with resolution of 512x512. I want to reduce the image file size by reducing the ...
2 votes
0 answers
60 views

How to join two sets of 6 tables and select the list into another set of 6 tables

A1 |__A2 |__A3 |__A4 |__A5 B1 |__B2 |__B3 |__B4 |__B5 C1 |__C2 |__C3 |__C4 |__C5 Given a list of A and a list of B, we want to "join" ...
  • 197
0 votes
1 answer
125 views

How can my distributed web service rate-limit calls to a downstream component?

Context: I own a service that's distributed across VMs, that themselves are distributed across multiple data centers. Scenario: I'm adding an API that calls a single downstream dependency. This ...
  • 453
0 votes
1 answer
262 views

Provide iterator while generating power set [closed]

I have written a code in C# to generate the power set of a given input list of integers. public List<List<int>> GeneratePowerSet(List<int> Set) { int setCount = Set.Count; ...
0 votes
1 answer
793 views

Gerstner Wave equation from tessendorf paper, mesh penetrates itself

I have been learning to create water waves in a mesh from a paper commonly known as the Tessendorf paper. Which is quite well known. But those who don't know this is the equations it mentions in the ...
  • 2,032
2 votes
1 answer
2k views

Do we include output space in space complexity?

For example. I have a function which generates an array with random numbers. int[] generateNum(int n) { int[] result = new int[n]; /* Logic to generate random number */ ............... ...
1 vote
1 answer
304 views

How a Merkle tree can work with Graph data, or a better data structure

I am looking at blockchain and trying to see how Merkle trees (or perhaps Merkle DAGs) can fit to a graph data structure with circular references. For example, say I have this data model: var ...
-2 votes
1 answer
828 views

Algorithm - Simulation of a soccer match

I'm implementing an App for fun. It consists of a soccer round-robin tournament simulator in which all teams play each other. A Team consists in a simple object: class Team{ String _teamName; ...
  • 293
1 vote
2 answers
101 views

Algorithm. Find the group of documents with the least amount of words

I need help with a problem which I have been working for the last month. I have a group of documents, each document has a set of unique words (if the word appears more than once in the document, I ...
  • 119
-1 votes
1 answer
35 views

Calculating activity score based on log in activity?

I have a site where user logs in. I need to calculate the log-in activity score based on the age when he logged in. For example :- If user logins today he will have high score than the user who ...
  • 1,896
1 vote
1 answer
413 views

Sorting an array of ranges for display

I have an array of ranges with start and end timestamps. I want to display those ranges on a graph. Right now, my naive algorithm gets an array of ranges sorted by their start timestamp and iterate ...
2 votes
1 answer
442 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 ...
0 votes
1 answer
52 views

storage of text history and algorithm to return text at particular time

An application I'm considering writing needs to show a text that a user has edited at a particular time. So consider if we have a text the user is editing from Time A to Time X, and I want to show ...
3 votes
1 answer
170 views

Performing complex searchs using C# collections

I have a collection with millions of items of Generic type T. Assume this list never changes. I want to perform many types of searches with subsets of fields of type T. Some with only 1 field and ...
1 vote
4 answers
780 views

Algorithm to simplify 2D convex hull at the cost of extra area

Are there any algorithms related to the following problem that could be usefull for solving it? I have a convex hull built on some point set. I would like to simplify it (reduce number of points) by ...
-3 votes
1 answer
95 views

Low resolution Image to High resolution

Is it possible to scale a low resolution image to a highier resolution upto the point with minimum effect on quality, sharpness and other notable attributes of an image.
  • 121
-3 votes
1 answer
257 views

Is my algorithm for determining whether a ipv4 is public or private correct? [closed]

I have just created a function which checks whether a ipv4 is public or not. I have not heavily tested it yet since it is kind of practically impossible to do so (because I do not know where to start)....
-3 votes
2 answers
877 views

How can compare two integer with only using ==, + and recursion?

Here is the original question from MIT lecture notes : Write a Spy procedure that takes two positive integers as input and returns True if the first is greater than the second. Use only the ...
8 votes
3 answers
1k views

How to optimize a mixed stack/register bytecode with control flow and side effects?

I'm trying to figure out a technique to optimize bytecode for the following virtual machine: Bytecode is a flat list of instructions, with execution starting from the first instruction. Stack ...
3 votes
3 answers
2k views

Is this a sorting algorithm faster than O(n*log(n))

If there are n variables each with m possible values. (For integer, m is 2 billion something.) First, map every possible value to an integer from 0 to m-1 in order. And define the mapping functions. ...
-3 votes
1 answer
89 views

How to determine the collection type without access to the source code [closed]

How could you determine if a collection is implemented as an array or as a linked structure without access to the source code (assuming you can run the code)?
  • 141
-3 votes
1 answer
130 views

Difference array to range array updates

I found information that the best way to update ranges of array values is using difference array. It works but I can't figure out why it works. Can anyone could explain it for me?
  • 275
1 vote
2 answers
242 views

Finding an efficient data structure and/or algorithm

I am tasked with an animated graph based on a timeline, and I am having trouble finding a suitable data structure and/or algorithm that's reasonably efficient. I have a working system suffering from ...
  • 121
3 votes
3 answers
1k views

Aggregation of data from two Microservices

I have two Microservices A and B. B Microservice has a large set of an entity called User. A Microservice stores the User entity in its own DB if User is configured by an agent. There is no flag ...
0 votes
2 answers
471 views

Why is stability considered a desirable trait of a sorting algorithm?

The common argument for stability in a sorting algorithm typically involves an example where a list is sorted by two criteria. For example: 1,4,5,7,2,6,8,9,15,65,24,27 sort by evenness/oddness and ...
4 votes
3 answers
3k views

What is recommended way to create test data for unit test cases?

I am new to TDD/unit testing. I am going to write a complex scheduling algorithm in Java. As this module is a core part of our application and there are number of scenarios in it, I want to write ...
  • 195

1
3 4
5
6 7
44