algorithm

Learning CS theory behind scheduling and time-planning.

I am looking for introductory and intermediate materials on scheduling algorithms (books, papers, you name it). I am also interested in reference implementations and libraries, any language will do. The goal is to evenly distribute set of recurring activities over time span. Also a number of constraints must be satisfied: resource avail...

How do I create a schedule for n-pastors visiting n-churches?

I want to make a schedule for many pastors. The conditions are: Every month, each pastor must must go to another church, The pastor must not go to same church where he came In 1 year he must go to 12 different churches There is 13 churches and 13 pastors and every church accepts only 1 pastor every month I can't use random(1 to 12) ...

Worst Case Time Complexity for an algorithm

What is the Worst Case Time Complexity t(n) :- I'm reading this book about algorithms and as an example how to get the T(n) for .... like the selection Sort Algorithm Like if I'm dealing with the selectionSort(A[0..n-1]) //sorts a given array by selection sort //input: An array A[0..n - 1] of orderable elements. //output: Array A[0.....

How can algorithm design and programming productivity be enhanced, increased?

How can algorithm design and programming productivity be enhanced, increased? ...

Creating an id from name and address data. Hash/Digest

My problem: I'm looking for a way to represent a person's name and address as an encoded id. The id should contain only alpha-numeric characters, be collision-proof, and be represented in a smallest number of characters possible. My first thought was to simply use a cryptographic hash function like MD5 or SHA1, but this seems like ove...

C++ sorting a vector or linked list

I have an input file that I want to sort based on timestamp which is a substring of each record. I want to store multiple attributes of the The list is currently about 1000 records. But, I want it to be able to scale up a bit just in case. When I did it with a Linked List by searching the entire list for insertion it took about 20 s...

Version Control Algorithm

I have a database where I store objects. I have the following (simplified) schema CREATE TABLE MyObjects ( UniqueIdentifier Id; BigInt GenerationId; BigInt Value; Bit DeleteAction; ) Each object has a unique identifier ("Id"), and a (set of) property ("Value"). Each time the value of the proper...

Fast Entity Grouping (by location) algorithm

I'm dealing with a large group of entities that store locations. They are displayed on a map. I'm trying to come up with an efficient way to group near located entities into one entity when viewed from a higher location. So, for example, if you are very high, when looking down, you will see one entity that represents a group of closely l...

Artificial Neural Network Question

Generally speaking what do you get out of extending an artificial neural net by adding more nodes to a hidden layer or more hidden layers? Does it allow for more precision in the mapping, or does it allow for more subtlety in the relationships it can identify, or something else? ...

Which Data Mining Algorithm is the best?

Hi everyone! Long time listener, first time caller. I'm a full time SE during the day and a full time data mining student at night. I've taken the courses, and heard what our professors think. Now, I come to you - the stackoverflowers, to bring out the real truth. What is your favorite data mining algorithm and why? Are there any s...

Where can I learn how to combine algorithms and data structures ?

After reading an introductory book on algorithms and data structures I am now craving for examples on how to combine these for optimal efficiency. For instance, you can combine hashmaps with specific sorting algorithms to create a simple text search program. Is there any good book or online resource for this? (I have already ordered P...

Measuring trust for users of a service.

Lets say you have a program that allows access to some sort of media. This media can be damaged. It is only possible for the users to know if the media is damaged after they use the service and receive the media. So to make your users happy, you want your program to give the users the ability to turn the media back in for a refund. Howev...

Detecting if two images are visually identical

Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint, then one could hash ...

How can I find the Largest Common Substring between two strings in PHP?

Is there a fast algorithm for finding the Largest Common Substring in two strings or is it an NPComplete problem? In PHP, I can find a needle in a haystack: <?php if (strstr("there is a needle in a haystack", "needle")) { echo "found<br>\n"; } ?> I guess I could do this in a loop over one of the strings but that would be very ex...

Counting inversions in an array

I'm designing an algorithm to do the following: Given array A[1... n], for every i < j, find all inversion pairs such that A[i] > A[j]. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can use this to find the number of inversions. Any hints or help would ...

Best algorithm for this interview problem

Given a NxN matrix with 0s and 1s. Set every row that contains a 0 to all 0s and set every column that contains a 0 to all 0s. For example 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 results in 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 A Microsoft Engineer told me that there is a solution that involves no extra mem...

Difference between 2 numbers

I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers. For example the difference between: 100 and 25 is 75 100 and -25 is 125 -100 and -115 is 15 -500 and 100 is 600 Is there a C# function or a very elegant algorithm to calculate this or I have to go and handle every case separate...

Make C# algorithm more efficient

I have a C# method that projects the value of a number from an interval to a target interval. For example: we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60. Here is the method: /// <summary> /// Projects a value to an interval /// </summary> /// <param nam...

Generating An Amortization Schedule

I have been tasked with creating a program that will generate an amortization schedule. I have only done a bit of research so far, but I need to calculate out payments, interest per payment and principal per payment. Can any one point me in the right direction to figure this out? While I will be writing this in RPG, I am sure others coul...

3D surface Reconstruction algorithm

I have a 3D surface ( such as a cone). It is projected to a 2D plan in the form of contour, meaning that different Z will have different lines on 2D plan. The problem is from the contour, how to recover the 3D surface by using interpolation? We only know about the z difference between different contor lines. ...