If I have two sequences (for example, string)
// 01234567890123456789012
a = "AAACDDFFFEE1122VV1VAADD"
// 0123456789012345678901
b = "DDFFAA11221DHHVV1VAAFE"
I want to know the best substring matching (unordered) from b to a, for instance:
optimal (6 matched parts, 19 characters of a matched)
b a
DDFF -> DDFF (4...
Can somebody give me pseudocode of karmarkar-karp's differencing algorithm, I don't understand it. Better if there's a visualization/demo of it.
...
Let's assume text is a String and contains a text. tags is an Array of Strings.
text = <<-EOS
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
Duis au...
We allow users to add domains to an active record model such as User.domain and find the users by domain using User.find_by_domain.
In the future we want to allow users to enter *.example.com as their domain and allow User.find_by_subdomain('sub1.example.com') and User.find_by_subdomain('sub2.example.com') to work. However we also want ...
Hi all
I've been tasked to find N clusters containing the most points for a certain data set given that the clusters are bounded by a certain size. Currently, I am attempting to do this by plugging in my data into a kd-tree, iterating over the data and finding its nearest neighbor, and then merging the points if the cluster they make do...
Hello,
I have to write a priotity queye as implementation of the folowing interface:
public interface PQueue<T extends Comparable<T>> {
public void insert( T o ); // inserts o into the queue
public T remove(); // removes object with highest priority (by natural order)
}
I would be glad for some help and clues, becous...
a=[1,3,6,7,1,2]
Which is the best sorting technique to sort the following array and if there are duplicates how to handle them.
Also which is the best sorting technique of all....
void BubbleSort(int a[], int array_size)
{
int i, j, temp;
for (i = 0; i < (array_size - 1); ++i)
{
for (j = 0; j < array_size - 1 - i; ++...
My rectangle structure has these members:
x, y, width, height.
Given a point x, y
what would be the fastest way of knowing if x, y is inside of the rectangle? I will be doing lots of these so speed is important.
...
I've been using one of the older implicit surface algorithms, due to Bloomenthal, as found here, basically the tetrahedral-based algorithm. This works fairly well, but has a shortcoming. Since it uses a fixed grid, it either wastes polygons or ignores detail, depending on the grid size selected.
So my question is, what are my option...
I've looked at different papers and here is the information that I've gathered:
SGI implementation and C cords neither guarantee O(1) time concatenation for long ropes nor ~log N depth for shorter ones.
Different sources contradict each other. Wikipedia claims O(1) concatenation. This page says that concatenation is O(1) only when one ...
The SAT algorithm requires you to find the normal of each edge of each shape (essentially a vector perpendicular to the edge vector) to be used as the separating axes. This can be done very simply...
(x,y) => (-y,x)
OR
(x,y) => (y,-x)
Which should be used in the SAT algorithm? This is essentially a question of whether the left hand n...
given an edge enum such as this:
none, top, left, bottom, right,
Given 2 rectangles, how could I find which edge of rectangle A that rectangle B is intersecting? I do not need to know which edge of B hit an edge of A, I just need to know which edge of A that B hit.
I found this algorithm but it does not return the specific edge:
bo...
I have an 2 dimensional array that is full of 1s and 0s such as
0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
You can see there is a square in th array.
I am trying to make a function that will make a rectangle or ...
I'm thinking this might be NP-complete, but I'll ask anyway. Greedy algorithms don't seem to work in my head.
Given a set of items, each with 1 or more tags, I want to find the smallest set of tags that cover all the items.
Edit: See my "solution" here.
...
A file contains a large number (eg.10 billion) of strings and you need to find duplicate Strings. You have N number of systems available. How will you find duplicates
...
I have this matrix:
1 2 3
4 5 6
and I transpose the matrix:
1 4
2 5
3 6
How can I get the original matrix back, after the transpose?
"untranspose" =
1 2 3
4 5 6
I am making a simple cryptographic algorithm in Java and need that to solve that problem.
...
Possible Duplicate:
Converting a Uniform Distribution to a Normal Distribution
Hello.
I'd like to know of any algorithm implemented in C which can take a random value between 0 and 1, the mean and standard deviation and then return a normally distributed result.
I have too little brainpower to figure this out for myself righ...
I have a simple (mass)-spring system wih two points which are connected with a spring. One point is fixed at a ceiling, so I want to calculate the position of the second point using a numerical method. So, basically I get the position of the second point and it's velocity, and want to know how these two value update after one timestep.
...
I wrote this program to test how long it would take to "solve" the set-cover problem.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using MoreLinq;
namespace SetCover
{
class Program
{
const int maxNumItems = 10000;
const int numSets = 5000;
...
Hello everyone,
I have an exam next week in algorithms, and was given questions to prepare for it. One of these questions has me stumped though.
"Can we draw a red-black tree with 7 black nodes and 10 red nodes? why?"
It sounds like it could be answered quickly, but I can't get my mind around it.
The CRLS gives us the maximum height ...