algorithm

VB.NET - Genetic Algotithm - Knapsack Problem

I have been working on the Knapsack problem using genetic algorithms. But I have run into a few difficulties... First off the user generates a data set which is stored in a text document. From there I read the data in to the program. I do fine getting the program to calculate fitness values, select parents, produce children, then muta...

An algorithmic question concerning shortest paths and such.

I have a very, very large graph, and I want to find the shortest path from one vertex to another. The graph is directed and unweighted. I have considered using some modification of Dijkstra's algorithm, but I usually use that for weighted undirected graphs. So then my other thought was to use a DFS, since I can treat all the weights ...

Scheduling Algorithm with contiguous breaks

I'm lost here. Here's the problem and I think it's NP-hard. A center is staffed with a finite number of workers with the following conditions: There are 3 shifts per day with 2 people in each shift Each employee works for 5 days straight and then 2 days off with only one shift per day So the problem is: how many workers do we need if...

What book to use to learn Algorithms and Data Structures ?

I want to learn Algorithms and become fluent in them. My goal is to land a job as a Software Development Engineer at either Google or Microsoft. I've been recommended to use the book "Introduction to Algorithms" by Cormen. But I feel like the book is not for beginners. Can anyone recommend a book on Algoritms that I can find easier ? o...

Algorithm to find all permutations of n characters

Possible Duplicates: Generating permutations lazily How to generate all permutations of a list in Python Algorithm to generate all possible permutations of a list? I didn't think this could be tough, but I'm having problem to come up with an algorithm to find all variations of n characters. We can assume each character onl...

What is the fastest substring search algorithm?

OK, so I don't sound like an idiot I'm going to state the problem/requirements more explicitly: Needle (pattern) and haystack (text to search) are both C-style null-terminated strings. No length information is provided; if needed, it must be computed. Function should return a pointer to the first match, or NULL if no match is found. Fa...

why is Ricart-Agrawala algorithm deadlock free?

Can someone explain why this algorithm is free from deadlock specifically? thanks ...

Template matching algorithms

Please suggest any template matching algorithms, which are independent of size and rotation. (any source codes as examples if possible please) EDIT 1: Actually I understand how the algorithm works, we can resize template and rotate it. It is computationally expensive, but we can use image pyramids. But the real problem for me now is whe...

Tree matching algorithm?

I am working on a tree library, and part of the required functionality, is to be able to search a node for child nodes that match a pattern. A 'pattern' is a specification (or criteria) that lays out the structure, as well as attributes of nodes in the subtree(s) to be matched. For example, suppose a tree represents data regarding a pa...

Most efficient way to find min and max of a sin/cos curve in C#

Background: I have a function in my program that takes a set of points and finds the minimum and maximum on the curve generated by those points. The thing is it is incredibly slow as it uses a while loop to figure out the min/max based on approximated error. Not completely sure what formal method this is because I did not write it myself...

Java string-manipulation problem !

I must write a function that takes two words (strings) as arguments, and determines if the first word can be transformed into the second word using only one first-order transformation. First-order transformations alter only one letter in a word The allowed transformations are: insert, remove and replace insert = insert a letter at an...

What are the most important algorithms?

Christoph Koutschan has set up an interesting survey that tries to identify the most important algorithms "in the world". Since one of the criteria is that "the algorithm has to be widely used" I though that extending the survey to the huge group of users at Stack Overflow would be a natural thing to do. So, what do you think? Which alg...

When should the STL algorithms be used instead of using your own?

I frequently use the STL containers but have never used the STL algorithms that are to be used with the STL containers. One benefit of using the STL algorithms is that they provide a method for removing loops so that code logic complexity is reduced. There are other benefits that I won't list here. I have never seen C++ code that ...

Tricky algorithm... finding multiple combinations of subsets within nested HashSets?

I have a problem where I have to find multiple combinations of subsets within nested hashsets. Basically I have a "master" nested HashSet, and from a collection of "possible" nested HashSets I have to programmatically find the "possibles" that could be simultaneous subsets of the "master". Lets say I have the following: var...

Number of iterations in nested for-loops?

So I was looking at this code from a textbook: for (int i=0; i<N; i++) for(int j=i+1; j<N; j++) The author stated that the inner for-loop iterates for exactly N*(N-1)/2 times but gives no basis for how he arrived to such an equation. I understand N*(N-1) but why divide by 2? I ran the code myself and sure enough when N is 10, the i...

Graph Hamiltonian Path with DNA Computing

I recently found a "DNA Computing" Algorithm (not genetic programming or genetic algorithms) that attempts to find the Hamiltonian Path in a graph, but I'm a little confused by the pseudo code... note that the notation is a little messed up because I copied it from a PDF paper on DNA computing: Input: for each node v and edge (u; v), ...

finding the longest road in a Settlers of Catan game algorithmically

I'm writing a Settlers of Catan clone for a class. One of the extra credit features is automatically determining which player has the longest road. I've thought about it, and it seems like some slight variation on depth-first search could work, but I'm having trouble figuring out what to do with cycle detection, how to handle the joining...

Fastest way to calculate cubic bezier curves?

Right now I calculate it like this: double dx1 = a.RightHandle.x - a.UserPoint.x; double dy1 = a.RightHandle.y - a.UserPoint.y; double dx2 = b.LeftHandle.x - a.RightHandle.x; double dy2 = b.LeftHandle.y - a.RightHandle.y; double dx3 = b.UserPoint.x - b.LeftHandle.x; double dy3 = b.UserPoint.y - b.LeftHandle.y; ...

Algorithms/problems to solve while learning a new language

At some point in our lives we're put in the situation to learn a new language (either by job requirements or just passion). Personally, I'm trying to learn Objective-C coming from a background of several years coding php. My problem is that I'm bored with your average starting programs (most of them coming from maths; eg: Fibonacci). Wh...

Linear Linked List - valid/common terminology?

Is speaking of a linear linked linked in contrast to a circular linked list a valid / common term? For some examples I'm posting to my students I need to distinguish between both and don't want to use terms which don't actually exist! ...