I have two points a and b, and a bounding box at 0,0,w,h. Both points are within the bounding box. How do I extend the line segment created by a and b to find points c and d where the line intersects the box?
*c-------------*
| \ |
| \ |
| a |
| \ |
| \ |
| b |
| ...
My goal is coming up with a script to track the point a line was added, even if the line is subsequently modified or moved around (both of which confuse traditional vcs 'blame' scripts. I've done some minor background research (see bottom) but didn't find anything useful. I have a concept for how to proceed but the runtime would be atr...
Is there a standard approach for deduping parallel event streams ? Before I attempt to reinvent the wheel, I want to know if this problem has some known approaches.
My client component will be communicating with two servers. Each one is providing a near real-time event stream (~1 second). The events may occasionally be out of order. ...
I am trying to figure out an efficient algorithm to take a list of items and generate all unique subsets that result from splitting the list into exactly 2 sublists. I'm sure there is a general purpose way to do this, but I'm interested in a specific case. My list will be sorted, and there can be duplicate items.
Some examples:
Inpu...
I have a 2D array which just contains boolean values showing if there is a tile at that point in the array or not. This works as follows, say if array[5,6] is true then there is a tile at the co-ordinate (5,6). The shape described by the array is a connected polygon possibly with holes inside of it.
Essentially all i need is a list of v...
For a Data Structures project, I must find the shortest path between two words (like "cat" and "dog), changing only one letter at a time. We are given a Scrabble word list to use in finding our path. For example:
cat -> bat -> bet -> bot -> bog -> dog
I've solved the problem using a breadth first search, but am seeking something bette...
Question
How can I randomly generate one of two states, with the probability of 'red' being generated 10% of the time, and 'green' being generated 90% of the time?
Background
Every 2 second either a green or a red light will blink.
This sequence will continue for 5 minutes.
The total number of occurrences of a blinking light should...
As far as I know There are 4 ways to solve recurrence equations :
1- Recursion trees
2- Substitution
3 - Iteration
4 - Derivative
We are asked to use Substitution, which we will need to guess a formula for output. I read from CLRS book that there is no magic to do this, i was curious if there are any heuristics to do this?
I can certa...
For my computer science class, we need to write a program (in C++) that takes an input of characters and outputs the possible permutations of it according to the dial pad on a phone, leaving non-digit characters in place.
For example, inputing 2 outputs 2, A, B, C. Inputing 23 outputs 23, A3, B3, C3, 2D, 2E, 2F, AD, AE, AF, BD, BE, BF, ...
Assuming a two dimensional array holding a 9x9 sudoku grid, where is my solve function breaking down? I'm trying to solve this using a simple backtracking approach. Thanks!
bool solve(int grid[9][9])
{
int i,j,k;
bool isSolved = false;
if(!isSolved(grid))
isSolved = false;
if(isSolved)
return isSolved;
for(i=0; i<9; i++...
Best way to implement a
dictionary (is their any DS better than Trie for Dictionary)
thesaurus (no idea, as match is made on meanings of the words, similar meanings)
spell checker (something better than a hash map), if possible with correct spelling recommendations.
when asked in an 1-hr interviews, are we expected to write a...
I have written a recursive function. For some reason it just won't call itself after it has run through for the first time. It just takes the next item from the loop without going down deeper. I am using Visual Studio 10, and am lacking sleep.
public IEnumerable<string> GeneratePath(int depth)
{
int presentDepth = depth;
char c...
Further to: http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axis
And what to do when some of the points
are negative?
I believe this part of the question was not answered but it seems I can't comment or extend that question so I've created a new one
Values -100, 0, 100 with 5 ticks:
...
I'm curious if n log n is the best a linked list can do.
Thanks
...
Is there any algorithm to compute the nth fibonacci number in sub linear time?
...
How to calculate the monthly fee on a loan?
Given is:
a: an amount to loan.
b: the loan period (number of months).
c: the interest rate p.a. (interests is calculated and added every month, 1/12 of the interest is added. So if the interest is on 12%, 1% interest is added every month).
d: the amount of money owed after the end of the pe...
Hi to all,
I got this problem that I can't just solve algorithmically.
Let's say i have a video capture that always captures video frames at a fixed rate F (let's say 30 frames per second).
What I want is to "split" this frame sequence in n (say four) subsequences. Each subsequence has its framerate fn, that's obviously < F. Frames in ...
What kind of algorithm would be good to cluster and rank blogs in logical communities (tech, entertainment, etc...)?
An algorithm to cluster and rank blog posts would be even better.
Answers accepted are algorithms, pseudo-code, java code or links to explanations on particular algorithms.
Update:
So, it seems I would like something i...
I just wondered whether (with some serious paranoia and under certain circumstances) the use of the QuickSort algorithm can be seen as a security risk in an application.
Both its basic implementation and improved versions like 3-median-quicksort have the peculiarity of behaving deviant for certain input data, which means that their runt...
Suppose there are two colors defined in CMYK:
color1 = 30, 40, 50, 60
color2 = 50, 60, 70, 80
If they were to be printed what values would the resulting color have?
color_new = min(cyan1 + cyan2, 100), min(magenta1 + magenta2, 100), min(yellow1 + yellow2, 100), min(black1 + black2, 100)?
Suppose there is a color defined in CMYK:
...