algorithm

How to create subsets of a single set of elements (where element names are complex) with XSLT?

In continuation of the question I had asked concerning "How to create subsets of a single set of elements with XSLT?" I wish to take my problem one step further: I had originally given the following XML as the original: <Set> <Element name="Superset1_Set1_Element1"/> <Element name="Superset1_Set1_Element2"/> <Element name="Sup...

I got a file full with hex addresses(char) what's the best way to convert them to unsigned long ?

Hey, I got a file full with hexadecimal addresses, I've managed to parse the file and fetch them yet I must convert them back to unsigned long, what's the best algorithm or fast way to do so considering the file is very long (a few megs) ? Thanks in advance. ...

Recommend an algorithms exercise book?

I have a little book called Problems on Algorithms by Ian Parberry which is chock full of exercises related to the study of algorithms. Can anybody recommend similar books? What I am not looking for are recommendations of good books related to algorithms or the theory of computation. Introduction to Algorithms is a good one, and of co...

lz77 question

what is the minimum source length (in bytes) for LZ77. can anyone suggest a small and fast real time compression technique (preferable with c source). i need it to store compressed text and fast retrieval for excerpt generation in my search engine. thanks ...

Comparing collections of subsets up to permutation

I have an array a[i][j]. The elements are char, interpreted as subsets of the set {1,...,8} (the element k is in the subset if the k-th bit is 1). I do not think it is relevant, but every element has exactly 4 bits set. Every row a[1][j]..a[n][j] is a collection of subsets of {1,...,8}. I need to remove duplicate rows, where two rows ar...

Deriving the Inverse of a subnet definition

An IP Subnet is defined with two parts, a network and a prefix-length or mask. For example 192.168.0.0/16 (or, 192.168.0.0/255.255.0.0). An IP address like 192.168.1.1 is said to match this subnet because, (192.168.1.1 & 255.255.0.0) == 192.168.0.0 I am interested in what might be called the inverse of a subnet which is described...

What is the name of this problem?

You are given a list of distances between various points on a single line. For example: 100 between a and b 20 between c and b 90 between c and d 170 between a and d Return the sorted sequence of points as they appear on the line with distances between them: For example the above input yields: a<----80-----> c <----20------> b <-...

SLAM Algorithm

Does anyone have any experience with developing or working on the autonomous robot problem, in particular developing the SLAM algorithm? I would like to know where would be a good place to get started on developing a very very basic version on SLAM. Also any pointers to resources on the topics (other than the obvious google searches) wou...

Equidistant points across a cube

I need to initialize some three dimensional points, and I want them to be equally spaced throughout a cube. Are there any creative ways to do this? I am using an iterative Expectation Maximization algorithm and I want my initial vectors to "span" the space evenly. For example, suppose I have eight points that I want to space equally in...

Linked List: Is this solution good?

I was looking for a way to avoid starting from the head of the list each time I want to find a node, so I thought of assigning indexes to nodes, keeping a pointer to a random (not exactly random; see below) node and then finding the pointer that's closest to the index I want to find. Allow me to explain with code: // head and last are p...

Best compression algorithm for XML?

Hello, I barely know a thing about compression, so bear with me (this is probably a stupid and painfully obvious question). So lets say I have an XML file with a few tags. <verylongtagnumberone> <verylongtagnumbertwo> text </verylongtagnumbertwo> </verylongtagnumberone> Now lets say I have a bunch of these very long tags with...

Auto scale and rotate images

Given: two images of the same subject matter; the images have the same resolution, colour depth, and file format; the images differ in size and rotation; and two lists of (x, y) co-ordinates that correlate the images. I would like to know: How do you transform the larger image so that it visually aligns to the second image? (Option...

Efficient way to practice graph theory algorithms

I just read about the breadth-first search algorithm in the Introduction to Algorithms book and I hand simulated the algorithm on paper. What I would like to do now is to implement it in code for extra practice. I was thinking about implementing all the data structures from scratch (the adjacency list, the "color", "distance", and "par...

Efficient algorithm for Next button on a MySQL result set

I have a website that lets people view rows in a table (each row is a picture). There are more than 100,000 rows. You can view different subsets of the rows, and you can view them with different sort orders. While you are viewing one of the rows, you can click the "Next" or "Previous" buttons to go the next/previous row in the list. ...

wordwrap function

Hey guys, I'm writing a word wrap function to format console text in C++. My problem is either A) I don't understand exactly what std::string::iterators do, or B) one of my iterators is not being set properly. Can anyone shed some light on the reason this code fails? by the way: sorry if this goes into too much detail. I'm not sure if m...

In simple terms, how is compression commonly implemented?

So I've been thinking lately about how compression might be implemented, and what I've postulated so far is that it might be using a sort of HashTable of 'byte signature' keys with memory location values where that 'byte signature' should be replaced upon expansion of the compressed item in question. Is this far from the truth? How is ...

What's the best way to strip leading / trailing digits from a number?

If I have a number like 12345, and I want an output of 2345, is there a mathematical algorithm that does this? The hack in me wants to convert the number to a string, and substring it. I know this will work, but I'm sure there has to be a better way, and Google is failing me. Likewise, for 12345, if I want 1234, is there another algor...

Folder searching algorithm

Not sure if this is the usual sort of question that gets asked around here, or if I'll get any answers to this one, but I'm looking for a pseudo-code approach to generating DB linking records from a folder structure containing image files. I have a set of folders, structured as folllows: +-make_1/ | +--model_1/ | +-default_versi...

How is linear algebra used in algorithms?

Several of my peers have mentioned that "linear algebra" is very important when studying algorithms. I've studied a variety of algorithms and taken a few linear algebra courses and I don't see the connection. So how is linear algebra used in algorithms? For example what interesting things can one with a connectivity matrix for a graph...

Channel allocation algorithm

We have a set of radio nodes in close proximity to each other and would like to allocate the frequencies for them to minimize overlap. To get complete coverage of the area, radio channels need to be oversubscribed and so we will have nearby radios transmitting on the same frequency. Sample data: 5 Frequencies 343 Radios 4158 Edges M...