algorithm

plane bombing problems- help

I'm training code problems, and on this one I am having problems to solve it, can you give me some tips how to solve it please. The problem is taken from here: https://www.ieee.org/documents/IEEEXtreme2008_Competitition_book_2.pdf Problem 12: Cynical Times. The problem is something like this (but do refer to above link of the source ...

Generate all the ways to intersperse a list of lists, keeping each list in order.

Given a list of lists like this [[1,2,3],[a,b,c,d],[x,y]] generate all permutations of the flattened list, [1,2,3,a,b,c,d,x,y], such that the elements of each sublist occur in the same order. For example, this one is okay [a,1,b,2,x,y,3,c,d] but this one is not [y,1,2,3,a,b,c,x,d] because y must occur after x, that being how x a...

Algorithm for generating an array of non-equal costs for a transport problem optimization

I have an optimizer that solves a transportation problem, using a cost matrix of all the possible paths. The optimiser works fine, but if two of the costs are equal, the solution contains one more path that the minimum number of paths. (Think of it as load balancing routers; if two routes are same cost, you'll use them both.) I would l...

How to detect if an ellipse intersects(collides with) a circle

I want to improve a collision system. Right now I detect if 2 irregular objects collide if their bounding rectangles collide. I want to obtain the for rectangle the corresponding ellipse while for the other one to use a circle. I found a method to obtain the ellipse coordinates but I have a problem when I try to detect if it intersect...

Reducing a set of non-unique elements via transformations

I have: 1) a "starting set", a multiset, e.x. { x, y, z, z }, 2) a set of transformations, e.x. {x,z} => {y}, {z,z} => {z}, {x} => {z}, {y} => {x}, and 3) a "target set" that I am trying to get by applying transformations to the starting set, e.x. { z }. I'd like to find an algorithm to generate the (possibly infinite) possible appli...

Determining the best audio quality.

How can you determine the best audio quality in a list of audio files of the same audio clip, with out looking at the audio file's header. The tricky part is that all of the files came from different formats and bit rates and they where all transcoded to the same format and bit rate. How can this be done efficiently? ...

question about missing element in array

i have following problem from book introduction algorithm second edition by MIT university problem is following An array A[1 . . n] contains all the integers from 0 to n except one. It would be easy to determine the missing integer in O(n) time by using an auxiliary array B[0 . . n] to record which numbers appear in ...

grid traversal question

Possible Duplicate: Looping in a spiral Given a grid of any height and width, write an algorithm to traverse it in a spiral. (Starting at the top left and ending in the middle) without passing over previously visited nodes. Without using nested loops. ...

Algorithm - Numbering for TOC (Table of Contents)

I want to implement a VBA function to number Excel rows based upon the grouping depth of the row. But I think a general algorithm for generating TOCs is more interesting. The problem is: Given a list of "indented" lines such as One Two Three Four Five Six (the "indentation level" may be assumed to be known and part of the in...

How did this programmer achieve this calculator inside of a game?

Link here: YouTube Video I'm curious and thinking for a long time now I have no idea how this man pulled it off. I just see levers and thread going and coming into cogs at random so it seems. Can someone shed some light for us curious geeks. :) ...

Find the period of over speed ?

Just something interesting come in my mind. Assume that we have a table (in SQL Server) like this: Location Velocity Time for example: Location Velocity Time 1 40 1:20 2 35 2:00 3 45 2:05 4 50 2:30 5 60 2:45 6 48 2...

Algorithm Complexity: MD5 or SHA1

Which is the best overall hash algorithm. md5 or sha1. From what I know md5 is faster that sha1 but SHA1 is more complex than md5. I am missing anything ...

Runtime error in my mergesort implementation

I have written the following mergesort code. public class mergesort { public static int a[]; public static void merges (int work[], int low, int high) { if (low==high) return; else { int mid = (low+high)/2; merges(work,low,mid); merges(work,mid+1,high); ...

intersecting line and array of points?

hi, i am having a line in normal graph,i want to know intersecting some points with that line , any formula for it?any help please? The line is from startpoint(50,50),endPoint(50,0)....the some point may be (0,10),(2,45),etc.. ...

Better way to summarize data about stop times?

This question is close to this: http://stackoverflow.com/questions/2947963/find-the-period-of-over-speed Here's my table: Longtitude Latitude Velocity Time 102 401 40 2010-06-01 10:22:34.000 103 403 50 2010-06-01 10:40:00.000 104 405 0 2010-06-01...

Question about permute-by-sorting

In the book "Introduction to Algorithms", second edition, there is the following problem: Suppose we have some array: int a[] = {1,2,3,4} and some random priorities array: P = {36,3,97,19} and the goal is to permute the array a randomly using this priorities array. This is the pseudo code: PERMUTE-BY-SORTING (A) 1 n ← length[A] ...

What kind of data processing problems would CUDA help with?

Hi, I've worked on many data matching problems and very often they boil down to quickly and in parallel running many implementations of CPU intensive algorithms such as Hamming / Edit distance. Is this the kind of thing that CUDA would be useful for? What kinds of data processing problems have you solved with it? Is there really an upl...

New to AVL tree implementation.

I am writing a sliding window compression algorithm (LZ77) that searches for phrases in a "moving" dictionary. So far I have written a BST where each node is stored in an array and it's index in the array is also the value of the starting position in the window itself. I am now looking at transforming the BST to an AVL tree. I am a lit...

Simple ranking algorithm in Groovy

I have a short groovy algorithm for assigning rankings to food based on their rating. This can be run in the groovy console. The code works perfectly, but I'm wondering if there is a more Groovy or functional way of writing the code. Thinking it would be nice to get rid of the previousItem and rank local variables if possible. def fo...

Is there a name for the technique of using base-2 numbers to encode a list of unique options?

Apologies for the rather vague nature of this question, I've never formally been taught programming and Google is rather useless to a self-help guy like me in this case as the key words are pretty ambiguous. I am writing a couple of functions that encode and decode a list of options into a Long so they can easily be passed around the ap...