tagged [algorithm]
Most efficient way to see if an ArrayList contains an object in Java
Most efficient way to see if an ArrayList contains an object in Java I have an ArrayList of objects in Java. The objects have four fields, two of which I'd use to consider the object equal to another....
- Modified
- 1 Mar at 19:24
Algorithm for checking transitivity of relation?
Algorithm for checking transitivity of relation? I need to check if relation is transitive or not? Would you please suggest some algorithm to check the transitivity of relations? I am storing relation...
- Modified
- 10 Mar at 23:19
What is the quickest way to find the shortest cartesian distance between two polygons
What is the quickest way to find the shortest cartesian distance between two polygons I have say and - they are situated in geographical . What is the quickest/speediest algorithim to find the the sho...
Why we use Hash Code in HashTable instead of an Index?
Why we use Hash Code in HashTable instead of an Index? - How that integer hash is generated by the GetHashCode() function? Is it a random value which is not unique?- In string, it is overridden to mak...
Mapping two integers to one, in a unique and deterministic way
Mapping two integers to one, in a unique and deterministic way Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no other integers D and E which ...
- Modified
- 28 May at 07:59
C# algorithm for generating hierarchy
C# algorithm for generating hierarchy I've got a text file that looks like this: I'm looking fo
- Modified
- 4 Jun at 15:43
Resize Image to fit in bounding box
Resize Image to fit in bounding box An easy problem, but for some reason I just can't figure this out today. I need to resize an image to the maximum possible size that will fit in a bounding box whil...
- Modified
- 9 Jul at 20:43
How can I generate truly (not pseudo) random numbers with C#?
How can I generate truly (not pseudo) random numbers with C#? I know that the Random class can generate pseudo-random numbers but is there a way to generate truly random numbers?
Greatest Distance between Equal Numbers in Array
Greatest Distance between Equal Numbers in Array let's say I have a matrix (array) like this example, but much larger: ```0 0 5 0 3 6 6 4 0 3 0 8 0 1 1 9 4 0 6 0 0 0 4 1 0 6 0 7 0 0 3 1 6 1 5 0 8 0 8 ...
How can I generate pseudo-random "readable" strings in Java?
How can I generate pseudo-random "readable" strings in Java? Generating a truly random string of a given length is a fairly straightforward (and already-well-covered) task. However; I'd like to genera...
C#: Removing common invalid characters from a string: improve this algorithm
C#: Removing common invalid characters from a string: improve this algorithm Consider the requirement to strip invalid characters from a string. The characters just need to be removed and replace with...
Replacing nested foreach with LINQ; modify and update a property deep within
Replacing nested foreach with LINQ; modify and update a property deep within Consider the requirement to a data member on one or more properties of an object that is 5 or 6 levels deep. There are sub-...
- Modified
- 26 Aug at 20:30
Space-efficient in-memory structure for sorted text supporting prefix searches
Space-efficient in-memory structure for sorted text supporting prefix searches I have a problem: I need space-efficient lookup of file-system data based of file path prefix. Prefix searching of sorted...
How might I find the largest number contained in a JavaScript array?
How might I find the largest number contained in a JavaScript array? I have a simple JavaScript Array object containing a few numbers. Is there a function that would find the largest number in this ar...
- Modified
- 4 Sep at 14:20
Checking string has balanced parentheses
Checking string has balanced parentheses I am reading the and this is from an exercise question. Quoting the question > A common problem for compilers and text editors is determining whether the par...
How to round decimal value up to nearest 0.05 value?
How to round decimal value up to nearest 0.05 value? Is there any way to round up decimal value to its nearest 0.05 value in .Net? Ex: 7.125 -> 7.15 6.66 -> 6.7 If its now available can anyone provide...
Best way to find position in the Stream where given byte sequence starts
Best way to find position in the Stream where given byte sequence starts How do you think what is the best way to find position in the System.Stream where given byte sequence starts (first occurence):...
Selection Coloring Algorithm
Selection Coloring Algorithm I'm trying to generate a color that could highlight an item as "selected" based on the color of the current object. I've tried increasing some of the HSB values, but I can...
Algorithm: efficient way to remove duplicate integers from an array
Algorithm: efficient way to remove duplicate integers from an array I got this problem from an interview with Microsoft. > Given an array of random integers, write an algorithm in C that removes dup...
- Modified
- 10 Oct at 16:7
Diff and Merge or delta sync
Diff and Merge or delta sync Consider a product where changes a client is making to a text file are broadcast to other clients via a Server. The broadcast happens when the person making changes in the...
- Modified
- 21 Oct at 08:56
How to obtain all subsequence combinations of a String (in Java, or C++ etc)
How to obtain all subsequence combinations of a String (in Java, or C++ etc) Let's say I've a string "12345" I should obtain all subsequence combinations of this string such as: 1. --> 1 2 3 4 5 2. --...
Quick and Simple Hash Code Combinations
Quick and Simple Hash Code Combinations Can people recommend quick and simple ways to combine the hash codes of two objects. I am not too worried about collisions since I have a Hash Table which will ...
There is some way to do this string extraction faster?
There is some way to do this string extraction faster? I need to extract the virtual host name of a HTTP request. Since this willl be done for every request, I´m searching for the fastest way to do th...
- Modified
- 5 Nov at 21:20
Fastest way to pick a random element from a list that fulfills certain condition
Fastest way to pick a random element from a list that fulfills certain condition I need to pick a random element from a list, that fulfills certain condition. The approach I've been using works, but I...