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)

7
votes
2answers
434 views

Algorithm to merge two sorted arrays with minimum number of comparisons

Given are two sorted arrays a, b of type T with size n and m. I am looking for an algorithm that merges the two arrays into a new array (of maximum size n+m). If you have a cheap comparison ...
1
vote
0answers
67 views

Design an algorithm with network flow

Given a matrix A with 0 and 1 entries. Neighbours of a[i,j] are a[i-1,j], a[i+1,j], a[i,j-1] and a[i,j+1] (if exists any). Tow neigbour entries are an Improper pair if they have not equal values. if ...
2
votes
1answer
132 views

Hash function with uniqueness guarantees and controllable entropy

Is there a class of hash functions that meets the following specs: Upper and lower bound can be specified Uniqueness is guaranteed as long as the input is between the upper and lower bounds Amount ...
0
votes
0answers
34 views

Silverlight-based “area of influence” algorithm

I am in the process of developing a tool for a game called MechWarrior: Online which defines a map of an area of space called the Inner Sphere. Essentially, this map is a set of points (planets) on a ...
0
votes
1answer
145 views

Shortest path to visit all nodes [duplicate]

I am given a set of tourist attractions(nodes identified by x, y) and i need to find the shortest path to visit them. The way i thought of it, is i will ignore if there are streets available and ...
1
vote
0answers
79 views

Algorithm for sweeping a 2d shape along a curve?

