algorithm

How can I find the shortest path in a graph, with adding the least number of new nodes?

I need to find the shortest path in a graph with the least number of added nodes. The start and end nodes are not important. If there is no path in a graph just between specified n-nodes, I can add some nodes to complete the shortest tree but I want to add as few new nodes as possible. What algorithm can I use to solve this problem? ...

How to make MFCC algorithm?

I wanna make the Mel-Frequency Cepstrum Algorithm but there are some things that I don't understand. After FTT is done we need to "Map the powers of the spectrum obtained above onto the mel scale, using triangular overlapping windows." I know how to calculate the triangles and I also know how to pass to mel scale. I simply don't know w...

Best Performance-Critical Algorithm for Solving Nearest Neighbor

We have a list of x,y pairs. Every pair represents a point on a 2D space. I want to find the closest point from this list, to a specific point xq,yq. What is the best performance-critical algorithm for this problem? Lisp of points is not going to change; which means I do not need to perform insertion and deletion. I want just to find the...

Javascript function for trilinear interpolation

All, I THINK that I'm looking for a function for Trilinear interpolation. Here's the details: I have a three dimensional dataset: Dimension 1 varies from 0 to 100 in increments of 5 Dimension 2 varies from 0 to 100 in increments of 5 Dimension 3 varies from 0 to 1 in increments of 0.1 So, I have 4851 total values (21 x 21 x 11). ...

Algorithm to find the number of distinct paths in a directed graph

I have a directed graph, what algorithm can i use to find the number of distinct acyclic paths between 2 particular vertices, and count the maximum times any path is used in these distinct paths? Two paths are distinct if they either visit a different number of vertices or visit vertices in a different order. ...

Find a missing 32bit integer among a unsorted array containing at most 4 billion ints

Hi, This is the problem described in Programming pearls. I can not understand binary search method descrbied by the author. Can any one helps to elaborate? Thanks. EDIT: I can understand binary search in general. I just can not understand how to apply binary search in this special case. How to decide the missing number is in or not in...

order of complexity of the algorithm in O notation

Can anyone tell me order of complexity of below algorithm? This algorithm is to do following: Given an unsorted array of integers with duplicate numbers, write the most efficient code to print out unique values in the array. I would also like to know What are some pros and cons in the context of hardware usage of this implementation ...

Algorithms to detect phrases and keywords from text

I have around 100 megabytes of text, without any markup, divided to approximately 10,000 entries. I would like to automatically generate a 'tag' list. The problem is that there are word groups (i.e. phrases) that only make sense when they are grouped together. If I just count the words, I get a large number of really common words (is, t...

Prescheduling Recurrent Tasks

At work, we are given a set of constraints of the form (taskname, frequency) where frequency is an integer number which means the number of ticks between each invocation of the task "taskname". Two tasks cannot run concurrently, and each task invocation takes one tick to complete. Our goal is to find the best schedule in terms of matchin...

Create groups from sets of nodes

I have a list of sets (a,b,c,d,e in below example). Each of the sets contains a list of nodes in that set (1-6 below). I was wondering that there probably is a general known algorithm for achieving the below, and I just do not know about it. sets[ a[1,2,5,6], b[1,4,5], c[1,2,5], d[2,5], e[1,6], ] I would like to generate a new s...

Unable to find solution for a practice problem in codechef

Here is the problem from code chef : A set of N dignitaries have arrived in close succession at Delhi and are awaiting transportation to Roorkee to participate in the inaugural ceremony of Cognizance. Being big sponsors of Cognizance, it has been deemed unsuitable by the organizing team to arrange for more than one dignitary to travel ...

Efficient Out-Of-Core Sorting

I'm trying to work out how to efficiently sort a huge dataset that won't fit in memory. The obvious answer at a high level is to sort a whole bunch of chunks that do fit in memory using some standard algorithm, write these out to disk, and then merge them. Merging them is the problem. Let's say the data divides up into C chunks, so I ...

What are various algorithm strategies in programming?

While I write an algorithm, I may not come know that this is some special kind of algorithm strategy which is developed earlier and named as xxxx or whatever. I'll try to illustrate my point: Brute-force search or exhaustive search, also known as generate and test, is a trivial but very general problem-solving technique that consists of...

Quick and Simple Hash Code Combinations

Can people recommend quick and simple ways to combine the hash codes of two objects. I am not too worried about collisions since I have a Hash Table which will handle that efficiently I just want something that generates a code quickly as possible. Reading around SO and the web there seem to be a few main candidates: XORing XORing wi...

Algorithmic solutions Leda

There is a LEDA program. http://www.algorithmic-solutions.com/ which basically provides GUI to algorithms. I d like to get into that, I was curious if I can code with C# or JAVA for LEDA. I have looked at their website and googled it. But i didnt see any other languages beside c/c++, Does anyone know if i can use C# or Java for LEDA...

How does Java implement hash tables?

Does anyone know how Java implements its hash tables (HashSet or HashMap)? Given the various types of objects that one may want to put in a hash table, it seems very difficult to come up with a hash function that would work well for all cases. ...

Do any POSIX functions or glibc extensions implement a breadth-first file tree walk?

I am writing a daemon that utilizes inotify to monitor file access and it is critical that I don't miss anything on a recursive search. I found this interesting idea and have begun to implement it. ftw() and ftw64() do not use a breadth-first algorithm, its more "pre-order". nftw() gives me the option of depth-first, but I'm worried abo...

Algorithm Question On Finding All Valid Words In Dictionary

Given a dictionary (just a list of strings). You receive a feed of an unknown number of letters from an external source. Given the string of letters, how would you go about listing all valid words (from the diciontary) you can make from any combination from those letters. So if you receive: abpplead You should find apple, bad, pad, le...

Layout many irregular boxes so they fit on screen

I've got a list of images with dimensions for each image. I need to select and layout a group of images from that list so they fit on screen with slight overlaps, and no gaps. (gradient in the overlap to avoid a sharp transition) I've researched 2d box packing algorithms, but they all assume that you need to use all the items, and, of c...

Finding the highest 2 numbers- computer science

I'm trying to figure out an algorithm to find the highest 2 numbers in a list of numbers. The highest number can be found in n-1 stages, perhaps by doing the fist step of a bubble sort or something along those lines. To me it seems that finding the next highest number as well could be found in a total of 1.5n comparisons on average. ...