algorithm

Randomly select a record from Active Directory Application Mode

I need a routine to randomly select records from ADAM (Active Directory Application Mode). Any advice to get me started on this task? ...

Fast Algorithm to Generate 500,000 html file.

What is the fastest way (Algorithm) to generate 500,000 static html files from DB? And is it a good practice to put all this files in single folder? or create hierarchically for this files? We want to handle about 6,000,000 concurrent hit, so the static files will be a good solution for that. the source DB will be simple flat table wi...

Algorithm Analysis Question

NOTE: I'm ultra-newbie on algorithm analysis so don't take any of my affirmations as absolute truths, anything (or everything) that I state could be wrong. Hi, I'm reading about algorithm analysis and "Big-O-Notation" and I fell puzzled about something. Suppose that you are asked to print all permutations of a char array, for [a,b,c] t...

What is the most underrated or little known but useful algorithm?

I'm looking for the one algorithm or data structure which is so unknown yet useful that you think it's a horrible oversight by the computer science or programming community. If only we could all learn this one thing, a lot of good would be done to many future programs. The best one I can come up with is interpolation search, which only...

General rules for simplifying SQL statements

I'm looking for some "inference rules" (similar to set operation rules or logic rules) which I can use to reduce a SQL query in complexity or size. Does there exist something like that? Any papers, any tools? Any equivalencies that you found on your own? It's somehow similar to query optimization, but not in terms of performance. To sta...

How to split long strings into fixed array items in C#

I have a dictionary object IDictionary<string, string> it only has the following items: Item1, Items2 and Item3. Each item only has a maximum length of 50 characters. I then have a list of words List<string>. I need a loop that will go through the words and add them to the dictionary starting at Item1, but before adding it to the dictio...

Optimizing a Cocoa/Objective-C search

I'm performing a search of a large plist file which contains dictionaries, tens of thousands of them, each with 2 key/string pairs. My search algorithms goes through the dictionaries, and when it finds a text match in either of the strings in the dictionary, the contents of the dictionary are inserted. Here is how it works: NSDictionary...

Optimized way to re-order numbering using C#

I have a following items displayed on an asp.net page (C#). 1 Welcome 2 Whats New 2.1 Gifts 2.2 Ideas 2.3 Others 2.3.1 Novelty 2.3.2 Boats 2.4 Vehicals 2.5 Fruits Now the user can remove any child items ( not root for ex user can remove item 2.1 gifts or item 2.3.1 novelty) Once user remove the item, i need to re-nunmber the structu...

Efficiently get unretrieved message Ids from a POP3 server.

I understand most of the POP3 protocol, but one thing that bothers me is how POP3 clients efficiently get a list of unretrieved message ids from the POP3 server. Many services like Yahoo and Gmail now offer gigs of space and most people (myself included), rarely if ever delete an email message. I'm currently implementing a simple POP3 c...

Pointers to some good SVM Tutorial ...

Hi all, I have been trying to grasp the basics of Support Vector Machines, and downloaded and read many online articles. But still am not able to grasp it. I would like to know, if there are some nice tutorial sample code which can be used for understanding or something, that you can think of, and that will enable me to learn SVM B...

Lossless compression in small blocks with precomputed dictionary

I have an application where I am reading and writing small blocks of data (a few hundred bytes) hundreds of millions of times. I'd like to generate a compression dictionary based on an example data file and use that dictionary forever as I read and write the small blocks. I'm leaning toward the LZW compression algorithm. The Wikipedia...

Looking for datastructure that maintains a size & purges older elements in the process

Usecase maintain a list of the last n visited URLs (where n is a fix number). As new URLs are added to the list, older urls are removed automatically (in order to keep it at n elements) Requirement The data structure needs to be sorted by time (should be no problem if it accepts a Comparator). ...

Invert a stack, without using extra data structures?

How would you invert a stack, without using extra data structures, like a second, or temporary, stack. Thus no stack1-stack2 or stack-queue-stack implementation in the answer. You just have access to push/pop feature of a standard stack. I think there is way to do it by keeping a global counter and using pointer manipulation. ...

Names of Graph Traversal Algorithms

What I'm looking for is a comprehensive list of graph traversal algorithms, with brief descriptions of their purpose, as a jump off point for researching them. So far I'm aware of: Dijkstra's - single-source shortest path Kruskal's - finds a minimum spanning tree What are some other well-known ones? Please provide a brief description...

Does anyone know how to do an "inverse" trilinear interpolation?

Trilinear interpolation approximates the value of a point (x, y, z) inside a cube using the values at the cube vertices. I´m trying to do an "inverse" trilinear interpolation. Knowing the values at the cube vertices and the value attached to a point how can I find (x, y, z)? Any help would be highly appreciated. Thank you! ...

Circle line collision detection

I have a line from A to B and a circle positioned at C with the radius R. This is in two dimensions. Which is a good algorithm to use to check whether the line intersects the circle? And at what coordinate along the circles edge it occurred? ...

HashMap profiling

Are there any HashMap implementations that expose hook methods for profiling the performance of the Map (average chain length, best / worst / average access time, #rehashes, etc.). It seems quite common to use HashMap and "hope for the best" with regards to ~O(1) access time, without analysing whether this is really the case but I'd lik...

Efficient hashCode() implementation

I often auto-generate an class's hashCode() method using IntelliJ IDEA and typically the method takes the form: result = 31 * result + ... My question is what is the purpose of multiplying by 31? I know this is a prime number but why pick 31 specifically? Also, if implementing a hashCode() for a particularly small / large dataset wo...

Is there a way to store a string longer than 25 characters into a hexadecimal string shorter than 25 characters and have it reversible?

Sorry if the title doesn't make sense. Basically I have a series of strings that are 10-60 characters long. The problem being is the service I have to use only accepts strings up to 25 so I need a way to convert the strings I have to 25 characters or less, send it off and when I get the results back be able to convert it back to the orig...

unique integer/long hash key generation over strings for faster compairson

I'm curious how others have solved this problem, and what problems might lurk behind the naive solution: I have a system which processes stock market data. There are tens of thousands of symbols, with associated prices/sizes, flowing into the system at the rate of several thousand every millisecond. One of the basic operations that ne...