Question:
In part 3 of the assignment, we are asked to create an anxious
undergrad who is "just like other pedestrians, except that they move
faster."
Can we also change the colour so that they are immediately
recognizable?
Answer:
Sure.
Question:
When you implement your new pedestrian classes NiceVampires will suck blood
from them. I sort of wanted to make it so that NiceVamp's would only suck
blood from Vamp's and Nice Vamp's, is that ok?
Answer:
Yes, that's ok. Make sure that you do it in a "nice" way. I have seen
it done with bad style in at least one case.
Question:
I don't understand the union function.
If you wanted to produce the union of 2 sets I thought that you would need 2
parameters for the two sets.
In our case we have one otherset; what do we
union it with???
Answer:
You can't just call union out of the blue like this:
var unionSet : ^Set unionSet := Union (...)Instead, you need to already have an instance of the set class, and then call its own Union function.
var s: ^Set new s % Put some stuff into s here. var unionSet : ^Set unionSet := s -> Union (...)Notice the last line. You are telling s to go "union" itself, (just like you could tell it to go print itself, or go add an element to itself). So all we have to tell union is which other set to combine with s to create the union.
Question:
I have an algorithm for Union, and
it requires me to access the individual elements of the otherSet.
But I can't just say otherSet -> root (and then root -> left or right), since
root is not exported. Am I just missing something?
Answer:
You're right, you can't get at the root of otherSet.
The only way to get at the stuff insider otherSet is through its
exported routines. None of them gives you access to its root.
Look at the original Union code (in the linked list version of Set)
to see how we got around this.
Question:
Should all student's be removed from the street when they are on the sidewalk
right outside of their destination building?
Answer:
Yes.
Question:
Can we move one of the temporary subprgrams,
buildNode, to the beginning of the class so that addElement could use
it?
Answer:
If you want to permanently use my buildNode (or a modified version of it),
you can move it higher up.
Question:
For Part 3,
are the marks based on the correct use of
modifications and additional subprograms, or on the complexity of the new
class?
Answer:
Some of the marks will be for coming up with new classes that are
not just trivially different from existing ones.
I would consider
AnxiousUndergrad, for example, trivially different.
PiedPiper would be significantly different.
Question:
In the newest edition of set.tu, in the Subset function,
when recSubset is called,
the function f passed has no parameter. Is this right?
Answer:
Yes, it's right.
When you're calling Subset, you pass it just the name of a function,
you don't call the function.
Subset then calls that function itself many times: once for each of
its elements, to decide whether or not to include that element in the
subset that it's building.
Question:
In which order should the printSet procedure print the members of the set
(post, pre, or inorder?)
Answer:
In the abstract notion of a set, there is no order on the elements.
When we print them, we have to print them in some order, but it doesn't
matter which.
% 148 students: Suggested method -- randomly go left and right % down the tree until you hit a leaf. Add the new element there. % Over time, this method is likely to keep the tree reasonably % well balanced.This is badly described. If you take my advice literally, you will always end up with a degenerate tree -- no node will have two children.
Better advice would be: randomly go left and right down the tree until you hit a node with less than 2 children.
Subset (Globals.TrueFunction)to make a copy of a set, just like in the original Union (in the linked list implementation). But I get an error saying that the parameter is the wrong type. Why doesn't it work?
I commented out that import only because I wanted to put revised Set, the driver, and SimpleObject (and as little else as necessary) in a subdirectory for testing.
numElements := nto buildFromList.
If I don't get to your question quickly enough, please come to an office hour.
If you are anxious for yours, you can drop by at an office hour and I'll dig it out and deal with it on the spot.