Week 3

There is a lot of important stuff this week! Read: 6.1-6.6, 6.8 ex1 - structures Make a simple struct for a listNode that can be used to build a singlely-linked list. The data that it holds be a char*. Implement a linked list, by writing a series of linked list functions in one file. (e.g. addFirst, get, remove, size, etc.). The methods should all operate on pointers to your listNode struct. Write a main method that demonstrates that it works. Show that you can add strings to the list, remove them, get them, etc. ex2 - malloc, etc. (K&R 6.6 will be particularly helpful here) Make a hash table that stores strings (i.e. char* ) that uses chaining for collision resolution. The hash table should simply be an array of the listNode's you designed for ex1. Rembemer that a line like this: struct ListNode *hashtab[100] means: "make an array called 'hashtab' that has 100 slots for pointers to ListNode sturcts". K&R 6.6 gives you a hashing function you can use to hash your strings. Your hashtable does not need to resize dynamically. Again, write a main method that demonstrates your functions properly implement the basic hash table functions (insert, lookup, remove, etc.) Read: 7.1, 7.4-7.8 (esp. 7.8.5) ex3 - scanf Write a simple program that employs scanf to convert hex to int or int to hex. Here's a script of what I have in mind: %> convert itoh 255 255 = 0xFF %> convert htoi 9B 9B = 156 Don't over do this one. The point is to use scanf to read things in formatted in different ways. HINT: if you read all the command line args in as strings, you can use sscanf for a slightly more efficient code. sscanf does scanf on a supplied string rather than waiting for standard input. ex4 - Reading files (you really need ch. 7.5 and 7.7 to do this) "Chunk-ify" a text file, a la Catching Plagiarists. Write a function (or series of functions) that can read a plain text file (I'll give you some) and writes out a new file with all of the six-word chunks from the file, each chunk on it's own line. Really, your main method should accept an arbitrary number of file names as command-line arguments, and be able to chunkify each one. Let your output files have a consistent extension. For example, if you're asked to chunkify myfile.txt, then your chunkified version should be myfile.txt.chunk, or something like that. FILE: The U.S. Declaration of Independence: decl.txt
How to Submit