swtv-kaist / cs458-fall22

1 stars 0 forks source link

Size of the array and the empty nodes #9

Open A-Mehdi opened 1 year ago

A-Mehdi commented 1 year ago

I have two questions:

  1. The homework description says that the size of the input array will be 8. Is this always true, even when there are only 5 nodes in the tree?
  2. Can we assume that 0 value means an empty node? For example if we have tree with 5 nodes then input array will be [0, 16, 10, 8, 9, 7, 0, 0]?
ahcheongL commented 1 year ago
  1. Yes
  2. No, a node can have zero value, an empty node will have garbage values (i.e. any values).
bltnynk commented 1 year ago
  1. Yes

So do we have to change the defined macro MAX from 16 to 8? ALso I think MAX is a constant, not a non-determinitic input value from the environment, right?

ahcheongL commented 1 year ago

We set MAX as 16 constant because of the overflow problem. If you try to access the left child of x[7], then you might access x[left(7)], which is x[14]. Please just let it be 16 constant, and think of it as an 8-length array.

bltnynk commented 1 year ago

We set MAX as 16 constant because of the overflow problem. If you try to access the left child of x[7], then you might access x[left(7)], which is x[14]. Please just let it be 16 constant, and think of it as an 8-length array.

But left child is already constrainted by (l<=h_size && x[l]>x[i]) so I think overflow would not happen?

ahcheongL commented 1 year ago

It depends on your verification code.