|
C M S C 2 1 4 C o m p u t e r S c i e n c e I I S p r i n g 2 0 0 4 |
After looking at my own code and asking several students, we all
agree that there is nothing wrong with the way makeEmpty() is written. But
you need to set the root to NULL yourself. Then this function will work
fine in functions in which it is called.
Yes! You still need to add or subtract any points in the cell on
which the Robot is placed after the 1st board is played and she is placed
on the 2nd board.
print the words empty tree
No. Locate is the recursive function. Why can't you write a helper
function? Because in test situations, you aren't always permitted to write
a helper function. So practicing this in coding helps. Additionally, we
all need to be able to learn to write a recursive function without
helpers.
Yes, the comments in that function should be the same as in P2.
I have changed the comment. Please update your
Stalker.h file.
This is not a mistake. If you will notice, this only happens
when 7 nodes have been printed and there are no more nodes to print.
My print always does a carriage return after 7 nodes and after all
nodes have been printed. Sometimes this causes 2 carrage returns in a
row.
No! It should have been a void function but we will leave it as
is.
You need not implement anything below the line:
In done() in Board, Stalker's default constructor in Stalker, and
in Robot's constructor in Robot, I used a static variable that would allow
the first time through to handle the reading of the first file or the
printing of the first message, then I changed the static variable. So the
2nd time through, the second file or message is processed.
DO NOT USE A GLOBAL VARIABLE ANYWHERE IN YOUR CODE ON PENALTY OF
FLOGGING!
Your choice. We are always printing inorder so our answers will be
the same regardless of which way we put the duplicates in the tree. (FYI,
my duplicates go left.)
findParent() returns false if the child is root (in which case
parent is NULL) or if it hasn't found the target.
Incidentally, findParent() is only called on a node that is in the
tree so the false being returned indicates the child is the root.
You can set curr to NULL after you delete it each time and since
root is initially passed into makeEmpty(), it would get set to NULL.
This function is only meant to be called from the operator=(), the
copy constructor, and the destructor, so to be really safe, you can set
root to NULL after it is called and forget about setting curr to NULL in
the makeEmpty() function after each delete.
The reason srch() is different from search() is because in search()
I was searching until I found the item (in which case I stopped
searching). But in srch(), I am really only trying to find the node and
it's parent - a lot simplier code. I am counting upon the node being in
the BST so I am really only interested in finding it's parent. Both of
these function are initialized inside the code - child to root and parent
to NULL.
This is not one of the methods that you are required to implement.
Yes, it is correct but misleading. What I was trying to say is that
when the following code is executed
Project 3 primary.output had 8 nodes per line instead of 7. I have
corrected it. Please get the newest copy from the posting account.
Leave previous exception there - you do not have to write extras to
make up for those that are no longer needed. You need to write 3 exceptions that apply to the Bst class
If those old exceptions are causing compile errors, comment them
out but leave them in the .h and .cpp Except files.
In Board, in done().
It is left over from a previous implementation when I turned
the Stalker's moves into a BST. Just leave it there.
If we have 2 Mpairs:
I am going to let you figure that out.
Delete it from Bst.h. It was left over from a print function that
called inorder, but we will not use it. I have updated the posting
account.
Yes! Sorry I missed that one. It has been updated in the posting account
I gave you a choice in project 1. But in this project, let's
assume that your code will not allow the Robot to land on the Stalker.
It is better to end the game with the Robot having points and end the
game early than it is to end the game early with 0 points.
I have updated the project
description
On project 2, I told you to either throw an exception or end
the game. On this project, I believe we must make a decision. So you
should end the game if the BST has no moves the Robot can make.
An example is: if Robot is on [0,2] in a 3X3 board and the only
moves in the BST are E1, N1, NE2 and NW3, there are no moves. So end
the game (retaining the points accumulated so far.)
I have updated the project
description
If you are having problems with your code not recompiling correctly,
you need to clean between compiling each time. Some of you need to
clean everything (depending upon your makefile) and some can just
get rid of the target.o (for example main.o if you are compiling your
entire program or testBst.o if you are compiling testBst.cpp)
It takes a long time especially at or near 11PM on the day you must
submit. You have to take that into account when submitting. Not only does
your compiling take a long time, but submitting may take 10 minutes or
more (heavy use of the system - many people trying to submit at the same
time.)
If you are close to the deadline and you have successfully
submitted, and you want to change one little thing, you have to ask
yourself is it worth 15% (or more) of your grade if the submit takes
longer than you had anticipated?
Project #3 is due by 11pm on Wednesday, March 31st, 2004.
// ADD ANY PRIVATE MEMBER METHODS HERE
copy(curr,other);
delete(other);
"curr" will still exist and look exactly like "other" used to look.
a = [w,x]
b = [y,z]
then a is less than b if w is less than y; If w and y are equal then
we compare the second coordinates, x and z to see which is less than the
other.
|
See the class syllabus for policies concerning email Last Modified: March 8, 2004 |
|
|
|
|
|