Discussion:
A2 Q2
(too old to reply)
Chris Jones
2011-10-03 19:41:27 UTC
Permalink
Hello again,

When we are writing the functions to find the children and parent are
we to assume they exist?

Thanks,
Doug Stinson
2011-10-04 13:48:03 UTC
Permalink
Post by Chris Jones
Hello again,
When we are writing the functions to find the children and parent are
we to assume they exist?
Thanks,
You should check that they exist as part of your function description.
Doug Stinson.
Kérberos Caelestius
2011-10-12 01:48:52 UTC
Permalink
Post by Doug Stinson
Post by Chris Jones
Hello again,
When we are writing the functions to find the children and parent are
we to assume they exist?
Thanks,
You should check that they exist as part of your function description.
Doug Stinson.
I'm still unclear on this. Aren't these functions just going to
consume an index i and output some other index? How do we check if a
child exists, etc?
Su Zhang
2011-10-12 14:20:10 UTC
Permalink
Post by Kérberos Caelestius
I'm still unclear on this. Aren't these functions just going to
consume an index i and output some other index? How do we check if a
child exists, etc?
If a child does not exist, its associated index will be out of bound,
and this is already checked by the pseudocode in the slides.

kun qian
2011-10-12 02:07:36 UTC
Permalink
Post by Doug Stinson
Post by Chris Jones
Hello again,
When we are writing the functions to find the children and parent are
we to assume they exist?
Thanks,
You should check that they exist as part of your function description.
Doug Stinson.
I think it to check whether the node exist depends on implementation.
So I don't think the question should require the solution to check for
existence.
chaolei
2011-10-12 03:16:14 UTC
Permalink
Post by kun qian
Post by Doug Stinson
Post by Chris Jones
Hello again,
When we are writing the functions to find the children and parent are
we to assume they exist?
Thanks,
You should check that they exist as part of your function description.
Doug Stinson.
I think it to check whether the node exist depends on implementation.
So I don't think the question should require the solution to check for
existence.
so we are just need to write a mathematical function like heap we talk
on class, for example: the left child of A[i] is A[2i].
am I right?
thanks~
cs240
2011-10-12 05:12:24 UTC
Permalink
Yes, you are expected to write mathematical functions like the ones on
slide 53 (module 2). Whether the nodes exist or not should be a condition
that is included in your function description.

Vivian
CS240 Tutor
Post by kun qian
Post by Doug Stinson
Post by Chris Jones
Hello again,
When we are writing the functions to find the children and parent are
we to assume they exist?
Thanks,
You should check that they exist as part of your function description.
Doug Stinson.
I think it to check whether the node exist depends on implementation.
So I don't think the question should require the solution to check for
existence.
so we are just need to write a mathematical function like heap we talk on
class, for example: the left child of A[i] is A[2i].
am I right?
thanks~
Loading...