algorithm

How do you show that one algorithm is more efficient than another algorithm?

Hi, I'm no professional programmer and I don't study it. I'm an aerospace student and did a numeric method for my diploma thesis and also coded a program to prove that it works. I did several methods and implemented several algorithms and tried to show the proofs why different situations needed their own algorithm to solve the task. I...

slight changes in long lat for varations of point with the same location

Bit of a weird one this. I'm rendering datasets on a map and need to split out points that have exactly the same long and lat. I had the idea of grouping my dataset by long and lat and where they are the same adjusting slightly so that they are visible as seperate entities on the map - rather than overlapping. I'm using linq to group t...

Fuzzy Search on Material Descriptions including numerical sizes & general descriptions of material type

We're looking to provide a fuzzy search on an electrical materials database (i.e. conduit, cable, etc.). The problem is that, because of a lack of consistency across all material types, we could not split sizes into separate fields from the text description because some materials are rated by things other than size. I've attempted a co...

Algorithm for efficient diffing of huge files

I have to store two files A and B which are both very large (like 100GB). However B is likely to be similar in big parts to A so i could store A and diff(A, B). There are two interesting aspects to this problem: The files are too big to be analyzed by any diff library I know of because they are in-memory I don't actually need a diff - ...

An algorithm for aggregation of similar sequences

Let's say you have a list of similar sequences, such as a a a a a b a a a x a a a a y ... You want to detect a common aggregate of all these sequences, such as x? a b? a a a y? where operator ? specifies that element is optional. What algorithm would you use? ...

How to find pythagorean triplets in an array faster than O(N^2)?

Can someone suggest an algorithm that finds all Pythagorean triplets among numbers in a given array? If it's possible, please, suggest an algorithm faster than O(n2). Pythagorean triplet is a set {a,b,c} such that a2 = b2 + c2. Example: for array [9, 2, 3, 4, 8, 5, 6, 10] the output of the algorithm should be {3, 4, 5} and {6, 8, 10}...

extra space for recursive depth-first search to store paths

I am using depth-first search to identify paths in a directed weighted graph, while revisiting nodes that belong to a cycle, and setting cutoff conditions based on total distance traveled, or stops from the source node. As I understand, with recursion an explicit stack structure is not required for depth first search, so I was wonderin...

Algorithms question on an n*n matrix of distances

Suppose I have an n*n matrix of distances between n users. I'd like to know what algorithm to use in order to find a route around the group, beginning at user X and returning to user X, with all other nodes visited once but only once, and using the shortest possible distance in each hop. ...

Algorithm to find palindromes

I'm posting this on behalf of a friend since I believe this is pretty interesting: Take the string "abb". By leaving out any number of letters less than the length of the string we end up with 7 strings. a b b ab ab bb abb Out of these 4 are palindromes. Similarly for the string "hihellolookhavealookatthispa...

What is the execution time T(n) of the algorithms?

Happy new year and peace to you all! Can you please explain to me what is the execution time T(n) of the 2 algorithms? Assuming execution time T(n) = # executions of (a:=a+1) Algorithm 1: for i ← 1 to n do for j ← 1 to i do for k ← j to i+j do a ← a + 1 end for end for end for Algorithm 2: ...

Algorithm to emulate mouse movement as a human does?

Hello I need to test a software that treats some mouse movements as "gestures". For such a task I need to emulate mouse movement from point A to point B, not in straight line, but as a real mouse moves - with curves, a bit of jaggedyness etc. Is there any available solution (algorithm/code itself, not a library/exe) that I can use? Of...

Get adjacent elements in a two-dimensional array?

I have a two-dimensional array, say 0 0 0 0 0 0 2 3 4 0 0 9 1 5 0 0 8 7 6 0 0 0 0 0 0 And i need to get all the numbers adjacent to 1(2, 3, 4, 5, 6, 7, 8, 9) Is there a less ugly solution than: topLeft = array[x-1][y-1] top = array[x][y-1] topRight = array[x+1][y-1] # etc Thanks! ...

How to do related questions autopopulate

I want to get a related [things/questions] in my app, similar to what StackOverflow does, when you tab out of the Title field. I can think of only one way to do it, which i think might be fast enough Do a search for the title in corpus of titles of all [things], and return first x matches. We can use whatever search is being used for ...

Concatenating/Merging/Joining two AVL trees

Assume that I have two AVL trees and that each element from the first tree is smaller then any element from the second tree. What is the most efficient way to concatenate them into one single AVL tree? I've searched everywhere but haven't found anything useful. ...

Math, circles, interior points and densities

The theory is this: I have a circle C of radius R and centre S. Inside this circle, I want to place N (a "big" number) points such that the density of points in the vicinity V of a point P is equal everywhere in the circle for all points. As N goes to infinity and the vicinity goes to P, the density function in both polar and cartesian c...

Optimise Floyd-Warshall for symmetric adjacency matrix

Is there an optimisation that lowers the constant factor of the runtime of Floyd-Warshall, if you are guaranteed to have a symmetric adjacency matrix? ...

Are there any general algorithms for achieving eventual consistency in distributed systems?

Are there any algorithms that are commonly used for achieving eventual consistency in distributed systems? There are algorithms that have been developed for ACID transactions in distributed systems, Paxos in particular, but is there a similar body of theory that has been developed for BASE scenarios, with weaker consistency guarantees...

Drawing triangles with CUDA

I'm writing my own graphics library (yep, its homework:) and use cuda to do all rendering and calculations fast. I have problem with drawing filled triangles. I wrote it such a way that one process draw one triangle. It works pretty fine when there are a lot of small triangles on the scene, but it breaks performance totally when triangl...

How can you efficiently remove duplicate characters from a string?

Is it possible to remove duplicate characters from a string without saving each character you've seen in an array and checking to see if new characters are already in that array? That seems highly inefficient. Surely there must be a quicker method? ...

Glass Effect - Artistic Effect

I wish to give an effect to images, where the resultant image would appear as if we are looking at it through a textured glass (not plain/smooth)... Please help me in writing an algo to generate such an effect. Here's an example of the type of effect I'm looking for The first image is the original image and the second image is the outp...