algorithm

Non cap sensitive search C#

Hi all, I want to do a search of a list of strings, non cap sensitive. Have tried .Contains and == Is there a method to do this, or would I have to convert the entire list of strings to noncaps, then search? Cheers! ...

Finding the index of an entry in a linked list in better than O(n) time...

I have a scenario where I'm pushing change-lists to another system. Each list contains zero or more inserted, updated or deleted notifications. Inserting is easy; the notification contains the target index and a pointer to the item. Updating is easy; I pass a pointer to the item. Deleting seems straight-forward; I need to pass the ...

Pick X points on a circle which are on screen in C#

Hi all, I have a few sets of information available to me, currently: position on screen (Point) orientation of point (double, say 15 degrees) distance (length from point) What I want to do is pick X (less than 6 I think) number of points in an angular spread facing the same orientation as the position with a distance of distance so ...

Deleting a loop in singly linked list

A loop may occur in singly linked list (SLL). To delete the loop in the list, first we need to detect the loop in the SLL and then delete the loop. Can any one tell how to delete the loop in a SLL with pseudo code? Can we do it using 3 pointers? Is there any alternate to accomplish the task? ...

How to joint some objects in digital image?

I'm looking for some algorithm to joint objects, for example, combine an apple into a tree in digital image and some demo in Matlab. Please show me some materials of that. Thanks for reading and helping me!!! ...

Calculating difference between username and email in javascript

Hi, for security reasons i want the users on my website not to be able to register a username that resembles their email adress. Someone with email adress [email protected] cant register as user or us.er, etc For example i want this not to be possible: tester -> [email protected] (wrong) tes.ter -> [email protected] (wrong) etc. But...

How to select a line

So I'm trying to figure out how to implement a method of selecting lines or edges in a drawing area but my math is a bit lacking. This is what I got so far: A collection of lines, each line has two end points (one to start and one to end the line) The lines are drawn correctly on a canvas Mouse clicks events are received when clicking ...

How to convert an 18 Character String into a Unique ID ?

Hi, I have an 18 Character String that I need to convert into a unique long (in Java). A sample String would be: AAA2aNAAAAAAADnAAA My String is actually an Oracle ROWID, so it can be broken down if needs be, see: http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#CNCPT713 The long number generated, (1) Mus...

Object Positioning Algorithm

I'm wondering if there is an "optimal" solution for this problem: I have a n x m (pixel) sized space with p preexisting rectangled - objects in various sizes on it. Now I want to place q (same sized) new objects in this space without any overlapping. The algorithm I came up with: Create array A[][] with the size [(n)/(size_of_object_...

Does there exist a digital image steganography algorithm which would be resistant to image manipulation?

I'm wondering - is there a steganography solution for digital images which is resistant to image manipulations? With "manipulations" I mean the most standard operations - recompressing JPEGs (or even changing file formats entirely), cropping and scaling. The application of this method would naturally be for image copyright protection. I...

Search file 1 in file 2

Hello, I need to go through an audio stream of 30 minutes and look for another 30 seconds of audio which is within the first audio. Example: I have a file of 30 seconds and file 2, the recorded broadcast (30 mins.) And i want to find the start position of file 1 in file 2. Understand? Excuse my English. Any help will be important Thanks...

What is the meaning of O( polylog(n) )? In particular, how is polylog(n) defined?

Brief: When academic (computer science) papers say "O(polylog(n))", what do they mean? I'm not confused by the "Big-Oh" notation, which I'm very familiar with, but rather by the function polylog(n). They're not talking about the complex analysis function Lis(Z) I think. Or are they? Something totally different maybe? More detail: Mos...

What is the best algorithm for checking if a number is prime?

Possible Duplicate: Efficient storage of prime numbers Just an example of what I am looking for: I could represent every odd number with a bit e.g. for the given range of numbers (1, 10], starts at 3: 1110 The following dictionary can be squeezed more right? I could eleminate multiples of five with some work, but numbers that...

Algorithm - How to delete duplicate elements in a list efficiently?

There is a list L. It contains elements of arbitrary type each. How to delete all duplicate elements in such list efficiently? ORDER must be preserved Just an algorithm is required, so no import any external library is allowed. Related questions In Python, what is the fastest algorithm for removing duplicates from a list so that all ...

Speeding up self-similarity in an image

I'm writing a program that will generate images. One measurement that I want is the amount of "self-similarity" in the image. I wrote the following code that looks for the countBest-th best matches for each sizeWindow * sizeWindow window in the picture: double Pattern::selfSimilar(int sizeWindow, int countBest) { std::vector<int> ...

Reverse a singly linked list

I would be wondered if there exists some logic to reverse the linked list using only two pointers. The following is used to reverse the single linked list using three pointers namely p, q, r: struct node { int data; struct node *link; }; void reverse() { struct node *p = first, *q = NULL, *r...

How to implement unique hits on articles

Hi, i was wondering what the best way is to implement a hit counter for articles, products, etc. Now if someone visits the page the counter just adds one in the database. If someone refreshes the page it counts continuously, misleading results, and unnecessary reads, writes. I was thinking of storing their ip, but i don't know how to mo...

How to check if an integer is power of 3?

I saw this question,and pop up this idea. ...

Java Code Review: Generate a subgraph

I'm using JGraphT and I want to generate a subgraph, like this: If there's a graph like {stuff -> a -> b -> stuff}, and you ask for the subgraph in direction of {a -> b}, you'll get {a -> b -> stuff}. (stuff = collection of nodes and edges, -> = an edge, a and b are nodes.) My idea is as follows: if the start is A, and the sink is B, r...

Graph theory question, Java. Which algorithm to achieve the following.

I have a graph, with X nodes and Y edges. Weighted edges. The point is to start at one node, and stop at another. Now here comes the problem; Visualize the problem. The edges are roads, and the edge weights are the max weight limits for vehicles driving on the roads. We would like to drive the biggest truck possible from A to B. So the...