What is an efficient algorithm to find whether a singly linked list is circular/cyclic or not? [duplicate]

The standard answer is to take two iterators at the beginning, increment the first one once, and the second one twice. Check to see if they point to the same object. Then repeat until the one that is incrementing twice either hits the first one or reaches the end. This algorithm finds any circular link … Read more

Implementing a simple Trie for efficient Levenshtein Distance calculation – Java

From what I can tell you don’t need to improve the efficiency of Levenshtein Distance, you need to store your strings in a structure that stops you needing to run distance computations so many times i.e by pruning the search space. Since Levenshtein distance is a metric, you can use any of the metric spaces … Read more

Where can I find information on the D* or D* Lite pathfinding algorithm?

Wikipedia has an article on the topic: http://en.wikipedia.org/wiki/D* Also a D* Lite implementation in C is available from Sven Koenig’s page: http://idm-lab.org/code/dstarlite.tar However I find the impenetrable math much easier to read than the C source code 😉 Another implementation of D* Lite (in C++) is available here: http://code.google.com/p/dstarlite/

Find all the 4 digit vampire numbers

Or you can use a property of vampire numbers described on this page (linked from Wikipedia) : An important theoretical result found by Pete Hartley: If x·y is a vampire number then x·y == x+y (mod 9) Proof: Let mod be the binary modulo operator and d(x) the sum of the decimal digits of x. … Read more