20.6

1 view
Skip to first unread message

Colin Thompson

unread,
Dec 5, 2011, 12:36:45 AM12/5/11
to byu-cs-jm-1...@googlegroups.com
For 20.6 are we supposed to mutate the elements of the array to the
average values and return void, or are we supposed to make a new array
and return that?

Jay McCarthy

unread,
Dec 5, 2011, 12:38:49 AM12/5/11
to byu-cs-jm-1...@googlegroups.com
"it takes an array of prices and replaces the values with their moving averages."


On Sun, Dec 4, 2011 at 10:36 PM, Colin Thompson <thom...@gmail.com> wrote:
For 20.6 are we supposed to mutate the elements of the array to the average values and return void, or are we supposed to make a new array and return that?



--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Colin Thompson

unread,
Dec 5, 2011, 12:45:05 AM12/5/11
to byu-cs-jm-1...@googlegroups.com
Are we allowed to make a new array to help us that we do not return?

Jay McCarthy

unread,
Dec 5, 2011, 12:46:28 AM12/5/11
to byu-cs-jm-1...@googlegroups.com
I guess, although I can't think of why that would be useful. Take what you did in #5 and convert it to a while loop with mutation and array rather than a list. There's no intermediate array there. Also, you can't really make new arrays you're stuck with the ones you start with.

Jay
Reply all
Reply to author
Forward
0 new messages