I am trying to create a graphics application where the user can use an arbitrary shape as a "brush", which will be swept along the drawing path. The shape may be transformed along the path (rotated, ...
2
votes
3answers
145 views

How to code a one-sided virtual economy

I'm attempting to make an online game with a mini-economy in it. The challenge is that the only person selling anything will be the website itself, and hence the supply and demand curve doesn't apply ...
1
vote
1answer
54 views

Algorithm to find the fewest number of values (from a set of values) where the sum equals a value (+ one more condition)

The simplest way to explain this is with an example. You're given then number 19 and you have a set of numbers to choose from: 1, 2, 3, 4, 6 When choosing values from the list (which can be ...
-2
votes
0answers
35 views

Source of extensive, battle-tested Unit Tests [closed]

Where can I find solid, proven unit tests for common data structures and algorithms? I'm giving an introductory class, that covers basics such as lists (linked, array-based, tree-based, etc.), ...
-2
votes
0answers
35 views

Find the number of increasing Sequence of length K [on hold]

Let we are giving a Array we have to find the number of increasing sequence of length K. 1 2 3 1 1 For the first window of [1, 2, 3], there are 3 non-decreasing subranges so the answer is 3. For ...
0
votes
3answers
101 views

Concept for dealing with recurring appointments

Our company implemented a calendar system a few months back with recurring appointments, using iCal strings to store the recurring appointment criteria. We are starting to run into performance ...
0
votes
0answers
30 views

Algorithm for intersection of two convex polygons among set of m convex polygons in a plane

There are set of m convex polygons(p1, p2, p3…pm) in a plane. Pi contains ni number of vertices. All total n1+n2+…+nm=n vertices. Two convex polygons intersect if either their boundaries intersect or ...
28
votes
7answers
4k views

Is there any algorithm pattern to protect any content in the web to ensure I am the first one who created it?

A few years ago there was this hacker (don't remember who he was) that full disclosed a vulnerability in a given system, but to make sure nobody took credit for that, he created some kind of PGP key. ...
2
votes
0answers
36 views

Merge directed acyclic graphs minimizing number of nodes

I have some DAGs (directed acylic graphs) and I want to merge them in order to minimize the number of nodes (we could say that every node has a cost, while edges are free). These four different DAGs ...
0
votes
1answer
75 views

Permutting a list of numbers in order to get a list which satisfies given condition

Here is algorithmic problem I'm trying to solve: Given a list [x_1,x_2,...,x_n] return a permutation of elements of the list [y_1,y_2,...,y_n] (where for each i we have y_i = x_j for only one j) ...
0
votes
2answers
88 views

Porting an algorithm implementation licensed under GNU GPL v3

I'm working on a JavaScript port of a red-black tree implementation in Java from the book Algorithms 4th Edition, by Sedgewick and Wayne. I believe that my JavaScript port qualifies as a derivative ...
2
votes
1answer
143 views

Matching algorithms in context of data quality problems

I work for an organization that has lots of databases containing person information. The data quality is poor. One case was a surname I found like this (this is the worst-case scenario): Mark ...
0
votes
0answers
77 views

RGB => HSL => hue range name conversion algorithm off by positive 60 degrees [migrated]

Background For practice (in ruby) I am implementing some color conversion algorithms. I have attempted to convert pseudocode avilable on EasyRGB.com to Ruby. The conversion seems to be working fine. ...
0
votes
1answer
67 views

Matrices calculations on partial shape matching

I'm working in a shape recognition project where it is supposed for me to develop an application that receives two images: an original one and a sketch made by a user. I am supposed to detect contours ...
0
votes
2answers
90 views

Track a series of choices with a single number

I want to track a series of scored questions in a single number (the total score). Is that possible? and how? For example, I have 30 questions with either 3 or 2 choices. For any given question, the ...
0
votes
0answers
49 views

Excel-like column numbering [migrated]

I have a working code (below) to convert a number to Excel-like (A...Z AA...AZ BA...BZ ...ZA-ZZ) column codes (headers). For simplicity I limited it to 1 or 2 character codes. My question is: ...
0
votes
0answers
51 views

Test if a point is inside or outside a 3D polygon

I'm wondering if there is an algorithm (or a code written in FORTRAN) that gives whether a 3D point is inside or outside a polygon having triangles as faces (an .stl file from gmsh for example). Most ...
0
votes
1answer
86 views

Finding same numbers in a matrix

I have a question here and I am trying to find a solution of it. But I want to see some other opinions as well. The problem is the following: There is a matrix NxN which holds integer numbers. ...
1
vote
1answer
87 views

Generate algorithm to solve peg solitaire

I know that with regression it is possible to generate a mathematical function based on experimental data. I was wondering, maybe there is a way to generate something more complex. I have a single ...
3
votes
1answer
76 views

How do I efficiently send notifications for different events to different users based on their preferences?

I'm creating a notification system for particular events. A user can set the criteria that match particular events (ie. New item, changed item, closed item etc) Items have different characteristics ...
1
vote
2answers
98 views

On-the-fly, random partition of a range of numbers [0,N] in groups of max M size

Suppose that you have a range of numbers from 0 to N that you want to randomly separate in groups of max M sequential numbers. This is easily done with a bitmap and a random number generator, but it ...
4
votes
3answers
110 views

Algorithm Analysis: In practice, do coefficients of higher order terms matter?

Consider an^2 + bn + c. I understand that for large n, bn and c become insignificant. I also understand that for large n, the differences between 2n^2 and n^2 are pretty insignificant compared to the ...
0
votes
0answers
52 views

Algorithm for sport tournament bracket tree

I would like to develop a library that: receive n players in input response with the tournaments brackets in output. I would ask you what kind of algorithm I have to use to choose the correct tree ...
1
vote
1answer
39 views

What algorithm-family or problem-space description fits? Industrial process feeding ingredients to process

Our process continuously feeds (normally <= 8) ingredients from a choice of hundreds, using 3 feeders only. So if ingredient count X is > 3, 3 through X are stirred together in a batch process and ...
2
votes
0answers
74 views

In a mutual credit network, how would you program an automatic jubilee?

A little explanation might be needed. I mean mutual credit the way that it's defined here: a type of alternative currency in which the currency used in a transaction can be created at the time of ...
1
vote
2answers
168 views

Most Efficient way to Compute the sum of divisors of N (1 ≤ N ≤ 1 000 000 000)

I want to write a code which computes the sum of divisors of a number N(1 ≤ N ≤ 1 000 000 000), excluding the number itself. However, I need an efficient way to do it. It suppose to print the answer ...
2
votes
1answer
121 views

moving around virtual keyboard

I'm creating virtual keyboard using javascript/html/css. And I can't find a good algorithm for moving from one button to another in different directions (top-bottom, left-right). Lets say I ...
1
vote
1answer
112 views

Is this still a Greedy Algorithm

As a preface I will state this is for a homework assignment. I have already discussed this with the professor and will not be using this design. This purpose of this question is whether or not the ...
3
votes
2answers
205 views

Why Do B+ Trees Have a Minimum Occupancy of 50%?

As far as I can tell, the basic operations (add, delete, search) on a B+ Tree would function the same if minimum occupancy was 1, or 1/3, or any other function on node size. All the sources available ...
2
votes
2answers
139 views

Finding shortest path between nodes with a twist

Note: if you feel that I should include code, please tell me. I am solving a problem of finding shortest path between nodes. I am given the vertices between nodes, however they are one sided (ie you ...
0
votes
0answers
54 views

Find 'Connected Components' in undirected, unweighted graph coded as a 2d array

Given an undirected, unweighted graph coded as a 2d array, how can I find the number of different connected components? Example There is the following 2d array (I'm not putting any brackets to ...
23
votes
8answers
6k views

Function guaranteed to never return the same value twice [closed]

This is a question I was asked at a job interview, and I can't figure out the answer they were looking for, so I'm hoping someone here might have some ideas. The goal is to write a function that is ...
0
votes
1answer
56 views

Simulated Annealing Contradiction?

The entire idea of simulated annealing is to avoid getting stuck in local optimums, which is why sometimes, a worse solution is accepted. However, simulated annealing will automatically accept a ...
0
votes
1answer
185 views

Why does this evaluation function work in a connect four game in java

I am exploring how a Minimax algorithm can be used in a connect four game. I was looking through a program and found this evaluation function. private static int[][] evaluationTable = {{3, 4, 5, 7, ...
0
votes
1answer
52 views

Rideshare algorithm to be used for scheduled and adhoc journeys

I need some help writing some pseudo code for a rideshare system for taxi drivers. The idea behind it is that it would combine real-time incoming taxi journeys and pre-bookings in real-time. The ...
0
votes
1answer
130 views

What is the justification for the running time of this loop?

I don't understand why the running time of the following loop is n+2 ? Also why the running time of the statements inside the loop is n+1 ? Double test(int n){ int sum=0; -> 1 time ...
3
votes
4answers
295 views

Mark x% items in stream

There are n items (n is known and > 1,000,000,000). I want to randomly 'mark' x% of n-items in stream. (n and x are known) Items are in stream ,one directional (you can't go back) processed item ...
2
votes
1answer
87 views

Finding the fewest sets which contain all items

I am wondering if there is a known algorithm for solving the following. Data: There is a number of sets containing items. An item can be a member of more than one set. Aim: return the minimum number ...
1
vote
0answers
67 views

Walk Tree vs Zhang and Sasha Algorithms

I need some help understanding how two tree comparing algorithms differ. I am working with Microsoft's XmlDiffPatch (http://msdn.microsoft.com/en-us/library/aa302294.aspx) which compares two xmls. The ...
0
votes
1answer
133 views

Which algorithm best fits the following problem [closed]

I'm looking for the right algorithm to solve a specific problem. I hope that there are known algorithms that can be used. The problem definition Given a set of 'options' (~10) A session is defined ...
4
votes
2answers
176 views

Extracting first and last name from a single name field

I'm working with the Twitter API which provides only a single field called name, which includes the full name of a person. The application that we're constructing requires a first name and a last ...
0
votes
1answer
86 views

Handling the process of large-scale lists [closed]

What are the efficient ways to process huge lists (+10 millions), and things to consider while manipulating huge lists. First question, when should I use recursion, and when I shouldn't. In both ...
2
votes
2answers
177 views

An algorithm that spreads similar items across a list

I need an algorithm that distributes same items across a list, so maximizing the distance between occurrences. E.g. I have a list of 15 items: {a,b,c,c,c,d,e,f,f,f,g,h,h,i,j} The algorithm should ...
12
votes
2answers
916 views

How to calculate figure rotation efficiently?

I have a Figure represented through a matrix of bytes (bitmap-like matrix). Example Figure is shown on the Picture 1. The goal is to find the best rotation angle of some given Figure. When Figure ...
1
vote
1answer
186 views

How to find duplicate strings

I allow my user to create profiles, meaning they potentially could create some with duplicate names. This can be problematic so I want to prevent them from doing so. I coded up this first pass ...