Stack Exchange Network

Stack Exchange network consists of 174 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.

-3
votes
1answer
14 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?
0
votes
1answer
65 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 ...
2
votes
1answer
58 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. Microservice A stores the User entity in its own DB if User is configured by an agent.There is no flag ...
1
vote
2answers
248 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 ...
1
vote
2answers
125 views

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

I am new to TDD/unit testing. I am going to write one complex scheduling algorithm in Java. As this module is core part of our application and there are number of scenarios in it, I want to write ...
1
vote
0answers
98 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 ...
-2
votes
0answers
45 views

What algorithm should I use to create an automatic sport calendar feature? [closed]

I have in mind to create (I would like to do it with python) an algorithm that automatically creates palimpsest for a sport basketball (sould works for every sport anyway) tournament. I would like to ...
0
votes
1answer
78 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 ...
0
votes
0answers
22 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
2answers
154 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 ...
0
votes
0answers
56 views

What algorithms does Hunspell use?

I am trying to make a spell checker for Kurdish. The problem is, Kurdish is an agglutinative language. It has suffixes, prefixes, and infixes. So a normal Hunspell dictionary could contain thousands ...
5
votes
0answers
210 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
120 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
454 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
40 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
62 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
57 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
55 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
105 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
118 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
125 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
36 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
60 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
49 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
65 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, ...
3
votes
6answers
601 views

Is it better to write an efficient algorithm or code that is easier to understand?

So I was recently given a coding assignment from a large financial firm, and I thought of two ways to solve the problem. One of the ways involved 1 outer for loop and 1 inner for loop. In this case, ...
3
votes
3answers
252 views

Chess: Efficiently deciding whether a check mate has been made

This question addresses building a Chess engine. I've done just that, and in my humble opinion quite elegantly. But I'm missing my ending conditions. Here are some pseudopython functions that I use. ...
1
vote
1answer
42 views

Hashing tag list to perform faster search

I have a list of items. Each item have various properties. Each item can be tagged, like tagging a post here. Right now, tags are represented using a Tags property, that is a string and it looks like ...
-3
votes
1answer
36 views

Flowcharting 2 methods that use the same variable

so I need to flowchart something similar to the picture. The the first flowchart on left and the 2 flowcharts on the right is on different classes. The someClass have a instance variable named MyVar ...
1
vote
3answers
164 views

Is the Factory pattern good for this situation?

Im developping for my company a software where clients can requests app deployements and upgrades. Each request has 3 status (Validated, Started and closed). For every type of request (deployment ...
6
votes
3answers
768 views

Algorithm to sort ten million 7-digit integers in ascending order with just 1.5Mb RAM?

Given a file containing at most ten million 7-digit integers with no duplicates. What is an efficient way to print these numbers in ascending order using just 1.5MB RAM and reading the data just ...
0
votes
1answer
116 views

How fuzzy search is implemented for file paths

Say I have file paths like this: my/long/directory/structure/index.js my/long/directory/structure2/index.js my/long/directory/structure3/index.js my/long/directory/structure.../index.js my/long/...
1
vote
3answers
160 views

When implementing new features that are similar to other features, do you make the older features more generic?

This may come off as a bit confusing, but it's a question that I keep finding myself asking as I pile on more and more responsibility to older systems and features that I designed previously. Trying ...
2
votes
0answers
97 views

phonetic algorithms for words that aren't surnames?

I've been doing a little research into algorithms for matching spelling mistakes in names. From Soundex through to metaphone and Beider-Morse. All of these algorithms generally focus on last names ...
1
vote
0answers
54 views

Decision tree for storing subscription info

I have a system in which user creates an entity. Now this entity has attributes which are dependent on many external systems. We have all those pipelines in backend which updates these entities when ...
4
votes
4answers
240 views

Find the min/max length of directed graph

The problem is simple on paper... but a bit harder when it comes to write the algorithm to solve it. Let's use the following graph: First part This graph has an entry point A and two possible exits ...
-1
votes
1answer
125 views

Executing an algorithm constantly on slow and fast machine

Is it possible to create an algorithm that will execute at the same rate and speed on faster and slow computers. What i mean is, i have a year 2000 desktop that can run a certain computational ...
1
vote
2answers
123 views

What is the best algorithm for implementing a system with a complex execution path?

I am currently working on an implementation that based on a set of user configurations should output a final decision. The multiple configurations are evaluated several times at different stages of ...
1
vote
1answer
125 views

Find a string in list of strings

Background: I am writing an application for a small embedded device. There is a static list of strings: currently about 500 strings and string length is 12 characters on average. The list might ...
1
vote
1answer
77 views

Simulating Comparison Without Using Comparison Primitives

In the same way that you can simulate the if statement and functions, I am wondering if there is a way to simulate the comparison operators ==, !=, >, >=, <, <=. For example, in ...
1
vote
2answers
112 views

How can an iterative algorithm be controlled dynamically?

Suppose we need an iterative algorithm for mathematical optimisation. Each iteration takes a long and random time. After each iteration, a stopping condition is checked for the iterate x, based on ...
3
votes
2answers
206 views

Shuffle in music players

I always hear how it is hard to implement shuffle algorithms for music players, but never really the explanation for it. What makes it hard? Take for example how I would implement one: First the ...
0
votes
3answers
241 views

how can i return the median of a threaded binary search tree in constant time?

I'm having a trouble with understanding how to implement and find the median of a threaded binary search tree in constant time. The tree consists of a worker's id and name. The given details are ...
0
votes
1answer
54 views

Find nth best path in graph G from node A to node B (without loops)

I'm making an graph layout optimizer and need to find paths from node a to node b in graph g. It has gone pretty well so far, but I lack an algorithm to take the next step. So far I've used BFS to ...
-1
votes
1answer
139 views

Algorithm to generate all the possible combinations

I develop an application using WinForms/C#. In my software I have a List of objects, let's say List<Item> Items. There is also another List of objects, let's say List<Factor> Factors. ...
2
votes
1answer
109 views

Data Structure for “Intuitive” Text Matching

I've noticed that text editors and such have a more-than-prefix/suffix-based pattern matching algorithm going on behind the scenes. And StackOverflow's tag matching algorithm does more than just ...
1
vote
0answers
22 views

Sorting a list of objects with re-ordering and different views

The problem I have is this: I have a list of items. Each item has multiple properties. I have a view where I display all items and I have a view where I display the items based on values in properties....
1
vote
1answer
298 views

How to reason about complexity of Merging k sorted linked lists?

I am trying to understand Big O notation better to be able to reason about it in a much clearer way and therefore, need some feedback on my analysis given below for problem: Merge k-sorted linked ...
1
vote
1answer
81 views

System design for credit calculation usage

We are implementing a system where a user can purchase 'credits' to be spent on two items. I am hoping for suggestions on how to implement such a system. We have two ways of spending credits: ItemA ...