CMPT 14x Fall2006 HW/Lab Assignments

Most homework and lab assignments are taken from the M2 textbook. This page lists the assignments not from the M2 textbook.

Lab08: due 13/14/15 Nov

Write a library that provides robust user input:
For each basic Python data type (int, float, bool, str), provide a function that reads input from the keyboard and returns the value in the proper type. E.g., input_str(), input_bool(), etc.

HW09: due Wed 15Nov

Improving open():
Create a wrapper for the open() function. When a program opens a file successfully, a file handle will be returned. If the file open fails, rather than generating an error, return None to the callers so that they can open files without an exception handler.

HW10: due Mon 20Nov

Calculate a knight's tour for a 3x4 board, starting at the corner (0,0). In addition to the completed board, also show all your backtracking, using a tree diagram or a list of moves or whatever you see fit.

Lab09: due 20/21/22 Nov

Write a Python class Complex implementing the complex number abstract data type. Try to emulate the built-in complex type as closely as possible.

Lab10: due 27/28/29 Nov

Choose one of your previous Labs 02-07 and rewrite it in Modula-2, with a full lab write-up. You may reuse parts of your old lab writeup, although some refinements of your pseudocode may need to be revisited before you start doing your Modula-2 code. You may wish to refer to the Stonybrook M2 tutorial and the M2 text.

HW11: due Fri 1Dec

Given the following simple Python class definition for a doubly-linked (i.e., bidirectional) list, write a function delete(head, n) which takes a reference to the head of the list and a positive integer index (head is n=0) and returns a reference to the list with the nth entry deleted. If n is beyond the end of the list, return None. Make sure to handle the special case n=0 (deleting the head).
class Node:
	def __init__(self, data=None, prev=None, next=None): = data
		self.prev = prev = next