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)

2
votes
0answers
51 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
97 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
131 views

Algorithm for finding automorphisms of a string in O(n) time

I recently stumbled upon this problem, which requires a solution in O(n) time, and I'm struggling to find a correct one. The obvious, naive solution runs in O(n²) time. Any ideas? A string S = ...
3
votes
2answers
198 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
115 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
43 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
5k views

Function guaranteed to never return the same value twice

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
48 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
140 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
51 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 ...
-5
votes
1answer
76 views

What is the time complexity for the following program? [closed]

I really don't know if this is the lame question, but please tell me the time complexity of the following code. for(i=0;i<n;i*=2){ // will each stmt gets executed O(log n) times? }
0
votes
1answer
129 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
0answers
69 views

Python algorithms for poker hands? [closed]

I am in the middle of writing a Texas Hold'Em poker program in Python and need some algorithms. I'm sure I can write these but I'd like to see if someone already has something similar to this. NOTE I ...
3
votes
4answers
288 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
84 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
64 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
131 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
173 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
82 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 ...
0
votes
0answers
13 views

Python: algorithm for describing chess positions [migrated]

I have an interesting problem with my chess application. The application reads PGN files, and at any time while viewing a game from the file, the function below, when called, iterates over the ...
2
votes
2answers
171 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
882 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
168 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 ...
3
votes
1answer
146 views

What advantages are there to using Flex/Bison over just writing a compiler straight in a programming language?

I have written an Interpreter / Compiler simply as a programming algorithm using features such as recursive functions and concepts from finite-State machines. To me, these things are ideally suited to ...
1
vote
1answer
201 views

Assembly vs. algorithmic languages (like C, Algol, etc)

Usually, computer science papers describe algorithms in Algol-like pseudolanguage, similar to Pascal or even C/C++. But Donald Knuth uses his own assembly language (MMIX). Are there any good known ...
1
vote
2answers
117 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
0answers
55 views

Does multiple Bloom filters make sense?

In order to decrease the number of false positives, I came up with a couple of possible solutions. Create two different types of Bloom filters; eg. filter1 using 3 different hash algorithms, filter2 ...
2
votes
1answer
181 views

Quickest sorting algorithm for sorting a low number of integers

I am making a program on my spare time that I want to run as quickly as possible. The program is written in C. A large set of the procedures operate on pointers to 7 integers that are sorted by their ...
-4
votes
1answer
97 views

how to write example code for this sequence number? [closed]

I want to ask you a question. How is the example code (just an algorithm in any language programming) for this sequence: 1, 2, 3, 1, 4, 2, 5, 3, 4, 5, 1, 6, 2, 7, 3, 6, 4, 7, 5, 6, 7, 1, 8, ... It ...
0
votes
1answer
100 views

Method ordering

This is the type of question that one would probably get in an exam, but now it happens to be in the real word. :-) I would appreciate some advice regarding the datastructure/algorithm that can be ...
1
vote
2answers
60 views

multiple comparison sorting

I have a set of songs where I want to sort them by a particular quality. In order to do this (by crowdsourcing) I will present users with a comparison between two songs. The user will then choose ...
1
vote
4answers
232 views

Order by different Enum property each row

So I have a list of DefaultSearchModal items that have an enum called TypeSearch in every list item. I would like to order the list to have a different enum property each row. So if you have an ...
0
votes
1answer
68 views

How to compute data for charting?

I'm building a charting component that displays data directly from the raw data records. It should be able to filter data (subset) and then perform some rudimentry maths on the data (sum, avg, etc). ...
0
votes
0answers
10 views

What is an example of a minimum weight connected subset T of edges from a weighted connected graph G? [migrated]

What is an example of a minimum weight connected subset T of edges from a weighted connected graph G? Can I just take two edges that are connected and have min combined weight and call that the min ...
1
vote
0answers
46 views

Incorporating custom Algorithm in SOLR-LUCENE , before Indexing?

CURRENT FLOW: I am using a custom algorithm(presently in php) to rank the MYSQL records before INDEXING it to SOLR . WHAT I WANT : Is it possible implementing this ALGORITHM(may be in JAVA) inside ...
0
votes
1answer
22 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. ...
1
vote
0answers
61 views

How to find minimum weighted vertex cover of a tree, and confused about a solution

Studying for my algorithms test by spamming Algorithm Design Manual exercises, but I'm stuck on this one. I know I have to keep score somehow. Let G = (V,E) be a tree with arbitrary weights ...
1
vote
1answer
82 views

Safe serial numbers generation

I want to generate a 6 digits serial number, ranged from A-Z (only uppercase allow), e.g. serial = "ABCDEF" the problem is, some letters are considered confusing to others letters/numbers, e.g. U ...
0
votes
0answers
25 views

Arduino ADC value and practices to store data to buffer

I'm writing Arduino application which has timer interrupt to acquire ADC value. Main loop has serial transmission procedure to send data from buffer. I'm not sure how to store data in buffer. Best ...
0
votes
0answers
41 views

Developing a “time scheduler” app [duplicate]

I need to develop an application to generate, given a set of preferences and constraints, a time schedule for employees. These tables can really get complex and they might need to take into account ...
0
votes
1answer
118 views

Is it possible to apply Master Theorem for finding the square and cube root

I was asked to calculate the running time of an algorithm which finds the square root and cube root of a given number. Is it possible to apply Master theorem with regards to this? First, I need to ...
0
votes
3answers
155 views

How would you go about compressing a list of integers that are non unique and retain the original order?

Let's start out with an example [1,1,1,5,3,1,1,2,78,2,3,1,1,...,1] As you can tell by the example, 1 is repeated a lot, but there will be outliers (like 78, and really anything that isn't 1). The ...
0
votes
0answers
16 views

A heuristic approach to Clique problem over undirected Graph

I'm trying to get all complete subgraph given a graph G. Needless to say it is an NP-problem complete: Clique_problem. I understand getting the full set is not possible in real time(since it'll take ...
3
votes
2answers
80 views

Process to generate hierarchical structure based on relational data?

I have a csv of employee ids, names, and a reference column with the id of their direct manager, say something like this emp_id, emp_name, mgr_id 1,The Boss,, 2,Manager Joe,1 3,Manager Sally,1 ...
3
votes
4answers
165 views

Algorithm for a UI showing X percentage sliders whose linked values always total 100%

A system I'm building includes a set of UI sliders (the number varies) each with a scale of 0-100. By slider I mean a UI where you grab an element and drag it up and down, like a volume control. They ...
0
votes
0answers
34 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 ...
1
vote
1answer
54 views

Algorithm to “de-rasterize” a voxel image of a polyhedron

Rasterizing a polygon in this question consists of creating an array of binary pixels that "represent" the polygon. The reverse of this process is easy to approximate in linear time to the perimeter ...
3
votes
1answer
45 views

How to diversify an optimal solution set?

If given a list of players, their salaries, and their projections, one can easily find the top 'n' projected teams (where a team is a combination of players), such that every team is under the salary ...
1
vote
1answer
65 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
133 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 ...