Changes

Jump to: navigation, search

Solo Act

16 bytes added, 06:39, 16 April 2018
Assignment 3
[[File:njsimasroot.png|500px ]]
 
The first step was using modulus to set the odd value in the leaf pair equal to the greater value:
 
modIndex =((ti + q) + (ti + 1) % 2)
I needed the number of nodes in the previous round, plus one, to later subtract from the current array index:
leafTotal I needed the number of nodes in the previous round, plus one, to later subtract from the current array index, basically 'walking backwards':   prevLeafTotal = ((t / 2) + 1);
Basically 'walking backwards'
The next step was making the thread index progression correspond to the root progression.
To do this, I add one, divide by two, and subtract one, and then add the modulus, as in step one, to account for the lesser of the leaf pair.
 
Progression = (((ti + 1) / 2) – 1) + ((ti + q) + (ti + 1) % 2)
 
Finally, I add this progression to the previous leaf total, and subtract the result from the new array index from stage 1:
 
root = modIndex – (leafTotal + progression)
 
Since this was all to be done by a single thread, in a single step, I condensed the formula into one line.
 
((ti + q) + ((ti + 1) % 2)) - (((((ti + 1) / 2) - 1) + ((ti + 1) % 2)) + (t / 2) + 1);
120
edits

Navigation menu