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)

17
votes
6answers
2k views

How to turn truth table into smallest possible if / else block

How can I take a truth table and turn it into a compacted if block? For instance, let's say I have this truth table where A and B are conditions and x, y and z are possible actions: A B | x y z ...
24
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. ...
0
votes
0answers
22 views

Line wrapping with variable number of lines… almost there! [on hold]

I'm fiddling a way to split a string in a variable number of lines. It's working but I would like the lines to be a bit more even in size so that they take less space horizontally. I've been over it ...
0
votes
3answers
97 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 ...
7
votes
1answer
3k views

Shortest Common Superstring: find shortest string that contains all given string fragments

Given some string fragments, I would like to find the shortest possible single string ("output string") that contains all the fragments. Fragments can overlap each other in the output string. ...
10
votes
8answers
1k views

Is there a subset of programs that avoid the halting problem

I was just reading another explanation of the halting problem, and it got me thinking all the problems I've seen that are given as examples involve infinite sequences. But I never use infinite ...
0
votes
0answers
28 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 ...
-2
votes
0answers
25 views

Algorithm for 2D general sweep - Implementation? [on hold]

Please help! I have been reading and re-reading two papers: Approximate General Sweep Boundary of a 2D Curved Object and Polygonal boundary approximation for a 2D general sweep based on envelope ...
2
votes
0answers
27 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 ...
-4
votes
0answers
40 views

How to print The sequence of numbers in structure array [on hold]

I have the task which cannot be solved. My task is create a sequences of cards. How print my sequences ? i really need help. my solution #include <iostream> #include <fstream> #include ...
2
votes
3answers
170 views

Count unique visitors by group of visited places

I'm facing the problem of counting the unique visitors of groups of places. Here is the situation: I have visitors that can visit places. For example, that can be internet users visiting web pages, ...
0
votes
2answers
176 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 ...
-2
votes
0answers
39 views

What are the Steps/Algorithm to load/Parse an XML File? [on hold]

I want to write an xml parser by my own, its a project given to me, and i should complete it, i know to search for a string, load files into memory using vectors, but is theres a way i can use this to ...
0
votes
1answer
72 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) ...
-4
votes
0answers
73 views

Divide an Array into n subarray such that each subarray have equal sum? [closed]

You are given an array of a given length. Now we have to determine whether we can Divide the array into n sub-array such that all of them have equal sum . Note: Each sub-array may or may not have ...
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. ...
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 ...
-1
votes
1answer
126 views

Finding all subsets of a set running time

Given a set {1,2,3} output { {}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3} } I have only been able to find as fast as O(2^n), is there any techniques for achieving faster results (besides ...
-1
votes
0answers
19 views

Best way to aproach creating an MRP [closed]

Ive been ask if I could create an MRP (Material requirements planning) program, from what I have read its seems like a complex program manager, I've been working on it for a couple of days now, and ...
0
votes
2answers
84 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
128 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 ...
7
votes
5answers
8k views

How to handle large numbers?

Well, I've just started doing puzzles and it's so annoying to see puzzles which are easy to do but also need to handle very large numbers. That's the problem. Say I have to deal with numbers like 10 ...
0
votes
0answers
43 views

All pair algorithm implementation [closed]

I need to know how to implement all pair algorithm in java... i am newbie for this kind of algorithm implementation .kindly help me with some suggestion. I have to generate possible test cases for ...
0
votes
1answer
63 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 ...
1
vote
2answers
138 views

Finding common prefixes for a set of strings

I am trying to find common prefixes for a sorted set of strings. i.e. if the following strings are given: AB123456 AB123457 ABCDEFGH ABCDEFGX1 ABCDEFGY XXXX then my function should return three ...
0
votes
1answer
77 views

Easiest algorithm implementation of a game tree? [on hold]

I want to create an algorithm to play out all possibilities in this game and print the most optimal moves. (This is a variant of mancala. You don't need to play the game to understand my code (the ...
0
votes
2answers
89 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
1answer
178 views

How can I rank teams based off of head to head wins/losses

I'm trying to write an algorithm (specifically in Ruby) that will rank teams based on their record against each other. If a team A and team B have won the same amount of games against each other, then ...
0
votes
0answers
49 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 ...
2
votes
1answer
117 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
88 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 ...
-3
votes
0answers
39 views

Make a prime number from specified number, by concatenating some more digits to right? [closed]

I am given a number, I don't know whether it's prime or not. The algo says, For eg - Step 1 - Convert char to ints. (Hello - 72101108108111) Ascii values Step 2 - Make a large number. Convert char ...
2
votes
3answers
266 views

Best practices for geolocation

We are writing a flight search engine. We want to pre-fill the departure airport for mobile users with the closest one to their location. To do that, our plan is to Find a list of airports with ...
1
vote
1answer
77 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
1answer
92 views

How can I approach creating an efficient algorithm for maximizing value with these specific constraints?

I'm having trouble coming up with an approach that isn't n^2 for this problem. Here's a contrived, simplified version I've come up with: Let's say you're a company that needs 4 employees to launch in ...
7
votes
3answers
896 views

What is the Bible of Hashing?

Is there a Cormen-like reference on Hashes and Hashing? This particular structure has seen little attention in my CS education for some reason but I'd like to learn more as they seem to be everywhere. ...
0
votes
2answers
414 views

Kth Optimal path in a matrix

I had the following question I was trying to solve: You are given a n*n matrix. Every cell of the matrix contain some value (positive). You are currently at (0,0) and you have to go to right ...
0
votes
0answers
161 views

Karger's algorithm for bin-packing?

I first came across that algorithm as the "Random minimum cut" algorithm. And recently a colleague was trying to pack a big quantity of small textures into one image file. Then it clicked - why not ...
0
votes
1answer
176 views

Calculate reachability of one point from another

I have an array which stores a set of positive x coordinates in sorted way, say arr={1, 4, 5, 9, 12, 45} etc. And I have a maximum distance k which I can go from one point to another point let ...
0
votes
1answer
38 views

Min weight feedback edge set with DFS?

Exercise from The Algorithm Design Manual 6-10. [4] Let G = (V,E) be an undirected graph. A set F ⊆ E of edges is called a feedback-edge set if every cycle of G has at least one edge in F. ...
0
votes
1answer
83 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
86 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 ...
12
votes
6answers
2k views

Are all programming problems algorithm problems? [closed]

I like how "Introduction to Algorithms" by Cormen et al. conveys knowledge. One reason is that everything has to do with programming problems and the book is not implemented in any particular ...
3
votes
3answers
430 views

NLP - Queries using semantic wildcards in full text searching, maybe with Lucene?

Let's say I have a big corpus (for example in english or an arbitrary language), and I want to perform some semantic search on it. For example I have the query: "Be careful: [art] armada of [sg] is ...
0
votes
3answers
165 views

An algorithm for finding converse duplicates of ordered pairs

Given an array of ordered pairs of values, is there a well-known algorithm to find converse duplicates? [Converse meaning the same values, but in the opposite order.] That is, given ...
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
94 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
109 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
47 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 ...