algorithm

how to find distinct digit set numbers over a range of integers?

Suppose i have a unsigned integer, call it low and one another call it high such that high>low. The problem is to find distinct digit set numbers over this range. For example, suppose low is 1 and high is 20 then the answer is 20, because all the numbers in this range are of distinct digit sets. If suppose low is 1 and high is 21, then t...

Can someone help me with simple algo?

I want to parse all bytes downloaded by http request if they are > 100kb, if they are not, to concat them to a buffer and when the buffer gets > 100kb to parse them again and null the uffer. But not to parse all the file data and in the final chunk to get ex: 2kb. It must check the next chunk and if it's final to concat it (ex: final_chu...

Text detection of image

I got grayscale images made by cheap camera and I need to make a program OCR. The main problem is noise or objects that are not text but they present in binary image. Now I think of text extraction from image. I need some good algorithm for that. Can you suggest any really good one? For example if image contains black color text and so...

Interval tree algorithm that supports merging of intervals with no overlap

I'm looking for an interval tree algorithm similar to the red-black interval tree in CLR but that supports merging of intervals by default so that there are never any overlapping intervals. In other words if you had a tree containing two intervals [2,3] and [5,6] and you added the interval [4,4], the result would be a tree containing ju...

Print all ways to sum n integers so that they total a given sum.

Im trying to come up with an algorithm that will print out all possible ways to sum N integers so that they total a given value. Example. Print all ways to sum 4 integers so that they sum up to be 5. Result should be something like: 5 0 0 0 4 1 0 0 3 2 0 0 3 1 1 0 2 3 0 0 2 2 1 0 2 1 2 0 2 1 1 1 1 4 0 0 1 3 1 0 1 2 2 0 1 2...

Trying to generate all sequences of specified numbers up to a max sum

Hi, Given the following list of descending unique numbers (3,2,1) I wish to generate all the sequences consisting of those numbers up to a maximum sum. Let's say that the sum should be below 10. Then the sequences I'm after are: 3 3 3 3 3 2 1 3 3 2 3 3 1 1 1 3 3 1 1 3 3 1 3 3 3 2 2 2 3 2 2 1 1 3 2 2 1 3 2 2 3 2 1 1 1 1 3 2 1 1 1 3 2 1...

Design Help/Suggestion required

I have an Application built 4 years back, The Application generates the 1,00,000 challans every year. I am maintaining the separate table for storing the challans and I have the Challan Id(Auto Increment) and that I am using that as the Challan Number for the application. Every since i am generating the challan Number, the length of th...

Optimally place a pie slice in a rectangle.

Given a rectangle (w, h) and a pie slice with a radius less or equal to the smaller of both sides (w, h), a start angle and an end angle, how can I place the slice optimally in the rectangle so that it fills the room best (from an optical point of view, not mathematically speaking)? I'm currently placing the pie slice's center in the ce...

Is there any super fast algorithm for finding LINES on picture?

So I have Image like this I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea) I need some super fast algorithm for finding all straight lines on it. I want to give to algorithm parameters like min length and max line distortion. I want to get relative to picture pixel coords start and...

Technologies required for connectedTv

Can anyone help me suggesting which technologies will be useful to implement a ConnectedTv. In ConnectedTv where the Internet is configured in TV, while watching TV, users can browse the TV. ...

How to find nth element from the end of a singly linked list?

The following function is trying to find the nth to last element of a singly linked list. For example: If the elements are 8->10->5->7->2->1->5->4->10->10 then the result is 7th to last node is 7. Can anybody help me on how this code is working or is there a better and simpler approach? LinkedListNode nthToLast(LinkedListNode head,...

How to use Haar wavelet to detect LINES on an image?

So I have Image like this I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea) I want to use SURF ( (Speeded Up Robust Features) is a robust image descriptor, first presented by Herbert Bay et al. in 2006 ) or something that is based on sums of 2D Haar wavelet responses and makes an e...

k-combinations of a set of integers in ascending size order

Programming challenge: Given a set of integers [1, 2, 3, 4, 5] I would like to generate all possible k-combinations in ascending size order in Java; e.g. [1], [2], [3], [4], [5], [1, 2], [1, 3] ... [1, 2, 3, 4, 5] It is fairly easy to produce a recursive solution that generates all combinations and then sort them afterwards but I imag...

how to determine base of a number?

Given a integer number and its reresentation in some arbitrary number system. The purpose is to find the base of the number system. For example, number is 10 and representation is 000010, then the base should be 10. Another example: number 21 representation is 0010101 then base is 2. One more example is: number is 6 and representation os...

Is there any algorithm for finding LINES by PIXEL COLORS on picture?

So I have Image like this I want to get something like this (I hevent drawn all lines I want but I hope you can get my idea) I need algorithm for finding all straight lines on it by just reading colors of pixels. No hard math, no Haar, no Hough. Some algorithm which would be based on points colors. I want to give to algorithm para...

How can I compute the average cost for this solution of the element uniqueness problem?

In the book Introduction to the Design & Analysis of Algorithms, the following solution is proposed to the element uniqueness problem: ALGORITHM UniqueElements(A[0 .. n-1]) // Determines whether all the elements in a given array are distinct // Input: An array A[0 .. n-1] // Output: Returns "true" if all the elements in A are distinct /...

Water jugs heuristic function for A*

Hi all, For the classic water jugs search problem, even for more than three jugs, which are some admissible functions that can be used for the A* search algorithm? Edit: I know about http://www.dave-reed.com/csc550.S02/HW/HW4.html , but that function clearly is not consistent. ...

How to implement dynamic binary search for search and insert operations of n element

The idea is to use multiple arrays, each of length 2^k, to store n elements, according to binary representation of n.Each array is sorted and different arrays are not ordered in any way. In the above mentioned data structure, SEARCH is carried out by a sequence of binary search on each array. INSERT is carried out by a sequence of merg...

How does lucene index documents?

Hello, I read some document about Lucene; also I read the document in this link (http://lucene.sourceforge.net/talks/pisa). I don't really understand how Lucene indexes documents and don't understand which algorithms Lucene uses for indexing? On the above link, it says Lucene uses this algorithm for indexing: incremental algorithm: ...

Sorting a list of variable length integers delimited by decimal points...

Hey guys, I'm in need of some help. I have a list of delimited integer values that I need to sort. An example: Typical (alpha?) sort: 1.1.32.22 11.2.4 2.1.3.4 2.11.23.1.2 2.3.7 3.12.3.5 Correct (numerical) sort: 1.1.32.22 2.1.3.4 2.3.7 2.11.23.1.2 3.12.3.5 11.2.4 I'm having trouble figuring out how to setup the algor...