Sign up ×

This should be pretty simple. Here is what I want to put into a formula/algorithm:

Divide the size of every object of an array by the number of times that object has been accessed in the last n seconds and discarding the highest quotient. (You can probably ignore the bold part)

I can program this just fine, but I am going to be showing it to a Mathematician (one of my professors) and I would like to impress him a bit. If the description of what I want is not clear and an example in code would help let me know and I'll whip something up real quick.

share|cite|improve this question
Sounds pretty clear to me. – Yuval Filmus Jan 26 '11 at 6:02
@Yuval Filmus do you know how to write what I want in a formula? The part I don't know how to do is representing the array (I assume I would use a set) in mathematical terms and showing in the formula that I want to "loop" through all items in the set. – ubiquibacon Jan 26 '11 at 6:09
I agree with Yuval here; there's no reason to use any fancy math notation because the words you have currently are already very clear. Adding any symbols would unnecessarily complicate the algorithm. (And anyway, I don't think that there is any standard notation for what you want. Probably the best you can do is just write pseudocode for the algorithm, but that's not particularly mathy.) – Ben Alpert Jan 26 '11 at 6:34

1 Answer 1

up vote 3 down vote accepted

The sizes of the objects form a vector $\vec{s}$. The access statistics form a vector $\vec{a}$. The quotients form a vector $\vec{q}$ defined by $$q_i = n_i/a_i.$$ This is your array division. The "mathy" notation is $q_i$ for the C "q[i]".

Now you want to take your array and ignore the maximum, so let $$p = \mathrm{argmax}_i q_i,$$ and then you want to ignore coordinate $p$.

But I think your professor also understands English.

share|cite|improve this answer
Point taken, I will stick with the English version and simply augment it with what I know (code). – ubiquibacon Jan 26 '11 at 6:50

Your Answer


