I have an array of nearly sorted values 28 elements long. I need to find the set of values that sums to a target value provided to the algorithm (or if exact sum cannot be found, the closest sum Below the target value).
I currently have a simple algorithm that does the job but it doesn't always find the best match. It works under idea...
I'm trying to evaluate different substring search (ala strstr) algorithms and implementations and looking for some well-crafted needle and haystack strings that will catch worst-case performance and possible corner-case bugs. I suppose I could work them out myself but I figure someone has to have a good collection of test cases sitting a...
An application I'm working on requires a matrix of random numbers. The matrix can grow in any direction at any time, and isn't always full. (I'll probably end up re-implementing it with a quad tree or something else, rather than a matrix with a lot of null objects.)
I need a way to generate the same matrix, given the same seed, no matte...
Hello everyone.
I am an engineering student, and deciding upon my final year project.
One of the many candidates is an online UML tool with code generation facilities. But I did not take compiler designing classes, so I am not much aware of the code generation techniques.
I want to know about the techniques that I should look to stud...
Reading through Cactus Kev's Poker Hand Evaluator, I noticed the following statements:
At first, I thought that I could always simply sort the hand first before passing it to the evaluator; but sorting takes time, and I didn't want to waste any CPU cycles sorting hands. I needed a method that didn't care what order the five cards were g...
Does anybody know what triangulation algorithm Maya uses? Lacking that, what would be the most probable algoritms to try? I tried a few simple off the top of my head (shortest/longest resulting edges, smallest minimum angle, smallest/biggest area), but they where all wrong. Is Delaunay the most plausible algoritm?
Edit: by the way, pseu...
What is the best way to obtain a simple, efficient immutable queue data type in Clojure?
It only needs two operations, enqueue and dequeue with the usual semantics.
I considered lists and vectors of course, but I understand that they have comparatively poor performance (i.e. O(n) or worse) for modifications at the end and beginning re...
In a multi-dimensional space, I have a collection of rectangles, all of which are aligned to the grid. (I am using the word "rectangles" loosely - in a three dimensional space, they would be rectangular prisms.)
I want to query this collection for all rectangles that overlap an input rectangle.
What is the best data structure for holdi...
I am aware that Dijkstra's algorithm can find the minimum distance between two nodes (or in case of a metro - stations). My question though concerns finding the minimum number of transfers between two stations. Moreover, out of all the minimum transfer paths I want the one with the shortest time.
Now in order to find a minimum-transf...
Out of pure interested, I'm curious how to create PI sequentially so that instead of the number being produced after the outcome of the process, allow the numbers to display as the process itself is being generated. If this is the case, then the number could produce itself, and I could implement garbage collection on previously seen numb...
Hi Everyone,
I need to know how to rotate an image, which is in yuv420p format by 90 degrees. The option of converting this to rgb, rotating and again reconverting to yuv is not feasible. Even an algorithm would help.
Regards,
Anirudh.
...
i want following suppose there is given two number 5 and 3
for example
5//101 and 3 //011 to concat these bits 101110 and we get 46 here is code for this task
public class concat {
public static void main(String[] args) {
int t=0;
int k=5;
int x=3;
int i=0;
while ( i<3 ){
t=x%2;...
Hi,
I want to write a squeeze functions squeeze(s1,s2) that deletes each character in s1 that matches any character in string s2.
Is there any algorithm available apart from time complexity(m * n) i.e. traversing string s1 m times(length of s2) and skipping all those characters occurring in s2.
Thanks...
...
I am trying to apply a save method in a backing Java bean which will take the table rows that are selected and save them in the database. However, let's say the user changes his choices a little (changes 1 out of his 5 choices). I am wondering about the algorithm I am going to apply if it matters in efficiency in the long term or not.......
Not a homework question, but a possible interview question...
Given an array of integers, write an algorithm that will check if the sum of any two is zero.
What is the Big O of this solution?
Looking for non brute force methods
...
hello stack overflow!
i want to do something like c# linq style :
SomeColection <SomeType> someColection;
someColection.Remove(something => something > 2);
and it'll remove all the things that are bigger then 2 (or any other boolean condition)...
using boost in the project...
...
Hi,
I want to "mix" char* data in this form:
source = (source + some_primary_number) % 256;
--the 256 line is because of I need to keep the range of char.
so I can do the "mix" and "un-mix" in 2 functions - the implementation above is for the mixing and this one is for the un-mixing:
source = source - some_primary_number;
if ( so...
hello i am using c# and i want to find the if a polygon (mostly a triangle) is given to me and i have to find a given point exists in the given polygon or not i want to know that is there any function in c# that can do it for me or any efficient algo to do so??
polygons are represented in 2D plane by XY points the given point is also re...
I found the following problem on the internet, and would like to know how I would go about solving it:
You are given an array ' containing 0s and 1s. Find O(n) time and O(1) space algorithm to find the maximum sub sequence which has equal number of 1s and 0s.
Examples:
10101010 -
The longest sub sequence that satisfies...
A linear algebra question;
Given a k-variate normed vector u (i.e. u : ||u||_2=1)
how do you construct \Gamma_u, any arbitrary k*(k-1)
matrix of unit vectors such that (u,\Gamma_u) forms an
orthogonal basis ?
I mean: from a computationnal stand point of view:
what algorithm do you use to construct such matrices ?
Thanks in advance,...