ex6 question

0 views
Skip to first unread message

Aaron

unread,
Jun 13, 2011, 11:18:26 PM6/13/11
to BYU CS 142 (Spring 2011) [McCarthy]
Ex 6 says:

6. Modify #5 so that it takes a vector of prices

I understood vector of prices as a ListOfPrices. I have it working as
a ListOfPrices. However, I think I remember faintly that in class,
the teacher said that a vector was an array. should the contract be
ListOfPrices -> ListOfPrices or should it be double[] -> double[]?

Jay McCarthy

unread,
Jun 13, 2011, 11:31:17 PM6/13/11
to byu-cs-jm-14...@googlegroups.com
A vector is another name for an array.

Jay

2011/6/14 Aaron <l33...@gmail.com>:

--
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

Jay McCarthy

unread,
Jun 13, 2011, 11:31:28 PM6/13/11
to byu-cs-jm-14...@googlegroups.com
So it should be double[] -> double[]

2011/6/14 Jay McCarthy <jay.mc...@gmail.com>:

Joe Larson

unread,
Jun 15, 2011, 2:22:51 AM6/15/11
to BYU CS 142 (Spring 2011) [McCarthy]
I'm confused as far as what this problem is asking for. I understand
that vector means array, but I don't know what you mean by "replaces
the values with their moving averages" or "If there is not enough data
for a three day average for the day, replace it with NaN." Could you
give me a sample input and output for the program (like in ex 5)?
Thanks.

On Jun 13, 9:31 pm, Jay McCarthy <jay.mccar...@gmail.com> wrote:
> So it should be double[] -> double[]
>
> 2011/6/14 Jay McCarthy <jay.mccar...@gmail.com>:
>
>
>
>
>
>
>
>
>
> > A vector is another name for an array.
>
> > Jay
>
> > 2011/6/14 Aaron <l33...@gmail.com>:
> >> Ex 6 says:
>
> >> 6. Modify #5 so that it takes a vector of prices
>
> >> I understood vector of prices as a ListOfPrices.  I have it working as
> >> a ListOfPrices.  However, I think I remember faintly that in class,
> >> the teacher said that a vector was an array.  should the contract be
> >> ListOfPrices -> ListOfPrices or should it be double[] -> double[]?
>
> > --
> > 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
>
> --
> Jay McCarthy <j...@cs.byu.edu>
> Assistant Professor / Brigham Young Universityhttp://faculty.cs.byu.edu/~jay

Jay McCarthy

unread,
Jun 15, 2011, 7:34:55 AM6/15/11
to byu-cs-jm-14...@googlegroups.com
The #5 example is an example for #6

If you had the array, [1, 2, 3, 4], then it would be [NaN, NaN,
((1+2+3)/3), ((2+3+4)/3)]

Jay

2011/6/15 Joe Larson <brothe...@gmail.com>:

Mark

unread,
Jun 16, 2011, 12:20:22 AM6/16/11
to BYU CS 142 (Spring 2011) [McCarthy]
That wouldn't return [(1+2+3)/3, (2+3+4)/3, NaN, NaN]? That's how the
previous example worked.

On Jun 15, 5:34 am, Jay McCarthy <jay.mccar...@gmail.com> wrote:
> The #5 example is an example for #6
>
> If you had the array, [1, 2, 3, 4], then it would be [NaN, NaN,
> ((1+2+3)/3), ((2+3+4)/3)]
>
> Jay
>
> 2011/6/15 Joe Larson <brotherjos...@gmail.com>:

Jeremy Bejarano

unread,
Jun 16, 2011, 12:48:19 AM6/16/11
to BYU CS 142 (Spring 2011) [McCarthy]
It says "takes a vector of prices and replaces the values with their
moving averages." I assume this means that the contract should be
double[] -> void. Right?

On Jun 13, 9:31 pm, Jay McCarthy <jay.mccar...@gmail.com> wrote:
> So it should be double[] -> double[]
>
> 2011/6/14 Jay McCarthy <jay.mccar...@gmail.com>:
>
>
>
>
>
> > A vector is another name for an array.
>
> > Jay
>
> > 2011/6/14 Aaron <l33...@gmail.com>:
> >> Ex 6 says:
>
> >> 6. Modify #5 so that it takes a vector of prices
>
> >> I understood vector of prices as a ListOfPrices.  I have it working as
> >> a ListOfPrices.  However, I think I remember faintly that in class,
> >> the teacher said that a vector was an array.  should the contract be
> >> ListOfPrices -> ListOfPrices or should it be double[] -> double[]?
>
> > --
> > 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
>
> --
> Jay McCarthy <j...@cs.byu.edu>
> Assistant Professor / Brigham Young Universityhttp://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93- Hide quoted text -
>
> - Show quoted text -

Jay McCarthy

unread,
Jun 16, 2011, 7:31:47 AM6/16/11
to byu-cs-jm-14...@googlegroups.com
No, the NaNs go in front because until the third element you don't
have enough data to do an average.

Jay

2011/6/16 Mark <Ma...@morrowlife.net>:

Jay McCarthy

unread,
Jun 16, 2011, 7:31:59 AM6/16/11
to byu-cs-jm-14...@googlegroups.com
Ah yes, you are right. Sorry for the mistake.

2011/6/16 Jeremy Bejarano <klak...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages