- Tuesday 18 November: Tentative marking scheme
-
I forgot to post this earlier:
Part 1: Trace 5 marks
Part 2: Two add methods 10 marks
Part 3: Proof 20 marks
Part 4: Lexicon program 65 marks
- Tuesday 18 November: Behaviour of Lexicon
-
Question:
What should happen if we insert
ASSIGNMENT and check if ASSIGN is in the lexicon?
Answer:
If you have inserted ASSIGNMENT but not ASSIGN, then ASSIGN is not
considered to be "in" the lexicon.
Question:
What should happen when the given string is not a word ?
Answer:
It doesn't matter whether the string is really an English word or not.
The only thing that matters to the Lexicon is whether or not you've inserted
that exact string.
General advice:
Thinking of the lexicon as an ADT that consists of a set of strings
may help you to understand the intended behaviour of the methods.
- Tuesday 18 November: Problems reading from file? Mystery solved
-
Some of you have found that when you try the Read.java sample program
in VisualAge,
it never finds the file you ask it to open.
The problem is that your data file must be in the directory in which
the program was started -- and this is the VA main directory.
(If you give an absolute pathname for the file though, it can be anywhere.)
You can do one of three things to get around the problem:
- always give absolute pathnames when you name a file, or
- put your data files in the main VA directory, or
- use the revised code for file input, Read2.java, now available on
the assignments web page.
It uses a file dialog, which asks the user to select a file
using the mouse.
The first two options are a pain; you'll probably want to do the third.
Note that none of this is an issue if you're using the JDK.
- Friday 14 November: "deprecated"?
-
If you try to compile the Read.java code that I posted (showing
how you can read from a file),
Java may complain to you that it "uses a deprecated API".
This means that the code is old-fashioned: it uses classes and/or methods
that are no longer considered the most up-to-date way to do things
in the latest version of Java (1.1).
For the purposes of this assignment, you can ignore such a warning.
The code will still work.
- Thursday 06 November: Question 1 --
What should your trace look like?
-
The most important thing about your trace for question 1 is that you
must show every call that is made to recPrintCombos, including
the actual parameter values for that call.
For each call, you must also show which recursive calls it causes to happen.
A nice way to do this is to draw a box for every call. Put the
call and actual parameter values at the top of the box as a title.
Then inside the box, trace what goes on during that call. For each
recursive call that it makes, draw another box with an arrow to it.
You will thus form a tree of boxes, which may be named a "call tree".
Show
the rest of the details about what goes on during a call (how the loop
iterates and so on) as compactly as you can. They're less important
than the actual call tree itself.
- Thursday 06 November: Question 4 -- does case matter?
-
Your trie only has 26 slots per node,
so what should you do about upper vs lower case? Any reasonable decision
will do, as long as you explain what you've chosen.
Some options:
- Make it a precondition on your methods that everything
must be lower case.
- Accept lower and/or upper case, but convert everything to lower case.
- Thursday 06 November: How to read from a file in Java
-
Look under Assignment 2 on the "assignments" page to find an explanation
for how to read input from a file in Java.
- Monday 02 November: printCombos
-
Question:
Just to clarify: Are we to ignore the "printCombos" method when doing our
trace?
Answer:
Yes. Just trace the direct call to "recPrintCombos"
that I show in the handout.
I only told you about the "printCombos" to make a side point about
improving the interface to a recursive method.