CP164: Winter 2026 Midterm Notes

The following are comments on the midterm. Please review this material before bringing any questions about your midterm to the instructor. You should also try completing your solutions in Eclipse to see how well they works.

The array-based data structures are the easy part of the course. If you can't handle these, you're not going to do better in the last half of the course. At the very least, talk to us about your progress.

Kindly do not ask us "for just a few marks so I can pass the midterm". You don't have to pass the midterm to pass the course. We don't hand out free marks just to make a certain grade. If you did poorly on the midterm, you have an opportunity to improve for the exam, assuming you stay in the course. You must, however, pass the final exam to pass the course. No Exceptions.

If you passed the midterm remember that a bare pass is not going to get you into 2nd year. You need to demonstrate mastery of this material, and 55% isn't really doing that.

We do not provide the complete code for the answers. It is a very good idea for you to go through the midterm on your own and attempt to complete and test it thoroughly as good practice.

You should not have any syntax errors in your code - the testing code provided to you will show those immediately. Correct them before moving on.

If you are still struggling with project importing and exporting, get help. The project given you had the correct name and files. If your project was mis-named, you did something wrong during the import process. If your files were mis-named, you renamed them. Don't do that. If you got multiple projects in one project, you imported it wrong. If the validation gave you errors, you did something wrong during the export process. You have had a great deal of practice with exporting by now - there should be no reason to get this wrong. Attention to detail is key. Every term some students hand in the wrong project or the original empty midterm. This is a Bad Idea.

Lastly, if you handed in the empty midterm file we provided you, either by renaming it or submitting is as "BadMidtermZip.zip", a small reminder from the actual Midterm (and Practice Midterm) Instructions:

Follow these steps carefully in order to avoid problems such as handing in an empty midterm:

  1. From the above zip file, import your midterm project (named login_m_202601) into your Eclipse workspace by following the instructions on the Importing a Project tab on the tutorial page: Using Eclipse with PyDev Note that you are to select Existing Projects into Workspace and then Select archive file:. (There are diagrams and explanations in the tutorial.)
  2. Delete the file login_BadMidtermZip.zip. If this causes problems with your workspace, you imported the project in the zip file incorrectly. Re-download the file and try again. (Deleting this file avoids students submitting their original, empty, project as their midterm. This is a Bad Idea.)

If you pay attention to the Instructions there is no good reason this should happen. Validating your zip file will also catch a bad zipfile name.


General Comments

Follow basic CP104/CP164 rules:
  • get basic syntax correct - Eclipse often warns you when there is a problem, pay attention! Running the testing provided usually demonstrates these errors immediately.
  • only one return statement per function/method
  • do not use break
  • do not use continue or pass
  • do not use the Python list remove method
  • do not name your variables the same as the function/method name
  • use appropriate loops - not everything is amenable to being solved by a for loop
  • when extending a class do not call high-level interface methods from within another high-level interface method
  • use parameters, don't overwrite them
Read and apply method and function docstrings carefully:
Get the number and types of parameters correct, and the number and types of returned values correct.

The emphasis on this midterm was the basic concepts of array-based linear data structures and their use and extension.

Use the testing given to you. It is better to hand in a smaller amount of working code than a large amount of non-working code. We explicitly gave you testing code to save you time and effort. Make use of it. Read the comments at the very top of the testing that explains how to use it.

'Open book' does not mean 'easy', it simply gives you access to all of the material you have been working with during the term. The amount of time required to look through existing code, or Googling it on Stack Overflow, or generating it with ChatGPT is costly. Having practiced writing this code so that it immediately comes to mind is a much better, less time-wasting approach.

If you struggled with the CP104 aspect of the midterm - for example, basic programming structures, variable usage, fixing syntax errors - unless you improve your understanding and practice with this material immediately, you're not going to do well in the rest of the course. CP164 assumes you have mastered the CP104 material.

use vs extend

We emphasize often in this course the difference between using and extending a data structure. To remind you:

use
You must write a function that uses a data structure. This function is not part of the class definition and must be written in a separated module. You may access the data structure only through its public interface methods; insert, push, is_empty, len, etc. You may not access the data structure's underlying implementation, i.e. you may not refer to _values anywhere in the function.
extend
You are adding a method to a data structure's definition. This method must be written in the data structure module. You may not use the data structure's public interface methods; insert, push, is_empty, len, etc. You must work with the data structure's underlying implementation, i.e. all data references must refer to _values.

Note that on the midterm we provided you with smaller versions of the required data structures. In List_array.py for example, we gave you only the List constructor, the append method for creating a List, an iterator for testing a List, and the outlines for the methods you were tested on. We didn't provide you with any other methods because you don't need them to write the methods we asked you to write. This was a hint.

Further note that although we expect you to know the difference between use and extend, we explicitly stated in the Requirements for each Task statements such as:

Testing

Run the testing given. It very often gives you explicit feedback on things such as misspelled variable names or bad attribute or method names, or incorrect parameters for functions and methods. Don't make the mistake of trying to complete tasks without testing them.

Requirements

Pay very, very close attention to the Requirements. You are warned that if you do not meet the Requirements for a Task, your code may be given a zero for that Task. For example:

Requirements play an equally important role in the final exam.