Tagged Questions

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)

0
votes
1answer
77 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
46 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
70 views

What is the time complexity for the following program? [on hold]

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
122 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
58 views

Python algorithms for poker hands? [on hold]

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
282 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
80 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
60 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 [on hold]

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 ...
-3
votes
0answers
74 views

Alphanumeric addition [on hold]

Suppose I have the following problem: ZEROES + ONES = BINARY where every letter stands for a different decimal digit. Such problems are known as "alphanumerics". Does anyone know an algorithm for ...
4
votes
2answers
169 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 ...
-5
votes
0answers
56 views

Pseudo code of 3 digits reversed [closed]

Pseudo code is one of the way of algorithm representation. It have its own procedure to write a program using this method. Let us say we are expected to write a program that finds the product of two ...
0
votes
1answer
82 views

Handling the process of large-scale lists [on hold]

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
58 views

How to verify external process succeeded completely [closed]

I am developing a web application, where users can take surveys. However, the surveys are run by other websites. Therefore I cannot verify if the user has finished the survey. How can I approach ...
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
160 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
870 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
159 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
142 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
198 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
113 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
170 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
99 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
230 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
41 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
20 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
52 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
77 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
23 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
40 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
115 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
151 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
15 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
158 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
52 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
61 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
131 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 ...
1
vote
0answers
50 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 ...
2
votes
1answer
83 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
75 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
56 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
48 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 ...