algorithm

Question on Scheme with Best First Search algorithm

Okay this is a homework question, and I just don't have a clue how I suppose to start. Some help and hints will be much appreciated. I need to use a heuristic function to solve a maze type problem. Suppose I have a 5x5 grid, and a robot in position (1,5) and my goal is to move the robot to (5,1). Along the way there are few obstacles...

Storing Large Number Of Files in File-System

I have millions of audio files, generated based on GUId (http://en.wikipedia.org/wiki/Globally%5FUnique%5FIdentifier). How can I store these files in the file-system so that I can efficiently add more files in the same file-system and can search for a particular file efficiently. Also it should be scalable in future. Files are named bas...

Scheme How To Return Multiple Values?

I notice that almost all scheme functions can only return one list as output. In the following, I would like to return multiple values of all the adjacent nodes of neighbors. (define (neighbors l w) (if (and (= 1 l) (= 1 w)) (list (and (l (+ 1 w))) (and (+ 1 l) w)))) ; how to output 2 or more values? In this case I'm first t...

How can I get all days between two days?

I need all the weekdays between two days. Example: Wednesday - Friday = Wednesday, Thursday, Friday 3 - 5 = 3, 4, 5 Saturday - Tuesday = Saturday, Sunday, Monday, Tuesday 6 - 2 = 6, 7, 1, 2 I'm pretty sure there is a clever algorithm out there to solve this. The only algorithms I can think of use eit...

calculating a hash of a data structure?

Let's say I want to calculate a hash of a data structure, using a hash algorithm like MD5 which accepts a serial stream, for the purposes of equivalence checking. (I want to record the hash, then recalculate the hash on the same or an equivalent data structure later, and check the hashes to gauge equivalence with high probability.) Are ...

Shortest path (fewest nodes) for unweighted graph

I'm trying build a method which returns the shortest path from one node to another in an unweighted graph. I considered the use of Dijkstra's but this seems a bit overkill since I only want one pair. Instead I have implemented a breadth-first search, but the trouble is that my returning list contains some of the nodes that I don't want...

a simple/practical example of fuzzy c-means algorithm

i a writing my master thesis on the subject of dynamic keystroke authentication. to support ongoing research, i am writing code to test out different methods of feature extraction and feature matching. my current simple approach just checks if the reference password keycodes matches the currently typed in keycodes and also checks if the...

Longest common substring with constant memory?

Given two strings -- how can you find the longest common substring using only constant memory? UPDATE: The time constraints are to solve it in O(len1 * len2), like the standard dynamic-programming solution. ...

Filtering out text content on some criteria, e.g. about myself

Hi, What is the specialist area where if I have a set of blog posts for example, and I would like to filter out the ones which may be about myself or irrelevant by some criteria? I know I could have a list of words to look for (which would be a lot of it is's about myself or anything/one else - the combinations won't end), to do my filt...

Find if an angle is within X degrees from another

I need an algorithm to figure out if one angle is within a certain amount of degrees from another angle. My first thought was (a-x < b) && (a+x > b), but it fails when it has to work with angles that wrap around from -179 to 180. In the diagram above, the region (green) that the angle must be between wraps between the negative and po...

What is the complexity of creating a lexicographic tree

What is the complexity of creating a lexicographic tree? ...

Calculating RMS with overlapping windows

I have a 1-dimensional float array of root mean square values, each calculated with the same window length. Let's say RMS = {0, 0.01, 0.4, ... } Now the RMS for a larger window, which can be represented as a range of the original windows, can be calculated as the RMS of the "participating" RMS values from RMS[i] to RMS[i + len]. Here ...

Generic Concat Extension method for Paramarrays not working for IEnumerable(of String)

Inspired by Javascripts variable Arguments in Max()/Min() and list comprehension in functional languages I tried to get the same in VB.NET using Generic Extension methods given IEnumerable(of T) as resulttype. This works well excepts for strings. Why? These kind of extension methods may be considered a bad idea. Any strong reason Why t...

Java NullPointerException

I'm writing two classes to handle simple auctions. I have a class ready and working, which handles the operations for a single auction, and now I'm writing another class like an auction house, to keep track of all the auctions available. When testing the following part of the class: import java.util.ArrayList; public class AuctionHouse...

Fastest way of finding the middle value of a triple?

I've got the following scenario: There are three ("pseudo" randomly chosen) int or float values which represent indices of an array. Now I'd like to compare the appropriate values from that array. After having compared them I'd like to know the middle value of the three and use this specific element for some further array operations. T...

Complexity class

Assume that methods m1 and m2 are static void and compute the same result by processing an argument of type Object[]. Empirically we find that m1 -> T(N) = 100N and m2 -> T(N) = 10Nlog2N where the times are in microseconds. For what size inputs is it better to use m1 and m2? So I would use m1 for big numbers while I would use m2 for sma...

Java: Calculating a metric of String simliarity

This method is a bottleneck in my program. (Or, it is at least where most of the time is being spent.) Its purpose is to calculate the similarity between two strings based on the way characters occur in both, or occur in one or not the other. The code is correct, but I would like to optimize it. Do you see any inefficiencies, bad pract...

file_exists() for a file that contains (&) in filename

$filename = "Sara & I.mp3"; if (file_exists($filename)) { ... } If the filename has a "&" PHP does not return true for file_exists How can I escape "&" in the $filename for the file_exists to work? Already tried urlecode(), urlrawencode(), htmlentities(), and escaping the '&' with a backslash (\&)... no go ps. this is on a linux sy...

Selection , Finding the largest of a set with Ternary comparator.

Let S be a set of n>0 distinct integers.Assume that n is a power of 3. A ternary comparison can compare three numbers from the set S and order them from the largest to the smallest. Describe an efficient algorithm that uses as few as possible ternary comparisons to find the largest number in the set S.Explain why your algorithm is corr...

Converting an input word number (like seven) into a character (like @)

so if the user types down seven with Scanner, @@@@@@@ (7) will be the output. I'll have to use a for loop statement but I can at least figure out that much. Just need help with figuring out a way to convert word numbers into a numerical number and finally into a random character. ...