
#
# 02w
#

################################################
# Q5 code.
################################################
class BinTreeNode:
    def __init__(self, d):
        self.data = d
		self.left = None
		self.right = None
		
def isHeap(root):
	'''Return True if the binary tree rooted at BinTreeNode root is a heap;
	False otherwise. Precondition: root != null.
	'''
	
	
################################################
# Q6 code.  A priority queue is a heap.  Write nose tests for it.
################################################
class WhizBangQueue(PriorityQueue):
	def isEmpty(self):
		'''Return True if I am empty; False otherwise'''
	
	def insert(self, item):
		'''Insert item in my elements, in the proper order.'''
	
	def deleteMin(self):
		'''Remove and return my smallest element. Raise a
		NoSuchElementException if I am empty.'''



#
# 03w
#

################################################
# Q4 code.
################################################

# Write a function checkDigits(str) that throws a WrongDigitException
# if a wrong digit is encountered in the parameter.

# Write class WrongDigitException.

# Write a function getInput() that uses function raw_input to read a string,
# and calls checkDigits on that input.  getInput() returns the input str if
# it is valid and otherwise returns "X is not a proper digit in base 8",
# where X is the first wrong digit found.


################################################
# Q5a.
################################################

# It's a neat though question, and all of them are good practice to write
# the code for.


#
# 03w afternoon midterm
#

################################################
# Q3 code.
################################################

# Use the fact that int(str) raises an exception if the str does not
# represent an integer.

def count_invalid_integers(f):
	'''Return the number of lines in open file f that don't represent an
	integer.'''
	count = 0
	
	# Your code goes here.
	
	return count
	

