Algorithms

Spring 2011
course
navigation

Apr 12

homework

So : how was the C hash table stuff?
If issues with strmap C code, here's some help: hash table 2 . That folder has
Browse through the code a bit, discussing what it's doing compared with the python one we did last time. Similarities? Differences?
Using the wikipedia categories of hash tables, what kind is this one?
Note idiomatic C such as this in hash() : static unsigned long hash(const char *str){ unsigned long hash = 5381; int c; while (c = *str++) { hash = ((hash << 5) + hash) + c; } if (DEBUG) printf("hash: str=\"%s\", hash=%lu \n", str, hash); return hash; } Explain the meaning of *str++ : what is getting incremented? What is the order of operations here?

crypto and number theory

Resources
1. Discus basic ideas of symmetric vs public key encryption
2. Back up and talk about some algorithmic number theory, as a warm-up :
a) GCD (greatest common divisor)
b) lists of prime numbers

prime tests

The general idea (there are several variations) looks like this :
If p is prime, then a**(p-1) mod p = 1 . (Fermat's little theorem)
The key piece here is (a**n mod p). Do a few examples and discuss what's going on.
Can we turn this around? No. But *almost*.
If we pick a number B, and find that x < B have the above property, the probably B is prime. And the more x's that work, the more likely B is to be prime.
See wikipedia: Carmichael_number
More coming ...
http://cs.marlboro.edu/ courses/ spring2011/algorithms/ notes/ Apr_12
last modified Tuesday April 12 2011 3:17 am EDT