java - Given a list index, how can I find the block and block index for that element in a Rootish ArrayStack Mathematically? -
suppose example given large number i
list index , wanted figure out block , block index element in list index corresponded in rootish arraystack. example:
list index = 8, know in block r = 3 , within block, @ index 2
since list index small, can calculation small sketch of rootish arraystack, larger list indexes no longer reasonable option. there sort of mathematical equation can plug in list index , solve this?
thanks
terminology: represents index (in example = 8), b represents block (3), , j represents index in b (2)
- solve ceiling b; (b+1)(b+2)/2 = i+1; (only positive root applies)
- solve j; j = - b*(b+1)/2;
example: case provided; i=8
- the first quadratic has roots -6, 3 (after ceiling) => choose 3
- j = 8-6=2
with fixed quadratic can come formula solve positive root.
Comments
Post a Comment