23 views2 pages

Document Summary

Be sure to show your code to one of the lab tas before you leave, so that you can receive credit for this lab. The distribute() method does not return any value; instead, it directly modifies its array parameter. For example, consider the initial array [ 3, 1, 6, 2, 4, 1, 5 ], which has a length of 7. Our starting index is 3, which holds the value 2. We will set the value of index 3 to 0, and add. 1 to each of the next 2 array values, to get the final result [ 3, 1, 6, 0, 5, 2, 5 ]. If we had a sufficiently large starting value, we would wrap around"" the end of the array to continue incrementing the array values. For example, if our starting index had been 2 (which holds the value 6) instead, we would have incremented indices 3, 4, 5, 6,