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)

  1. solve ceiling b; (b+1)(b+2)/2 = i+1; (only positive root applies)
  2. solve j; j = - b*(b+1)/2;

example: case provided; i=8

  1. the first quadratic has roots -6, 3 (after ceiling) => choose 3
  2. j = 8-6=2

with fixed quadratic can come formula solve positive root.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -