algorithm

How to detect element transformation type (scale, move, rotate) for rotated elements depending on cursor position?

The situation I've written the following method (in actionscript 3, it's a flash application) which returns what transformation type is required for the current mouse position in relation to a given element position. An element can be moved, scaled and rotated. This method returns if any of these transformations are applicable with the...

Algorithm of naming embedded Pictures in OpenOffice

I need to embed images inside OpenOffice Text documents without the help of OpenOffice itself. For that I need to work directly inside the zip archive and modify the appropriate xml files. The problem I have now is that OpenOffice stores embedded pictures inside a picture folder and asigns a unique name to them according to the informati...

How to get the most represented object from an array

Hi, I have an array with some objects, and there are several objects that are alike. E.g: fruit = [apple, orange, apple, banana, banana, orange, apple, apple] What is the most efficient way to get the most represented object from this array? In this case it would be "apple" but how would you go out and calculate that in an efficient wa...

Search in DBF file using .idx file

I have a DBF file and a index file. I want to read index file and search records satisfy some condition. (for example: search records which its StudentName begin with "A" by using Student.DBF and StudentName.idx) How do I do this programmatically? ...

File name copy algorithms

Hi When I copy following file in Windows in the same directory. "Log.txt" it get copied as "Copy of Log.txt" If now copy "Copy of Log.txt" again , it gets copied as "Copy of Copy of Log.txt" If now again I copy "Copy of Log.txt" it gets copied as "Copy (2) of Copy of Log.txt" Anybody aware of what algorithm is used here. ...

Construct a Tree

How can I construct a tree given its inorder and preorder traversal? I am just looking for an efficient algorithm. ...

Suggested GA operators for a TSP problem?

I'm building a genetic algorithm to tackle the traveling salesman problem. Unfortunately, I hit peaks that can sustain for over a thousand generations before mutating out of them and getting better results. What crossover and mutation operators generally do well in this case? ...

Recursive N-way merge/diff algorithm for directory trees?

What algorithms or Java libraries are available to do N-way, recursive diff/merge of directories? I need to be able to generate a list of folder trees that have many identical files, and have subdirectories with many similar files. I want to be able to use 2-way merge operations to quickly remove as much redundancy as possible. Goals...

How can I convert a function of input size defined recursively into a direct function of problem input size?

Say I have an algorithm which operates on an input of size n and I know that the time it takes for n is twice the time it takes for n-1. I can observe in this simple case (assuming it takes, say, 1 second for n = 0) that the algorithm takes 2n seconds. Is there a general method for converting between recursively-defined definitions to ...

How can I find all of the permutations consisting of 1 element from a variable number of arrays of variable length?

I have an array U of arrays D that vary in length. I need to be able to return all permutations of array indices that would select a different permutation consisting of 1 element from each set. I also require that this alorithm gets represented as an object that only remembers the last permutation, and returns the next permutation with a...

An interview question

Given a linked list of T size , select first 2n nodes and delete first n nodes from them; Then do it for the next 2n nodes and so on... For example- Let's consider a linked list of size 7: `1->2->3->4->5->6->7` If n = 2, the desired output is : `1->2->5->6->7` I didn't understand what this problem is actually indicating.Could...

how do you calculate co-ordinates of point based on constraints relative to other points?

Let me know if this is mathoverflow material, and I'll wend my way over there. I'm hoping someone will recognise this and point me in the right direction... I'm trying to map out related nodes. I've figured out how to calculate the minimum distances between all the points, and now I need to know how to turn those into actual co-ordinate...

Guess Game.. in C#

hey all.. this is my code.. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Guess_Game { class Program { static void Main(string[] args) { int quantity; int min, max; Console.WriteLine("Enter the Quantity of Numbers : "); quanti...

On the formulation of the linear assignment problem

I'm looking at the standard definition of the assignment problem as defined here My question is to do with the two constraints (latex notation follows): \sum_{j=1}^n(x_{ij}) = 1 for all i = 1, ... , n \sum_{i=1}^n(x_{ij}) = 1 for all j = 1, ... , n Specifically, why the second constraint required? Doesn't the first already cover all ...

3 dimensional bin packing algorithms

I'm faced with a 3 dimensional bin packing problem and am currently conducting some preliminary research as to which algorithms/heuristics are currently yielding the best results. Since the problem is NP hard I do not expect to find the optimal solution in every case, but I was wondering: 1) what are the best exact solvers? Branch and...

How can I correlate pageviews with memory spikes?

I'm having some memory problems with an application, but it's a bit difficult to figure out exactly where it is. I have two sets of data: Pageviews The page that was requested The time said page was requested Memory use The amount of memory being used The time this memory use was recorded I'd like to see exactly which pageviews...

Finding a minimum bounding sphere for a frustum

I have a frustum (truncated pyramid) and I need to compute a bounding sphere for this frustum that's as small as possible. I can choose the centre to be right in the centre of the frustum and the radius be the distance to one of the "far" corners, but that usually leaves quite a lot of slack around the narrow end of the frustum This see...

Detecting patterns in waves

Hello all! I'm trying to read a image from a electrocardiography and detect each one of the main waves in it (P wave, QRS complex and T wave). Now I can read the image and get a vector like (4.2; 4.4; 4.9; 4.7; ...) representative of the values in the electrocardiography, what is half of the problem. I need a algorithm that can walk thr...

Efficient Algorithm for comparing only the lists that have been updated

Hi everyone, Even describing this problem is hard, But I'll give it a go. I've been struggling with this for a few days and decided to ask here. OK, so I'm trying to model "concepts", or "things" as I call them. Just concepts in general. It's to do with processing logic. So, each "thing" is defined by it's relationship to other things...

Selection of an inefficient data structure, what problems it can create for us???

Suppose i have a software program which uses an inefficient data structure. Now how can i make it efficient. it seems that we should simply change the data structure but its not the case in reality. according to my point of view the whole software needs to be changed. what is your point of view? ...