Docsity

CS181 Assignment 1: Python Programming and Data Structures, Assignments of Computer Science

Toggle sidebar
bg1
CS181, Programming Languages
Assignment 1
For both problems send only the source files (.py) to [email protected].
Remember to include your name as a docstring, in the beginning of each file!
Problem one:
Make a program that works like the cat command in Unix. It should
take an arbitrary number of file names as command line arguments and print
their contents at the standard output stream, in sequence.
Problem two: Build a general probing Hashtable class. It should im-
plement the following methods:
•Object put(String key, Object value)
•Object get(String key)
•Object remove(String key)
•clear().
The key is always a string. As a hash function you may use the XOR of
all ASCII characters contained in the key. A simple way to implement the
hash table is as an array of lists. You may assume that the hash table has
a fixed size and returns an error message when full.
Problem three:
Make a simple telephone directory manipulation program. The program
should be able to read a directory from a file, make insertions and deletions,
search for a given name and write the updated information back to the file.
Make a menu for selecting the appropriate command. Assume that there
are not too many entries in the directory and thus the whole directory may
be loaded into memory.
1

Partial preview of the text

Download CS181 Assignment 1: Python Programming and Data Structures and more Assignments Computer Science in PDF only on Docsity!

CS181, Programming Languages

Assignment 1

For both problems send only the source files (.py) to [email protected]. Remember to include your name as a docstring, in the beginning of each file!

Problem one: Make a program that works like the cat command in Unix. It should take an arbitrary number of file names as command line arguments and print their contents at the standard output stream, in sequence.

Problem two: Build a general probing Hashtable class. It should im- plement the following methods:

  • Object put(String key, Object value)
  • Object get(String key)
  • Object remove(String key)
  • clear().

The key is always a string. As a hash function you may use the XOR of all ASCII characters contained in the key. A simple way to implement the hash table is as an array of lists. You may assume that the hash table has a fixed size and returns an error message when full.

Problem three: Make a simple telephone directory manipulation program. The program should be able to read a directory from a file, make insertions and deletions, search for a given name and write the updated information back to the file. Make a menu for selecting the appropriate command. Assume that there are not too many entries in the directory and thus the whole directory may be loaded into memory.