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

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
votes
5answers
425 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, ...
2
votes
3answers
213 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
37 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
32 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 ...
-3
votes
1answer
46 views

A question about algorithm that can filter out expected length of elements [closed]

I have an assignment about algorithm which I get stuck. Here is the problem to solve: There are two 2D containers, both containers have the same width, 1st container has length 3 meter, 2nd container ...
1
vote
3answers
158 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
625 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
63 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
151 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
92 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
51 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 ...
3
votes
4answers
154 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
122 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
119 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
107 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
75 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
109 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
196 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
137 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
50 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
122 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
80 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
21 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
130 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
76 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 ...
1
vote
1answer
79 views

Improving my inelegant Haskell deduplication function

I'm working on learning Haskell, and one of the simple exercises I put myself through to this end is writing a function that deduplicates a list, removing all of the duplicate elements of a list such ...
3
votes
1answer
96 views

Array rotation algorithm

I'm developing an application which sends quotes to clients via email. Since quotes are obtained from various resources (per each client) they end up in a single array which is then used as a source ...
2
votes
1answer
45 views

Algorithm: Binary Search / Tree / Partitioning on unsortable data?

First, this question is not really about binary search as I neither have sorted data, nor any sortable data at all. :-) W.r.t the "unsortable" claim see below; but I think the title term "unsortable"...
0
votes
3answers
135 views

How to Simulate Control-Flow without using Control-Flow Primitives

Basically, I want to know how to simulate while and if if I'm handling the control flow myself through an array of instructions. The while loop can be simulated by if, as seen with assembly branching ...
2
votes
3answers
115 views

What is the complexity of find and checking prime numbers?

I'm trying to figure out the complexities of these two functions that I've written but could not understand.def First, I thought it is supposed be O(N). But it is not clear how many times the loop ...
-1
votes
1answer
80 views

Adjacency List list of linked list or can be repesented in other ways?

I am new to graph data structure. Everywhere on google it is said to be list(or array ) of linked list. My question is can not it be represented as list of list(in java array list of array list) or ...
0
votes
0answers
34 views

implementing data structure that consists of pair-diff(s,d)

i am having trouble and would really appreciate your help, especially with pair-diff(S,d) i am trying to implement a data structure S in given times: Insert(S,k) - inserting k into S O(logn) Delete(...
1
vote
1answer
56 views

Parnas' Paper on Modularization and Workflow Engines

In a Software Engineering class, we had an assignment to read Parnas' seminal paper on modularization [0]. In this paper, two approaches of dividing a software into modules are discussed: Traditional ...
0
votes
1answer
76 views

How to solve a Constraint Satisfaction Problem for Scheduling

This presentation describes several algorithms for solving a CSP for scheduling. Say I have a few processes with some constraints: a before c c before b b after d c 50% more important than e give d ...
-3
votes
2answers
112 views

Alternative to the stable marriage / hospital residents solution?

I manage co-curricular programs for the school I work at. Until now, they have signed up on a google form on a first-in best-dressed capacity, but there is lots of complaints about how some students ...
0
votes
1answer
78 views

Generating combinations without getting stuck in recursive calls

This question is about figuring the design of a recursive function that changes the state of a group of elements by processing one of them at a time, with the goal of reaching a desired state. The ...
0
votes
1answer
32 views

Assembling random indexed packages into an ordered sequence(s)?

I am pretty confident that this is well-known and solved problem. Suppose there are n uniquely indexed "packages" randomly getting into single entry point like .AcceptPackage(Package package). ...
-1
votes
1answer
67 views

Interdependent variables

Let's say there are two variables a & b, both a & b would have a value between a predefined range. a = x1 to y1 (range) b = x2 to y2 (range) Variable a & b are interdependent, if the ...
1
vote
1answer
92 views

Proof of digital document integrity

Let's say we have the following scenario. We have user A and user B and an initial digital document D generated by B. What algorithms and infrastructure are required in order to guarantee/prove ...
2
votes
1answer
72 views

Calendar scheduling: home field constraints

I am working on a round-robin scheduling algorithm for sports. The goal of the algorithm is to schedule all given games across different weeks, in the given fields and given game times. These are ...
-4
votes
1answer
119 views

Help with algorithm for organaizing blocks

So I'm stuck on this problem for around a week, tried different approaches and having a hard time coming up with a solution. What I'm trying to achieve is to fit blocks horizontally inside another ...
0
votes
0answers
152 views

Algorithm for recursive division maze generation on hexagonal grid

I'm currently writing a book on procedural generation and I'm writing a chapter about maze generation. I've done some searching but can only find recursive division demonstrated on a square grid. I ...
-1
votes
1answer
128 views

What is the SLOWEST 32 hashing function without excessive collisions

I am currently using a CRC32 hash to generate a locality sensitive hash for some of my data. For much the same reasons as PKBDF2 makes a better choice than, say, SHA26, for hashing passwords I ...
0
votes
0answers
38 views

How to schedule ordered pairs from a set uniformly over a given number of dates separated as two sets

I'm working on a personal project in which I have a set of (at least 1) entities and two disjoint sets of dates. I need to assign ordered pairs of the entities to the dates. I don't care about which ...
0
votes
1answer
40 views

Modified priority queue (with “disabled” elements)

I need something like a priority queue but with the following modification: Sometimes I need to mark some elements in the queue as "disabled". Disabled elements: temporarily (until marked non-...
1
vote
1answer
122 views

What tools exist to determine the speed up a GPU will have on an algorithm?

Basically, I am wondering what sort of speed I will get by parallelizing a algorithm to work with GPUs. I am wondering if someone has implemented queueing theory/Amdahl's law with a UI or if everyone ...
0
votes
1answer
64 views

Maximize picks from a list when you can only choose 2 items from every 7 items [closed]

What would be an O(n) algorithm to maximize picks from a list when you can only choose 2 items from every 7 items. I've been thinking about this problem for a few days and I can't figure out an answer....
2
votes
1answer
194 views

Parallel processing a Tree on GPU

I have seen a few papers on parallel/GPU processing of trees, but after briefly looking through them I wasn't able to grasp what they did. The closest to a helpful explanation was found in ...
0
votes
1answer
61 views

Is my reasoning to determine this algorithm's Big-O correct?

Take the following algorithm with two separate sections, and the sections do not influence each other whatsoever (the function is not recursive, as well). void algorithm(int x) { // This section ...
2
votes
2answers
141 views

Algorithm for splitting players into unique group every round

For a match I have certain number of players, certain number of groups (players and groups are aliquot) and certain number of rounds to be played (players are reshuffled every round). Ideally, I'd ...