Introduction to Computer Science
CompSci 101 : Spring 2014

Reasoning about Code

Think about the following problems and discuss what kind of sequence would most help represent the data. In Python, we have discussed a variety of kinds of sequences: strings, lists/tuples, sets, and dictionaries. For each of the following problems, state the type of sequence you feel best represents the data and explain your decision. Note, more than one sequence may make sense, so your justification is most important part of the exercise — how would you make use of your chosen sequence?

If you suggest a dictionary, clearly state what are the keys and values. If you suggest a sequence of sequences (e.g., a list of lists or set of tuples), clearly describe the type and purpose of the sub-sequences.

Student Registration

Consider the problem of building a registration program for a university that manages students wanting to register for courses, taking courses, and receiving grades for those courses. For these problems, you can either assume that student names are unique or that each student has a unique ID that can be used to easily lookup their name if needed (i.e., you do not need to come up with a complex solution to represent students uniquely, a simple string or number will do).

 

Spell Checking

Consider the problem of writing a spelling checker. In addition to the kind of sequence(s) you would use, give pseudocode to solve the problem using those sequences (you do not need to write actual Python code).