algorithm

Algorithm for determining a file's identity

For an open source project I have I am writing an abstraction layer on top of the filesystem. This layer allows me to attach metadata and relationships to each file. I would like the layer to handle file renames gracefully and maintain the metadata if a file is renamed / moved or copied. To do this I will need a mechanism for calcu...

How to determine if two web pages are the same?

What are some of techniques good for detecting if a webpage is the same? By same, I don't mean char-for-char equivalent (that's easy), but is robust enough to ignore something like a current date/time on the page, etc. E.g., go a Yahoo! News article load the page, open the same page 10 minutes later in another browser. Baring rewri...

Algorithm Questions Website

Has anyone seen or know of a website which gives you a varying degree of difficulty algorithm to solve(time based or not doesn't matter). Preferably in a multitude of languages. What I am looking for and not sure if it exists is a place which would give me a algorithm to try to solve in any language I specify, such as some factorial alg...

The Most Efficient Algorithm to Find First Prefix-Match From a Sorted String Array?

Input: 1) A huge sorted array of string SA; 2) A prefix string P; Output: The index of the first string matching the input prefix if any. If there is no such match, then output will be -1. Example: SA = {"ab", "abd", "abdf", "abz"} P = "abd" The output should be 1 (index starting from 0). What's the most algorithm way to do this ki...

Length of Encrypted String

I need to create a database column which will store a string encrypted using Triple DES. How do I determine the length of the encrypted string column? (Answers for algorithms other than Triple DES are also welcome.) ...

Whats the Most efficient way to Check if a Date is between Recurrence of a Span ?

What's the most efficient way to check if a date falls between a repetition of a span of time using the c# date class. E.g., you have the span 01/01/2009 1:00:00 am to 01/06/2009 5:00pm which repeats every x number of years, months, or weeks, etc. And I want to check if variable date x falls between any recurrence I read Martin Fowler...

Can Shor's algorithm be used for key encryption?

Can Shor's algorithm be used for encryption, more specifically WEP encryption? ...

Algorithm to Find the pointer to the Node M Steps to Tail in a Singly Linked List

Suppose there is a singly linked list whose length is unknown. We want to find the node with M steps to the tail. For example, the singly list is like this: (A)->(B)->(C)->(X)->(Y) and M = 2. Then the output should be pointer to (C). When confronting this quiz, my first reaction is to traverse the singly linked list to get the length N...

Algorithm to generate spanning set

Given this input: [1,2,3,4] I'd like to generate the set of spanning sets: [1] [2] [3] [4] [1] [2] [3,4] [1] [2,3] [4] [1] [3] [2,4] [1,2] [3] [4] [1,3] [2] [4] [1,4] [2] [3] [1,2] [3,4] [1,3] [2,4] [1,4] [2,3] [1,2,3] [4] [1,2,4] [3] [1,3,4] [2] [2,3,4] [1] [1,2,3,4] Every set has all the elements of the original set, permuted to ap...

Is there an overview of the most common algorithms?

I'm looking for an overview of algorithms, you need every now and then. If there is a problem, you either do reinvent the wheel or spend a lot of time searching for an algorithm to a common known problem which has been solved a hundred times before. Best one would be a website with sorted algorithms, like: Compression ... Decryption...

How would I search a range of ranged values using C#

I have a list of values like this 1000, 20400 22200, 24444 The ranges don't overlap. What I want to do is have a c# function that can store (loaded values from db then cache it locally) a relatively large list of these values then have a method for finding if a supplied value is in any of the ranges? Does this make sense? Need the ...

What is the best way, algorithm, method to difference large lists of data?

I am receiving a large list of current account numbers daily, and storing them in a database. My task is to find added and released accounts from each file. Right now, I have 4 SQL tables, (AccountsCurrent, AccountsNew, AccountsAdded, AccountsRemoved). When I receive a file, I am adding it entirely to AccountsNew. Then running the below ...

Number of trits matching count criteria

For all trinary numbers with length 36 (including those starting with 0's), how many have exactly equal counts of 1's and 2's, or exactly one more 1 than 2? For example: 00 - yes 01 - yes 02 - no 10 - yes 11 - no 12 - yes 20 - no 21 - yes 22 - no So for all trinary numbers of length 2, 5 out of 9 possibilities match. This presumabl...

Using static vs. member find method on a STL set?

I am using a set because, i want to use the quick look up property of a sorted container such as a set. I am wondering if I have to use the find member method to get the benefit of a sorted container, or can I also use the static find method in the STL algorithms? My hunch is that using the static version will use a linear search inste...

How to store sets, to find similar patterns fast?

(This is no homework and no work issue. It's just my personal interest/occupation and completly fictional. But I am interested in a good algorithm or data structure.) Let's assume, that I would run a dating site. And my special feature would be that the singles were matched by movie taste. (Why not?) In that case I would need a way to ...

Best way to optimize dataset that contains linestrings. Some lines start and end at same coordinates.

THE SETUP I have a table which contains linestrings. Linestrings are made up of multiple geographic points. Each point is made up of a latitude and longitude. Note: the linestring value is stored as TEXT in the database. So one row in the table might look like this: id: an integer linestring: x1, y2, x2, y2, x3, y3, x4, y4 THE PROBLEM ...

In-Place Radix Sort

This is a long text. Please bear with me. Boiled down, the question is: does someone know a workable in-place radix sort algorithm? Preliminary I've got a huge number of small fixed-length strings that only use the letters “A”, “C”, “G” and “T” (yes, you've guessed it: DNA) that I want to sort. At the moment, I use std::sort which u...

I need a fast key substitution algorithm for java

Given a string with replacement keys in it, how can I most efficiently replace these keys with runtime values, using Java? I need to do this often, fast, and on reasonably long strings (say, on average, 1-2kb). The form of the keys is my choice, since I'm providing the templates here too. Here's an example (please don't get hung up on...

Difference between lower bound and tight bound?

With the reference of this answer, what is Theta (tight bound)? Omega is lower bound, quite understood, the minimum time an algorithm may take. And we know Big-O is for upper bound, means the maximum time an algorithm may take. But I have no idea regarding the Theta. ...

Generating shuffled range using a PRNG rather than shuffling

Is there any known algorithm that can generate a shuffled range [0..n) in linear time and constant space (when output produced iteratively), given an arbitrary seed value? Assume n may be large, e.g. in the many millions, so a requirement to potentially produce every possible permutation is not required, not least because it's infeasibl...