|
C M S C 2 1 4 C o m p u t e r S c i e n c e I I F a l l 2 0 0 3 |
You may NOT ASSUME that "halt" will always translate to 0935 and
"garble" will always translate to 5555. We will test your project 3 on a
different "codebook.txt" than you have been using. In other words, if you
HARDCODED these values, your project will fail our tests. The ONLY thing
you can hardcode is if you encounter a word that you can not translate
(it is not a plural or part of an expression) you may replace it in
checkcodebook() in Encoder with the word "garble". Then when you look up
"garble" in codebook.txt (your bst) it should always tranlate to the same
4-digit code (which is 5555 right now but will be changed for projects 3
and 4 tests.)
You should initialize "curr" or "child" to a COPY of the root and initialize
"parent" to NULL since the root has no parent. In ModBst, you only pass in
"curr" (a copy of the root) because each node already knows where its parent is
located.
No! The staff discussed this and determined that since there were no metro
shutdowns, no power outages, and no hurricanes, there is no extension.
Glad you asked. They are handled differently in each. Let's handle one at a time:
No! You can call locate() (which is recursive) to find where the
node and its parent are, then determine which case you have -deleting a
leaf, deleting a node with a right subtree, deleting a node with a left
subtree, or deleting a node with 2 subtrees. By the way, if you start out
with the node to be deleted has 2 subtrees, with right successor or left
predecessor, you then will end up deleting only a leaf or a node with one
subtree.
As long as either the function itself is recursive or it calls a
recursive function, you have satisfied the recursion.
The pointer that is passed in is the root of some tree or subtree.
The node passed in will point to the smallest node of that subtree after
calling findMin() or will point to the
largest node in that subtree after calling findMax(). Warning: yes it will change where root is pointing if
you pass root into it.
The same as in Codebook: each pair is on a separate line. plaintext
word followed by a single blank followed by 4-digit code followed by
endl.
The comment was changed (see faq immediately below this one) to say
that the function that calls this sets the root to NULL.
Use this version in Project 3 so that everything will match.
It is required that your version and our TNode.h match.
You are writing a modified Node, ModNode, and a modified Bst,
ModBst, so that we will be able to use it without having to do the extra
work in the next project. It will all become clear there. So for now,
please just trust that it is better to have this completed before project
4. I can clarify some things though. The manner in which we have to do
this without inheritance is rather tedious. For example, Encoder must be
changed just so it says #include ModBst.h" instead of "#include Bst.h".
Also, the search and locate functions now take only 2 arguments instead of
3 (as in Bst.h). main.cpp must have some #includes modified. So when you
put p3mod in your makefile, make copies of Encoder.* (called
ModEncoder.*) and main.cpp - call it Modmain.cpp. Then compile these
modified versions.
The example, hopefully, will clear up any questions about the extra
credit in Task 6. However, this should be the least of your
concerns right now. First get everything else running and test it
well. To spend time on an extra credit worth 5 points and end up
loosing 10 or 20 points on other parts that will get tested more
thoroughly does not make good sense.
Anyone who did not read the comments in Encoder above encode()
missed the explanation of "fixing halt".
Print the Bst Pairs in the same format as you printed the Codebook:
the word/expression, followed by a single blank, followed by the 4-digit
code.
Did you read the description in comments above encode() in
Encoder? "halt" no longer remains static (always 0935), rather it
changes by -7 each time it is encountered. If this were a real message,
seeing 0935 every 8 to 12 words would be a "dead give-away" to anyone
trying to "break" our code that 0935 is a separater
or demarcation of some sort.
Yes "curr" needs a reference there too, I changed ModBst.h in the posting account to reflect
this.
Thanks for noticing this. I left it out by mistake. I changed Bst.h in the posting account to reflect
this.
Whoops! I should have said that preorder() prints the preorder
traversal of the tree, inorder() prints the inorder traversal of the tree
and postorder() prints the postorder traversal of the tree.
Yes! I changed Bst.h and ModBst.h comments only.
Please download the newest versions so they will diff with
ours.
Then "curr" would be NULL and "parent" would be the parent of
the new node that will be inserted (that contains X). "curr" is the node
whose string you are comparing with X. Since you can only insert a leaf
node into a Bst, if X is not found then "curr" is NULL and "parent" is the
node that will connect up to the new node containing X that you have
created.
Any word you can't translate, after checking for expressions to the
right or left, and plurals, just replace the word in the message with
"garble". When garble is looked up in your Bst, it will translate to
5555.
Any word that someone can't handle should be treated as a garble.
However, the "complicated expression" test needs to be translated
correctly in order to get 5 extra points (Task 6). So anyone who handles
the expression as one containing garbles will not receive the extra
credit.
Project #3 is due by 11pm on Thursday, October 30th, 2003.
Note:
any project may be turned in late up to 2 days as specified on the
class syllabus.
For details regarding the late policy and any
penalties associated with submitting late projects please see the
class syllabus.
|
See the class syllabus for policies concerning email Last Modified: Tue Oct 14, 2003 |
|
|
|
|
|