CMPT 14x Fall2007 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 14 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 Fri 23 Nov

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 28 Nov

Write a Python program to calculate a knight's tour of an arbitrary-size board, given the dimensions of the board and the starting position.

References you may find useful (cite them in your lab write-up if you use them):

HW10: due Fri 30 Nov

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):
		self.data = data
		self.prev = prev
		self.next = next

Lab10: due 5 Dec

Complete one of Lab04-07 in Modula-2, with a full lab write-up. Some labs gave you a choice of problems; you need not choose the same problem, but you may. You may reuse parts of your old lab write-up if appropriate, although some refinements of your pseudocode may need to be revisited before you start your M2 code. You may wish to refer to the Stonybrook M2 tutorial and the M2 text.