algorithm

Minimum and maximum of a box?

Given the, width, height and depth of a box and its center point, how could I find the minimum, x, y, and z coordinate and the maximum x, y and z coordinate without bruteforcing through each vertex? its an AABB box. Thanks from a top view --------------- | | | | | c | | | |-------------...

Where can I learn more about relativisations of P and NP?

A landmark paper entitled "Relativisations of the P =? NP Question" by Theodore Baker, John Gill, and Robert Solovay was published in the SIAM Journal of Computing Vol.4, No.4, December 1975. It talks about the P vs. NP problem and introduces methods of relativisations. I have the paper, but I'd like to know more about testing an algor...

non-monotonic complexity algorithm

as a thought exercise, I try to think of algorithm which has nonmonotonic complexity curve. only thing I could think of was some algorithm with asymptotic solution in extremities. Is there such algorithm, which has nonmonotonic complexity curve, which does not rely on asymptotic approximation? ...

Finding object under mouse

I'm developing a game that basically has its entire terrain made out of AABB boxes. I know the verticies, minimum, and maximum of each box. I also set up my camera like this: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(Camera.rotx,1,0,0); glRotatef(Camera.roty,0,1,0); glRotatef(Camera.rotz,0,0,1); glTranslatef(-Camera.x,-C...

Least Recently Used cache using C++

hi, I am trying to implement LRU Cache using C++ . I would like to know what is the best design for implementing them. I know LRU should provide find(), add an element and remove an element. The remove should remove the LRU element. what is the best ADTs to implement this For ex: If I use a map with element as value and time counter as ...

Calculating frequency from amplitude and bitrate

Hey Stackoverflow; I currently have an array full of data which from what I believe is the Amplitude of my wave file. It is currently at a low -32768 and at a high 32767. I also have the SampleRate which was 16,000hz. My understanding of sound isn't very good; does anyone know from this how I can calculate the Frequency? Help greatly...

Word boundary detection from text

Hi, I am having this problem with word boundary identification. I removed all the markup of the wikipedia document, now I want to get a list of entities.(meaningful terms). I am planning to take bi-grams, tri-grams of the document and check if it exists in dictionary(wordnet). Is there a better way to achieve this. Below is the sample ...

Bidirectional A* (A-star) Search

I'm implementing a bidirectional A* search (bidirectional as in the search is performed from both the origin and destination simultaneously, and when these two searches meet, I'll have my shortest path - at least with a bit of extra logic thrown in). Does anyone have any experience with taking a unidirectional A* and bidirectionalising(...

Damas-Hindley-Milner type inference algorithm implementation

I'm looking for information about the well-known Damas-Hindley-Milner algorithm to do type inference for functional languages, especially information about implementation. I already know how to do the W-algorithm, but I heard about recent new algorithms based on constraint generator/solver rather than usual unification. However, I can't...

Group together all the anagrams

Problem statement: You are given a set of k strings, each length n. You have to output the group of anagrams together. Anagrams are like e.g atm - mat , like-kile. ...

ParallelFor code for finding sum of few elements in an array (Subsetsum problem)

I have the following C# code fragment: using System; class count { public static void Main() { int [] a = {-30, 30, -20, -10, 40, 0, 10, 5}; int i,j,k; int N=8; for (i=0; i < N; ++i) for (j=i+1; j < N; ++j) for (k=j+1; k < N; ++k) if (a[i] + a[j] + a[k] == 30) Console.WriteLine (a[i].ToString () + a[j].ToSt...

Trying to come up with an algorithm to sort to Spanish words.

Hello, I am writing a program to sort Spanish words.The letters are almost the same as the English alphabet, only with a few exceptions. a,b,c,ch,d,e,f,g,h,i,j,k,l,ll,m,n,ñ,o,p,q,r,rr,s,t,u,v,w,x,y,z Further, for this problem, assume that any pair of characters which can represent a letter does; for example, the combination ch would a...

Who can I turn to for analysis of my algorithm?

I have an algorithm that attempts to solve SAT, and I believe it always generates the correct result. It also seems to be extremely efficient by my analysis. I am looking for a creditable person who is interested enough to try to analyze my algorithm. It's fairly complicated, but I think that I may have something worthwhile. Is the...

How can I check if the content of a folder was changed

I need a procedure that checks if new folders/files were added to a given selected folder. I need this procedure to run upon application start up so the processing time at this stage is important. I guess I can make a log of current state, log of the previous state, sort and compare them. First I need to know if there is another way. ...

I have a Python list of the prime factors of a number. How do I (pythonically) find all the factors?

I'm working on a Project Euler problem which requires factorization of an integer. I can come up with a list of all of the primes that are the factor of a given number. The Fundamental Theorem of Arithmetic implies that I can use this list to derive every factor of the number. My current plan is to take each number in the list of base p...

Is there any way to divide rgb color palette?

I'm trying to generate a color palette which has 16 colors. i will display this palette in 4x4 grid. so i have to find a way to rgb color palette which has 255*255*255 colors divided to 16 colors equally and logically. i think it's gonna be a mathematical algorithm. because i'm tring to pick 16 vectors from 3x3 matrix which picked in e...

C++ double value losing precision when multiplied?

I am trying to create a function to find the square root of a number. For debugging purposes, it has instructions to print current variable values. The function squareRoot accepts two arguments, x and t. It then declares and initializes n and s. n is the amount to add or subtract, halving every time it is used. s is what is thought to be...

Generating all factors of a number given its prime factorization

If you already have the prime factorization of a number, what is the easiest way to get the set of all factors of that number? I know I could just loop from 2 to sqrt(n) and find all divisible numbers, but that seems inefficient since we already have the prime factorization. I imagine it's basically a modified version of a combinations...

A randomized algorithm to statistic in a set of n elements Select

The question is as follows : " Write a randomized algorithm to statistic in a set of n elements Select ?" can anyone please tell me what does the above question means ? ...

How to find the best combination of many pieces of data depending on certain criteria?

I am trying to write a Python script that finds combinations of armor items from a game that match certain criteria. I have an object that has keys for each item slot (ie. head, chest, waist, etc.) and a list of all the items that can fit in that slot with their stats in each key. There are 10 slots and many items for each up to a total ...