University of Toronto - Fall 1996
Department of Computer Science

CSC 148H: INTRODUCTION TO COMPUTER SCIENCE



Old Announcements -- Week 12



Friday 29 November: Problems calling Subset?

Are you getting the error message: "Class subprograms cannot be subprogram variables"? Click here for some information to help you deal with it.

Friday 29 November: Overriding an operation

Here is a rule that you may not be aware of: If a child class is going to override a subprogram defined in one of its ancestor classes, that ancestor must export the subprogram. As part of your extensions to the class hierarchy, If you wish to override a subprogram that is not exported, you may change the export list.

Friday 29 November: Missing slides

Your lecture slide packages are missing six slides. They are available as a postscript file here. You should be able to read and print this at the cdf PC lab, or from your own computer if you have the right software. (If you don't, see my Week 7 posting, "Wednesday October 23: Problems viewing the diagram?")

Friday 29 November: Assignment 3 -- Important subtlety

Many of you are stumbling upon an important subtlety to do with when two objects are the same, what isMember should do, and what it means to have duplicates in an instance of the Set class. Please click here for an explanation.

Friday 29 November: Assignment 3 -- Yet more Q&A

Question: Globals.debug shows up in your original Set class (the one with the linked list implementation). Do we have to include it in our revised Set class?
Answer: No. You can just ignore everything to do with "debug". (But do you see how Globals.debug could be used to help with debugging?)

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.



Wednesday 27 November:Assignment 3 -- Object hierarchy for Hand-in question 1

For hand-in question 1, include every class defined in the program, even if it doesn't participate in an inheritance relationship. Treat Street as one object, although its code is split up into two files.

Wednesday 27 November:Assignment 3 -- More miscellaneous Q&A

Question: For Part 1, I was under the impression that we are only supposed to test our own subprograms (i.e. addElement, Union, Difference, etc.). However, in the sample driver program, it has testing for the subprograms that you provided (i.e. removeElement and Subset). What's up?
Answer: That's just to show you how to call them.

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.



Wednesday 27 November:OOT tidbit

If you run a program using the DOS version of OOT, the "Run with Args" menu lets you set output to go to both the screen and a file. This could be very handy during testing.

Wednesday 27 November:A2 out of 110?

Question: It was said that a total of 5 marks will be given a bonus, for those who use graphical output instead of text-based output. Then, shouldn't the total mark on Assignment 2 be 105 rather than 110?
Answer: After creating the draft marking scheme which appeared in the assnt 2 handout, I realized that no marks were allocated for testing. I added 10 for that, bringing the total to 110. In addition, a student could earn 5 more, but they are bonus marks. So the assignment is out of 110.

Wednesday 27 November:Assignment 3 -- Algorithm for AddElement

The comments on addElement say:
    % 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.



Wednesday 27 November:Assignment 3 -- Problems passing TrueFunction to Subset

Question: Inside my Union routine, I want to call
         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?
Answer: If you want to use the Globals module when testing your revised Set, you will have to make sure that it defines elementType in the same way. That is, if you've temporarily changed elementType in your Set class to be ^SimpleObject, you'll have to do the same in Globals. That means you'll also have to add SimpleObject to the import list of Globals.

Wednesday 27 November:Assignment 3 -- import Globals?

I temporarily commented out the bit of code that made Globals an import of the revised set class. You may reinstate it as an import -- and you probably will need to because your Union, for example, will want to use it in the same way that our original Union (in the linked list implementation) used it.

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.



Wednesday 27 November:Assignment 3 -- small things wrong with my code

You should change the given code to fix each of these small problems:

Wednesday 27 November: Email to Diane

About 40 email questions have piled up over the last couple of days. I am wading through them now, and expect to post a bunch of related messages here.

If I don't get to your question quickly enough, please come to an office hour.



Wednesday 27 November:Waiting for a remarked assignment?

I also have a backlog of assignments that have been remarked and are ready to return. I need to go through a make a record of what happened in each case, and then they will be returned in lecture or tutorial.

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.


Back to the csc148 home page