Is there an algorithm ( preferably in C# implementation) that allows me to compare how similar two lines are? In my case I have one reference line, and I have a lot of secondary lines, I need to choose, out of so many secondary lines, which is the closest to the reference line.
Edit: It is a 2D line, with start and stop points. When yo...
Hi All,
Here is one of my interview question. Given an array of N elements and where an element appears exactly N/2 times and the rest N/2 elements are unique. How would you find the element with a better run time?
Remember the elements are not sorted and you can assume N is even. For example,
input array [] = { 10, 2, 3, 10, 1, 4, 10...
In my webapp, we have many fields that sum up other fields, and those fields sum up more fields. I know that this is a directed acyclic graph.
When the page loads, I calculate values for all of the fields. What I'm really trying to do is to convert my DAG into a one-dimensional list which would contain an efficient order to calculate th...
The Scenario
I have several number ranges. Those ranges are not overlapping - as they are not overlapping, the logical consequence is that no number can be part of more than one range at any time. Each range is continuously (there are no holes within a single range, so a range 8 to 16 will really contain all numbers between 8 and 16), b...
Dear all,
Is it possible to find out whether one drawing line (which is not in a horizontal or vertical position) overlapped (or touched) any other items (like line, rectangle, circle etc). Kindly advise me on the possibilities and solution with examples.
Thanks for looking into this...
...
I was wondering when one should use Prim's algorithm and when Kruskal's to find the minimum spanning tree? They both have easy logics, same worst cases, and only difference is implementation which might involve a bit different data structures. So what is the deciding factor?
...
I'm wondering if there is an algorithm for calculating the nearest locations (represented by lat/long) in better than O(n) time.
I know I could use the Haversine formula to get the distance from the reference point to each location and sort ASC, but this is inefficient for large data sets.
How does the MySQL DISTANCE() function perform...
Hi Guys,
I have a bit of a difficult algorithm question, I can't find any suitable algorithm from a lot of searching, so I am hoping that someone here on stackoverflow might know the answer.
I have a set of x,y coordinates for a vehicle as it moves through a 2D space, the coordinates are recorded at "decision points" in the time period...
I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle.
Is there a fast and efficient way of doing this? Something along the same lines of Bresenham?
The language I am using is C.
...
Hi there
I have given a tree like this:
i can acces each node with the next operator.
// postorder dfs
Iterator< Index<String<char> >, BottomUp<> >::Type myIterator(myIndex);
for (; !atEnd(myIterator); goNext(myIterator))
// do something with myIterator
but i want to use a recursive algorithm on the tree.
Is there a way i can ...
I'm having a hell of a time trying to figure this one out. Everywhere I look, I seem to be only running into explanations on how to actually traverse through the list non-recursively (the part I actually understand). Can anyone out there hammer in how exactly I can go through the list initially and find the actual predecessor/successor n...
I've been doing programming for a few years and I am passionate about algorithms. I read books on it and develop them for programming contests. But on the interviews they ask me more and more non-algorithmic questions, the ones that you have to read a thick book on .NET and remember most of it by memory like the Bible. Does it mean that ...
Here's a problem that I seem to be running into working with an accounting system.
I have a set of transactions, but their sum does not equal the amount that the accounting department thinks that it should. They are not questioning the math, just the transactions being included :p
Is there an algorithm that would help me determine whic...
Hi everyone
I have some data in a tree structure, and I want to represent them in a graphical way, with the root node in the middle of the stage, his children displaced in a circle around him, and so on for every children, around their parent.
I don't want overlapping nodes, so the question is how to arrange space in an optimal way.
Some...
So I've been working on a wiki type site. What I'm trying to decide on is what the best algorithm for merging an article that is simultaneously being edited by two users.
So far I'm considering using Wikipedia's method of merging the documents if two unrelated areas are edited, but throwing away the older change if two commits conflict...
It's easy to convert Decimal to Binary and vice-versa in any language, but I need a function that's a bit more complicated.
Given a decimal number and a binary place, I need to know if the binary bit is On or Off (True or False).
Example:
IsBitTrue(30,1) // output is False since 30 = 11110
IsBitTrue(30,2) // output is True
IsBitTrue(30...
Hello ,
Is there any specific algorithm for handwriting recognition?
The algorithm should recognize the hand written letter.
Any one could help would be greatly appreciated in advance.
Thank you
...
I'm trying to solve the problem of stacking objects into the most convenient size for postage. The size and shape of objects will be varied. Length, width and height of all objects is known.
For example a customer may order a (length x width x height) 200x100x10cm object (wide, long and flat) along with 2 50x50x50cm objects (cubes). If ...
I am writing an algorithm to generate combinations of items from a database. They need to be unique permutations (i.e. 145, 156 == 156, 145). The problem I am running into is how to keep track of previous combinations so that i do not end up with 145, 156 and 156, 145.
Currently I am adding them to an array with index of id1_id2... (so...
Hello. This may be a hard question to answer but I'm researching something and I was wondering if anyone knew of "lesser known" string similarity metrics (see this page for examples of well-known ones). I've been to wikipedia and Sourceforge has a nice library called Simmetrics with a bunch of string metric algorithms. Has anyone done so...