Discussion:
A2 Q1 question
(too old to reply)
kun qian
2011-09-30 20:33:41 UTC
Permalink
Judging from the question the second constructor is suppose to take in
an array of n elements and build a heap using it? But the bubble down
procedure doesn't take arrays as an parameter. So what do I do?
cs240
2011-10-01 21:13:27 UTC
Permalink
Yes, the second constructor taks an array of n elements and build a heap
using it.

I don't see where the problem is. Why do you need the BubbleDown
procedure to take arrays as parameter?

Vivian Dong
CS240 Tutor
Post by kun qian
Judging from the question the second constructor is suppose to take in
an array of n elements and build a heap using it? But the bubble down
procedure doesn't take arrays as an parameter. So what do I do?
kun qian
2011-10-01 22:50:01 UTC
Permalink
Post by cs240
Yes, the second constructor taks an array of n elements and build a heap
using it.
I don't see where the problem is. Why do you need the BubbleDown
procedure to take arrays as parameter?
Vivian Dong
CS240 Tutor
Post by kun qian
Judging from the question the second constructor is suppose to take in
an array of n elements and build a heap using it? But the bubble down
procedure doesn't take arrays as an parameter. So what do I do?
The bubbledown procedure from the slides takes in Array as parameter.
But then in the buildheap example there is no such parameter. I do not
understand how Bubbledown is suppose to manipulate the array if it
doesn't take in arrays.
Su Zhang
2011-10-02 00:10:42 UTC
Permalink
Post by kun qian
But then in the buildheap example there is no such parameter. I do not
understand how Bubbledown is suppose to manipulate the array if it
doesn't take in arrays.
It does not manipulate the array passed to the constructor but rather
the member structure in which the actual heap data are stored. The
`BubbleDown' operation needs of course to be a member function of the
binary heap class in order to make this possible.

Su
cs240
2011-10-02 03:57:07 UTC
Permalink
Exactly!

Vivian
CS240 Tutor
It does not manipulate the array passed to the constructor but rather the
member structure in which the actual heap data are stored. The `BubbleDown'
operation needs of course to be a member function of the binary heap class in
order to make this possible.
Su
Loading...