tags:

views:

112

answers:

5

Let's say I have a sequence of values (e.g., 3, 5, 8, 12, 15) and I want to occasionally decrease all of them by a certain value.

If I store them as the sequence (0, 2, 3, 4, 3) and keep a variable as a base of 3, I now only have to change the base (and check the first items) whenever I want to decrease them instead of actually going over all the values.

I know there's an official term for this, but when I literally translate from my native language to English it doesn't come out right.

+2  A: 

An offset?

Greg
I meant that I think there's a term for sequences that are managed like this... Where each element is based on the previous one. But it's been more than 10 years since college and it was in a different language...
Uri
+1  A: 

If I understand your question right, you're rebasing. That's normally used in reference to patching up addresses in DLLs from a load address.

I'm not sure that's what you're doing, because your example seems to be incorrect. In order to come out with { 3, 5, 8, 12, 15 }, with a base of 3, you'd need { 0, 2, 5, 9, 12 }.

Mark Brackett
No -his offsets are correct. He's talking about the difference between each N and N+1 in the sequence. 3-3 = 0, 5-3 =2 etc.
Steve Fallows
+4  A: 

Differential Coding / Delta Encoding?

I don't know a name for the data structure, but it's basically just base+offset :-)

Matt J
+1  A: 

I'm not sure. If you imagine your first array as providing the results of some function of an index value f(i) where f(0) is 3, f(1) is 5, and so forth, then your second array is describing the function f`(i) where f(i+1) = f(i) + f'(i) given f(0) = 3.

I'd call it something like a derivative function, where the process of retrieving your original data is simply the summation function.

What will happen more often, will you be changing f(0) or retrieving values from f(i)? Is this technique rooted in a desire to optimize?

Perhaps you're looking for a term like "Inductive Sequence" or "Induction Sequence." (I just made that up.)

Greg D
+1  A: 

Are you just looking for the word "recursive", where each value would depend on the one before it?

Chris Shaffer