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.

learn more… | top users | synonyms (1)

1
vote
1answer
51 views

Sorting list and changing same values to nearly the same

I have a list of doubles that need to be sorted and changed so that there are no two numbers that are the same (difference smaller then 0.05) and I need to do it fast. I don't care about preserving ...
-1
votes
3answers
117 views

Generate unique integer from two integers with algorithm

I am currently trying to come up with an algoritm which would take at least two numbers (say user IDs) and then come up with an unique number which is generated based on these two numbers. Each ...
-3
votes
0answers
46 views

What should i learn to create a Virtual Reality World? [on hold]

I'm computer engineering student. Actually more than knowing the answer of this question, i am trying to find ways to make myself code more programs. But this is what i am interested on. For a long ...
1
vote
0answers
38 views

Calculating “instability score” for connection quality, programmatically

First of all, apologies if this is posted in the wrong site. I thought it is more suitable here than SO because the question is quite generic, more an algorithm question than a specific programming ...
3
votes
1answer
61 views

Data structures and algorithms for a directed rooted tree with inherited properties?

I need to represent a directed rooted tree in memory. The caveat is, that nodes have properties. And those properties are inherited (but not 100%) by the child nodes, recursively. What would be a ...
0
votes
0answers
63 views

Similar problem to word break

I have a list of strings say L and an array of words say A. I want to find a string from the list L that is a best match to a string created from the permutations of the words in the array. The ...
0
votes
0answers
33 views

What is the best way to sort strings with multiple words in each line and is separated by newline in Java? [migrated]

I have list of anime that i have watch uptill now and i want to sort them in alphabetical order. Below is the small example of how the list is and there are over 200 lines. I have stored all of them ...
-3
votes
0answers
98 views

Find number of numbers made with 1,2,3,4 such that same digits never lie together [closed]

There is a particular sequence only uses the numbers 1, 2, 3, 4 and no two adjacent numbers are the same. Write a program that given n1 1s, n2 2s, n3 3s, n4 4s will output the number of such ...
0
votes
0answers
47 views

How to improve A* Algorithm where each child node costs marginally different

I have an A* algorithm with a heuristic to best guide the best path. The problem is that each node can have up to 240 children and each subsequent child also... So doing a breadth first approach is ...
0
votes
1answer
45 views

Algorithm for tiling a surface with no adjacent tiles

I am looking for an algorithm that does as follows: Given a 2D grid of X,Y and a number of tiles T, places a tile in each cell of the grid such that the surrounding tiles are not the same. This ...
0
votes
1answer
54 views

Finding common subsets in a list of sets

Let say I have a list of sets, defined like this (3 sets in this example) : A = [1, 2, 3, 4, 5] B = [4, 5, 6, 7, 8] C = [1, 2, 3, 4, 5, 6, 7, 8] Total number of elements defined in sets : 18 I'd ...
-4
votes
0answers
33 views

Questions regarding graph/2-d matrix traversals and shortest path [closed]

Many interview questions are about graph traversal and shortest paths. For example, you may be asked to find the shortest path from a point in the graph to another. In order to solve it, one would use ...
0
votes
1answer
66 views

How to decide in which language to write an algorithm that iterates through large amounts of data? [closed]

I am attempting to implement an algorithm that takes in a massive array of data, and iterates through each element in this array. For each element, it will either create an new array and put the ...
1
vote
1answer
71 views

Check word density within a document

Here is the situation: I have a Document(d) and a set of keywords (Set<String> keywords). I like to check the density of each words from set keywords with d. I have few solution but not really ...
1
vote
1answer
45 views

How to do “image shifting” faster?

I have a grayscale matrix (implemented as a simple array) to be shown on a display: line 1: | a | b | c | line 2: | d | e | f | a-f are grayscale values. This pattern has to be shifted by a ...
16
votes
5answers
4k views

Algorithms: How do I sum O(n) and O(nlog(n)) together?

