Discussion:
Decoding w/o getLeftChild()
(too old to reply)
Steven Klein
2005-10-04 00:03:35 UTC
Permalink
My understanding of how we should be decoding is, start at the root, read a
bit, if it's a zero move to the left child, if it's a one move to the right
child, read the next bit, move etc. However, the template code does not
have a getLeftChild() function. I could just use (getRightChild() - 1) but
I assume this is not how we're expected to do it. Can someone give me a
quick outline of the proper way to decode.

Thanks,
Steven
Jamie Hargrove
2005-10-04 00:27:45 UTC
Permalink
User-Agent: OSXnews .10/b
Xref: number1.nntp.dca.giganews.com utexas.class.cs337:429

That's how I did it... isn't this a bit late to be asking? >.>
-Jamie
Post by Steven Klein
My understanding of how we should be decoding is, start at the root, read a
bit, if it's a zero move to the left child, if it's a one move to the right
child, read the next bit, move etc. However, the template code does not
have a getLeftChild() function. I could just use (getRightChild() - 1) but
I assume this is not how we're expected to do it. Can someone give me a
quick outline of the proper way to decode.
Thanks,
Steven
.
Zach
2005-10-04 00:28:42 UTC
Permalink
Copy/paste the getRightChild() code to make getLeftChild() but remove
the + 1.
Post by Steven Klein
My understanding of how we should be decoding is, start at the root, read a
bit, if it's a zero move to the left child, if it's a one move to the right
child, read the next bit, move etc. However, the template code does not
have a getLeftChild() function. I could just use (getRightChild() - 1) but
I assume this is not how we're expected to do it. Can someone give me a
quick outline of the proper way to decode.
Thanks,
Steven
Loading...