algorithm

dijkstras algorithm

Can I use "Dijkstra's algorithm" to find distribution of probabilities of some events (example "biased dice","male death probability")? If I can, how? Also, can anyone explain following sentence with more example: Dijkstra's algorithm is for finding shortest paths in certain types of weighted graphs ...

Comparing two speech sounds

I need to be able to determine if two sounds are very similar. The goal is to have a very limited vocabulary (10 or 15) of short one or two syllable words, then compare a captured sound to determine if it is one of those items with all the usual variability in environmental and capture conditions. The idea is that the user can issue a fe...

Standard term for a thread I/O reorder buffer?

I have a case where many threads all concurrently generate data that is ultimately written to one long, serial file stream. I need to somehow serialize these writes so that the stream gets written in the right order. ie, I have an input queue of 2048 jobs j0..jn, each of which produces a chunk of data oi. The jobs run in parallel on, s...

Find a common element within N arrays

If I have N arrays, what is the best(Time complexity. Space is not important) way to find the common elements. You could just find 1 element and stop. Edit: The elements are all Numbers. Edit: These are unsorted. Please do not sort and scan. This is not a homework problem. Somebody asked me this question a long time ago. He was using...

priority queue with limited space: looking for a good algorithm

This is not a homework. I'm using a small "priority queue" (implemented as array at the moment) for storing last N items with smallest value. This is a bit slow - O(N) item insertion time. Current implementation keeps track of largest item in array and discards any items that wouldn't fit into array, but I still would like to reduce num...

question about heapsearch order

ia have meet following problem suppose we have sorted array of size 2^k-1 where k is given number we should copy this array into heapsearch array b the elements in odd positions of a go in order into last half of the positions of b positions congruent to 2 modul0 4 go into b's secodn quarter and so on this is not homewo...

search algorithm using sentinel

i am trying to do search algorithm using sentinel which reduce time to 3.87n nanoseconds for example compare to this code int search (int t ){ for (int i=0;i<n;i++) if (x[i]==t) return i; return -1; } it takes 4.06 nanoseconds so i am trying to optimize it here is code public class Search{ public static int search(in...

Parallel curve like algorithm for graphs

Is there a well know algorithm for calculating "parallel graph"? where by parallel graph I mean the same as parallel curve, vaguely called "offset curve", but with a graph instead of a curve. In the best case, it would allow for variable distance for each segment (connection). Given following picture, where coordinates of nodes connecte...

question about Tetration

i have question how write program which calculates following procedures http://en.wikipedia.org/wiki/Tetration i have exponential program which returns x^n here is code public class Exp{ public static long exp(long x,long n){ long t=0; if (n==0){ t= 1; } else{ if (n %2==0){ t= exp(x,n/2)* exp(x,n/2); } el...

Question on HyperOperation

I am trying to solve the following recurence program. http://en.wikipedia.org/wiki/Hyper_operator Here is my code. I know it has mistakes, but I have done what I could. public class hyper { public static int Hyper(int a, int b, int n) { int t=0; if (n == 0) return b+1; if ((n == 1) && (b == 0))...

Algorithm to represent Decision tables

What would be the best algorithm to use if you wanted to store Decision tables in code, i've looked at the Adjacency matrix and Binary tree would anyone consider this to be the right direction? What other choices to I have? ...

All minimum spanning trees implementation

I've been looking for an implementation (I'm using networkx library.) that will find all the minimum spanning trees (MST) of an undirected weighted graph. I can only find implementations for Kruskal's Algorithm and Prim's Algorithm both of which will only return a single MST. I've seen papers that address this problem (such as Represen...

Find all ways to insert zeroes into a bit pattern

I've been struggling to wrap my head around this for some reason. I have 15 bits that represent a number. The bits must match a pattern. The pattern is defined in the way the bits start out: they are in the most flush-right representation of that pattern. So say the pattern is 1 4 1. The bits will be: 000000010111101 So the genera...

Explain how finding cycle start node in cycle linked list work?

I understand that Tortoise and Hare's meeting concludes the existence of loop, but how does moving tortoise to beginning of linked list while keeping the hare at meeting place, followed by moving both one step at a time make them meet at starting point of cycle? ...

How to implement Unary coding?

I have a question about how to implement unary encoding. For example: How can we differ n (non-negative) from n (strictly positive)? I don’t understand a bit. Please help me. I have changed and written code. public class unary { public static void main (String[] args) { int n = 10; int i = 0; String t = ""; ...

Student-Project allocation algorithms?

Hi there, Is anyone aware of any documented Student-Project allocation algorithms (similar to the Hospitals-Residents problem, which is a subset of a two-sided matching problem)? Update based on comment This is just for knowledge rather than implementation since I've already got an implementation for the allocation algorithm. Thanks...

Allocation algorithm help, using Python.

Hi there, I've been working on this general allocation algorithm for students. The pseudocode for it (a Python implementation) is: for a student in a dictionary of students: for student preference in a set of preferences (ordered from 1 to 10): let temp_project be the first preferred project check if temp_project...

Are there any well known algorithms to detect the presence of names?

For example, given a string: "Bob went fishing with his friend Jim Smith." Bob and Jim Smith are both names, but bob and smith are both words. Weren't for them being uppercase, there would be less indication of this outside of our knowledge of the sentence. Are there any well known algorithms for detecting the presence of names, at lea...

Find a better control

It is necessary to implement the following functionality: There is a rectangle "field", its size is 150x100 pixels. Field is split to locations, each location is 10x10 (totally 15x10 locations on the field). There are few "coins" (5, for example), each of them can be dropped into any location. The list of text messages should be displ...

How does an unsharp mask work?

I've been playing around with image processing lately, and I'd like to know how the unsharp mask algorithm works. I'm looking at the source code for Gimp and it's implementation, but so far I'm still in the dark about how it actually works. I need to implement it for a project I'm working on, but I'd like to actually understand the alg...