The ever-helpful Wikipedia claims that diff implements Longest Common Subsequence.
This cannot be so. Diff, at least in -y mode, has three types of report: add, remove, and substitute. LCS does not have any concept of 'substitute'.
What is the algorithm of diff? I have reason to not believe that it is Levenshtein distance, but I might ...
Given a list of time ranges, I need to find the maximum number of overlaps.
Following is a dataset showing a 10 minute interval of calls, from
which I am trying to find the maximum number of active lines in that
interval. ie. from the example below, what is the maximum number of calls that were active at the same time:
CallStart Call...
An algorithm which will take two positive numbers N and K and calculate the biggest possible number we can get by transforming N into another number via removing K digits from N.
For ex, let say we have N=12345 and K=3 so the biggest possible number we can get by removing 3 digits from N is 45 (other transformations would be 12, 15, 35...
I am developing a Trie data-structure where each node represents a word. So words st, stack, stackoverflow and overflow will be arranged as
root
--st
---stack
-----stackoverflow
--overflow
My Trie uses a HashTable internally so all node lookup will take constant time. Following is the algorithm I came up to insert an item into the tr...
Hi,
I'm trying to calculate the amount of longest possible subsequences that exist between two strings.
e.g.
String X = "efgefg";
String Y = "efegf";
output: The Number of longest common sequences is: 3
(i.e.: efeg, efef, efgf - this doesn't need to be calculated by the algorithm, just shown here for demonstration)
I've manag...
Hi,
I have a number of possibly overlapping rectangles, of random size and position within a fixed plane. Since these rectangles are random, some may not overlap:
|-----
| | |----|
|----| | |
|----|
Some may overlap by just one corner:
|-----|
| |--|--|
|--|--| |
|-----|
Some may be contained inside an...
Hi,
I am trying to trace the path of a node in a binary tree (not a binary search tree). Given a node, I am trying to print the values of the path from the root.
I have written the following program.
package dsa.tree;
import java.util.Stack;
public class TracePath {
private Node n1;
public static void main(String args[])...
A word is grouped if, for each letter in the word, all occurrences of that letter form exactly one consecutive sequence. In other words, no two equal letters are separated by one or more letters that are different.
Given a vector<string> return the number of grouped words.
For example :
{"ab", "aa", "aca", "ba", "bb"}
return 4.
He...
Assume you are given two arrays of integers of constant length which is 3, and you are always sure that two elements of the given two arrray will have same values.
so assume array A has three values: a, b, c.
and array B has three values: d, e, f.
we are sure that two of the values will be same. we are asked to put these four different...
In proving and disproving Big O questions that explicitly say use the definition to prove and disprove, my question is, is what I am doing correct?
For example you have a question that is g(n) = O(f(n)) ... In order to prove it I was doing the following
g(n) <= C(F(n))
g(n)/F(n) <= C .. then give n=1 and solve for C , which proves it.
...
Hi,
I am looking algorithms or techniques so that i can minimize the pixel stretching effect for a given image. I am not looking for any tool.
...
Hello! I had one of my friends send me this programming assignment so I could brush up on some of my C++ skills. Below is the program description and my proposed algorithm. Could someone please provide some feedback/alternative solutions:
Problem:
This program creates word search puzzles - Words are printed at random locations in a rec...
I am writing a simple OCR solution for a finite set of characters. That is, I know the exact way all 26 letters in the alphabet will look like. I am using C# and am able to easily determine if a given pixel should be treated as black or white.
I am generating a matrix of black/white pixels for every single character. So for example, the...
Recently I saw demonstration of image distortion algorithm that preserves some objects in image. For example changing weight/height ratio but preserving people faces in image to look realistically. The problem is i can't find the reference to that demonstration neither I know the name of such transformations.
Can anybody point me to a ...
Hi,
I'm taking an algorithm course at the university, and for one of my projects I want to implement a red-black tree in C# (the implementation itself isn't the project, yet just something i decided to choose to help me out).
My red-black tree should hold string keys, and the object i created for each node looks like this :
class sRbTr...
I'm looking for algorithms like ones in the stl (push_heap, pop_heap, make_heap) except with the ability to pop both the minimum and maximum value efficiently. AKA double ended priority queue. As described here.
Any clean implementation of a double ended priority queue would also be of interest as an alternative, however this question ...
How can I generate the shortest sequence with contains all possible permutations?
Example:
For length 2 the answer is 121, because this list contains 12 and 21, which are all possible permutations.
For length 3 the answer is 123121321, because this list contains all possible permutations:
123, 231, 312, 121 (invalid), 213, 132, 321.
E...
As part of our system simulation, I'm modeling a memory space with 64-bit addressing using a sparse memory array and keeping a list of objects to keep track of buffers that are allocated within the memory space. Buffers are allocated and de-allocated dynamically.
I have a function that searches for a given address or address range with...
I have these 2 sequences for a binary tree (not a BSD):
InOrder: 3 2 1 4 5 7 6
PostOrder: 3 1 2 5 6 7 4
We know that the last element in postOrder is the root, so we locate the root at the inOrder sequence and subdivide like this:
- all the elements at the left of the root go to the left subtree
- all the elements at the right of the ...
When using a simple encryption method in which the letters are replaced by the indexing numbers of the alphabet, there are multiple ways of decrypting them, ex. ABOR is 121518 but 121518 could also be AYEAH or LAER.
Well I need an algorithm to calculate how many possible ways there are for a given number to decrypt the message via the ...