Changes

Jump to: navigation, search

Solo Act

810 bytes added, 05:38, 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, basically 'walking backwards':
leafTotal ((t / 2) + 1);
Basically 'walking backwards'The next step was making the thread index progression correspond to the root progression. For example, in round four, the thread index progression is 1, 3, 5, 7, for the greater of the leaf pair. This needed to be 0, 1, 2, 3.  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