I have the follow algorithm which finds duplicates and removes them: public static int numDuplicatesB(int[] arr) { Sort.mergesort(arr); int numDups = 0; for (int i = 1; i < arr.length; ...
0
votes
0answers
49 views

Algorithm recommendation for string classification [migrated]

I have numerous (hundreds to low-thousands) of pre-classified short strings of text, each string is just a few words long, some just a single word. The strings have been divided into a few dozen ...
1
vote
1answer
44 views

saving connectivity information in a nodes/edges network

I want to implement the A* algorithm. I have a network with Nodes and Edges, both are classes. Now, I am unsure how to approach the connectivity information. Should a node know which edges depart ...
0
votes
0answers
20 views

selecting area in array and expanding it to surroundings

I'm currently solving an algorithmic problem, but english is not my native language and I'm running into the limits of my language abilities when searching for reasonable solution. The problem: I ...
0
votes
2answers
104 views

Algorithm for figuring out the enemy flag's location in Stratego

I am currently programming a Stratego game in JavaScript, simply because I wanted to learn to use JavaScript while spending some time to keep my programming skills up to par. (My current work ...
0
votes
0answers
16 views

solving a number theoretical problem [migrated]

In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (at least one ...
0
votes
1answer
54 views

Are there any known file dispensing algorithms?

I wish to know if there are any known algorithms for dispensing a list of files for a specified maximum directory size (disc size for example), while attempting to keep output directories size close ...
16
votes
1answer
394 views

3d Packing algorithm for item's shipping

I've received a task to build a shipping estimative that suggests the best accomodation of goods on as few boxes as possible: There is a finite set of known retangular box sizes There are many ...
2
votes
1answer
99 views

Find n nodes farthest away from each other

I'm looking for an algorithm that gives me the n nodes that are the farthest away from each other. Can this be accomplished relatively efficiently? To clarify my question: I think of the problem as ...
4
votes
1answer
116 views

Understanding Boyer-Moore Algorithm

Edit: I've found the original publication. It seems to me that the original does not have a l′(i). But I could be wrong because the definition of rpr(i) is so obscure to me. I'm not sure how it makes ...
0
votes
3answers
140 views

The right algorithm to get perfect combination

I am working on a self-study project but I cannot come up with a reliable answer. Here is the deal: I start with 500cm sticks. I have orders from customers who want smaller sticks. I am willing to ...
1
vote
1answer
42 views

Create a collection with “average points” of N items from a pool with items of various points

Let's say I have a question pool to generate exams out of it. Each question contains a difficulty from 1 (hard) to 99 (easy). The questions are available in a hash / array (adapt to your favorite ...
3
votes
1answer
301 views

Accuracy of “calculator algorithms”

I am building a library class that provides functionality for mathematical operations on BigDecimals (and a few on BigIntegers). Now, BigIntegers are quite easy to master and pleasant to use. ...
3
votes
1answer
59 views

Derive subset with sum between two values

I have a set S of size n whose members each have associated with them a number in the range 0.00 to 1.00 inclusive. I want to select a subset T of size m with this property: the average of the ...
2
votes
3answers
80 views

recalculation model for GUIs

I often come across this problem. Say to have a form with some controls: A B C = A + B D E = C * 2 ONLY IF D==TRUE F G = A - F The user fills A, then B. The system calculates C. The user fills D ...
-1
votes
0answers
58 views

Best algorithm to schedule events

I have a data set of talks to be given at a event which is given by the user. It is assumed that talks are always ending on time and there are two parallel events at the same time. Both start at the ...
-2
votes
1answer
70 views

Given a subset of numbers and subset of sums. Match the numbers to sums.(Harder than appears)

I found the question below on a forum board. I'm not sure what the most efficent solution is. I'm not sure this fits exact cover, and approaching it via exhaustive backtracking seems somewhat ...
-2
votes
0answers
14 views

Print the longest common sequence [migrated]

I am trying to implement solution of the classical problem, but I am confused as I get some cases where I don't find good results. Output: "The Longest common sequence", "Length" def ...
0
votes
2answers
57 views

Algorithm for mapping users to a schedule based on time availability

I have a project where I must map employees to a schedule. The basic concept is: Company Opens between 08:30 and 17:00. Employee 1 can work from 08:30 to 12:00 then from 13:00 to 1700; Employee 2 ...
2
votes
1answer
94 views

What does 'upper bound' mean in context of BigO?

My computer science teacher says Big O has an upper bound but no lower bound. When I look at a graph of an algorithm mapped out using BigO though, there isn't an upper bound at all. The upper limit ...
0
votes
0answers
32 views

An algorithm to implement SQL's ORDER BY with TOP/LIMIT or OFFSET/FETCH

Is there a general algorithm to implement SQL's ORDER BY with OFFSET/LIMIT more efficiently than sorting all the records? The algorithm for a simple TOP x is easy enough. It takes one full pass ...
1
vote
1answer
147 views

Divide and Conquer Algorithm clarification needed

I have a homework assignment for a data structure/algorithm class. The task is to take an unsorted array of size n (example: [-8, 3, 2, -3, 3, 1, -3, -5]), and we have to use a divide and conquer ...
2
votes
1answer
147 views

Converting cron schedule to time intervals

I have, on the server, many jobs defined by users and some of those jobs are scheduled using cron expressions. I need to check (I can execute Groovy/Java on the server) if those jobs take longer than ...
0
votes
0answers
89 views

Tournament bracket customized algorithm

I'm in the making of a tournament for archery but i'm stuck because they want a specific match-matching for players. There is the usual 1-32,2-31,3-30 etc but the way they want the tree is a specific ...
3
votes
1answer
238 views

What makes for a bad case for quick sort?

I am learning about quicksort and want to illustrate different arrays that quicksort would have a hard time on. The quicksort I have in mind does not have an initial random shuffling, does 2 ...
1
vote
4answers
393 views

How to work around Java's lack of pointers to pointers when working with linked data structures? [closed]

I've learned from a textbook how to implement binary search trees recursively in Java, and am working on implementing them nonrecursively. I've found a simple and elegant way to implement an insert ...
1
vote
1answer
98 views

Is it possible to antialias existing lines, circles, text, etc. of a single color?

I want to manually antialias the output of GDI drawing functions on Windows. Each drawing function is rendered onto its own image and then blitted back (so alpha blending can work, as GDI doesn't do ...
0
votes
0answers
28 views

Is this synchronization required in service onCreate method?

Below is a sample code i captured from android doc Per service instance onCreate will be called only once. Ref: here and here The synchronization and singleton doesn't make any sense to me in this ...
0
votes
0answers
135 views

how to use Sql query to search text in CSV file and avoid iteration

I have one A File and many input files ,All files have CSV format . I want to match text of one column of all input files with one of the column of A file . I have stored all column value of File A in ...
0
votes
1answer
110 views

How are the tiles in WORDAMENT organized?

I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating ...
0
votes
0answers
53 views

Floating point number to binary

Which Algorithm does java uses to convert floating point number (Ex:0.15625) into binary(0.00101). Whether java uses normalized form or denormalized format ? If i type "float ab=0.15625" in java ...
2
votes
3answers
190 views

Find all possible subarrays of an Array

I am lost I just can't seem to get my head around backtracking/recursion approaches. I understand how simple recursion problems like factorials work I can even trace those by hand. But when it comes ...
2
votes
1answer
64 views

Need help identifying a league scheduling algorithm

I am trying to create a sports league scheduler. I am having trouble identifying an algorithm to help me efficiently fill in each slot. Sample data to build the schedule would be: 10 teams Each ...
-4
votes
1answer
94 views

Does the head of any linked list must contain any data [closed]

Is there any rule that says the head of any linked list should contain data. Is it because by doing it so we save a space for one node. Why for some implementation of head contains data and for other ...
-1
votes
1answer
99 views

Unevenly distributed random number generation [duplicate]

Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability. How to generate that number? I use Ruby/Python.