Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
43 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
1answer
26 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 ...
1
vote
1answer
28 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 ...
1
vote
0answers
41 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" ...
-2
votes
1answer
45 views

Given list of sets, find set of elements which belong to at least two different sets [closed]

Given a list of sets S, I'd like to find a set of all elements which belong to at least two differents sets in S. Here are my attempts in Python: import itertools duplicates = set() for u, v in ...
0
votes
1answer
24 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 ...
-4
votes
0answers
55 views

Optimal data structure and algorithms for matching data related to IT technologies [closed]

I want to write a software which will match data from developer skill survey with job offer data. I have two main problems with it: how to structure dictionary of technologies and how to meaningfully ...
0
votes
1answer
101 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
1answer
47 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 ...
-3
votes
0answers
29 views

How to develop an automated testframework + visualization for algorithm pipelines?

Right now I'm working on an image retrieval engine which is basically a pipeline consisting of multiple algorithmic steps all of which have tons of parameters to configure and evaluate. In the end I ...
2
votes
1answer
121 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 */ ............... ...
0
votes
1answer
41 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
1answer
80 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; ...
0
votes
1answer
67 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 ...
-1
votes
1answer
25 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
vote
1answer
84 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
1answer
66 views

Can Mean Shift Algorithm 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
1answer
43 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
1answer
154 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
3answers
119 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
1answer
64 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.
-3
votes
1answer
157 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
2answers
114 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 ...
4
votes
3answers
421 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 ...
2
votes
3answers
286 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
1answer
82 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)?
-2
votes
1answer
35 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?
2
votes
2answers
154 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 ...
3
votes
3answers
229 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 ...
1
vote
2answers
267 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 ...
2
votes
2answers
182 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 ...
1
vote
0answers
109 views

tea bag flavors mixing algorithm

I bought three boxes of tea bags with different flavors (A, B, C). I wish to mix them in such a way that - there is never two consecutive bags of the same flavor (ABCCAB is avoided) ; - the mixing is ...
0
votes
1answer
93 views

Find two horizontal lines to minimize distance to scattered points

I am having trouble with a coding question that I found practicing for a interview: A scatter graph of points on a page, draw two horizontal lines (these lines are parallel) across the page such that ...
1
vote
0answers
33 views

Logfile correlation finder (for j4Log)

I'm currently analyzing a problem in a old "distributed" system, that only occurs sporadically - as the system does not support other means of debugging help I have to rely on the logs (I did not ...
1
vote
3answers
251 views

What algorithm is used in subtitles?

What algorithm does a video player use to find the subtitles to show at any given time? I'm building a video player that displays some notes on different times over a video. Each note has a starting ...
5
votes
0answers
253 views

Concurrent fault-safe data structure

I am building an application that aims to process ~10M data items per second. Each item is exactly 42 bytes small (including a sorting key) which means the total data rate will not be big 420 MB/s. ...
-2
votes
1answer
201 views

Calculating longest trip [closed]

I have been stuck on this question for some time. Could you guys direct me or point me to the right direction for solving this problem ? We would like to encourage passengers to experience the joy of ...
8
votes
3answers
503 views

Is it possible to programmatically evaluate safety for arbitrary code?

I've been thinking a lot lately about safe code. Thread-safe. Memory-safe. Not-going-to-explode-in-your-face-with-a-segfault safe. But for the sake of clarity in the question, let's use Rust's safety ...
0
votes
1answer
97 views

How to manually model a UML activity Diagram to JSON with Qt C++?

Suppose I have a kind of UML activity diagram with 1-n forks and joins. The assignment of the individual nodes relative to each other is defined by an XML relationship table via UUIDs where each ...
1
vote
1answer
149 views

Binary Search Tree with ID and Duplicate Values

I'm having trouble finding resources for this implementation I'm trying to figure out. I want to save nodes in a binary search tree (self balancing) containing an ID and value struct Score { int ...
-1
votes
1answer
64 views

How to maintain unique, customer facing Booking or Reservation Ids

I am facing trouble in creating a unique, customer facing Booking Id. It's a simple thing to do at backend where we can create a UUID and maintain uniqueness. But the UUID looks ugly from a Frontend ...
1
vote
1answer
66 views

How to identify additional space complexity

I just started leaning about algorithm design and I am now having trouble identifying the additional space used in an algorithm. For dynamic program, as far as the examples I've learnt, such as ...
1
vote
2answers
144 views

Shunting-yard algorithm

I'm interested in all the cases where shunting-yard algorithm can tell if an expression is not correctly written from a syntax point of view. So the Shunting-yard algorithm takes an expression ...
0
votes
1answer
130 views

What's the benefit of separating specialised data from behaviour in an algorithm?

Functional programming strongly suggests to separate data from behaviours (functions). However, I can't see the benefit of this for an algorithm's implementation intrinsically tied with particular ...
0
votes
1answer
132 views

A collision-free hash-like function for use in hash tables and other data structures?

A short introduction to the problem: I'm working with a small database where I have a table of strings (web URLs, to be precise) as pairs: hash|string. Another table references these strings by hash ...
0
votes
1answer
48 views

How to resolve multiple user serve on multiple location appointment booking system

I'm trying to build an appointment system but at one point I stuck Problem: I define available slots for the next 7 days with help of a cron. I have multiple users serve service more than one ...
2
votes
2answers
92 views

Cumulative sum of overlapping increase/decrease over time

I am looking for an efficient way to handle a calculation. I have lots of timestamped events, representing loading and unloading of trucks. I need to construct the filling rate of these trucks over ...
2
votes
2answers
37 views

Matching closest position of a sequence from another

I have 2 sequences: One is a videoclip with the image taken by a drone's camera The other is a file with a list of chronological data from the sensors Example: time 0: speed_x=1, latitude=0.001, ...
0
votes
1answer
55 views

Subdomain matching

I am working on a small plugin for a DNS server. I have a static list of domain (sometimes subdomains too) names: gaming.xyz.com facebook.com mail.example.com blog.example.com I want to check if a ...
1
vote
2answers
91 views

How to find matching profiles?

I'm developing backend for a dating app, in which each user has a profile of his/her characteristics a profile of ideal match's characteristics There are dozens of characteristics like gender, ...