## Tutorial 11: Harvesting E-Mail Addresses and Other Evil Things (November 21-23, 2007)Today's tutorial is all about generative recursion. We'll work with strings, graphs, and numbers. The starter code is here. All the material is from lecture module 11. - Spam bots
- An email address looks like
`name@domain.suffix` , where each of`name` ,`domain` , and`suffix` consist only of letters and numbers. - The
`suffix` is never more than 3 characters long. - The characters surrounding the email address (that is, immediately preceding
`name` and following`suffix` ), if there are any, are not letters or numbers. - Viruses in a network
- Shortest path to a client
- Two paths diverged...
- When will it end?
;; bar: nat nat -> nat (define (bar m n) (cond [(zero? (* m n)) (+ m n)] [else (local [(define q (min m n (sqr (- m n))))] (bar (- m q) (- n q)))])) ;; f: nat -> nat (define (f n) (cond [(zero? n) 0] [(zero? (remainder n 2)) (f (quotient n 2))] [else (add1 (f (* 8 (sub1 n))))])) ;; g: nat nat nat -> nat (define (g m n i) (cond [(zero? (remainder i n)) i] [else (g m n (+ i m))])) ;; h: nat nat -> nat (define (h m n) (cond [(< m n) (h n m)] [(< (+ m n) 1000) (h (- m n) (sqr (add1 n)))] [else (* m n)]))
A spam bot is a computer program that crawls the internet looking for email addresses to add to a spam list. One crucial step is extracting (or 'harvesting') email addresses from some text with lots of other stuff in it (usually an html file). Note that most spam bots choose speed over thoroughness, because there are so many email addresses published freely that even a very stupid harvester can be quite effective. This is nice because it means that spam bots are usually easy to fool. Write a simple email harvester called To make this problem a bit shorter, you've been provided with two helper functions in the starter code. The function Directed acyclic graphs (DAGs) can be used as a very simplistic model for the flow of information in a network. Each node in the graph represents a single computer in the network, and each line represents a one-way communication connection. The following questions focus on what happens when a single computer in the network is infected with a virus. The code for the The most insecure computers in a network are almost always the client machines. These can be recognized by having no out neighbors. In graph theory, these kind of nodes are called 'sink nodes'. So a virus might be more likely to take hold if it is close to some client nodes. Write a function A virus will have a greater chance of spreading to a given node if there are multiple (different) paths from the source to the target node. We'll say two paths are distinct as long as they are not completely identical (so they can share some nodes). Write a function We have seen in class that, when dealing with generative recursion, sometimes it is very difficult to determine if the algorithm always terminates (in fact, this is a famous 'undecidable' problem --- Google 'undecidable', 'Alan Turing', or 'halting problem' for more). A program that never terminates can also very easily become a security risk in a computer. For the following programs, detemine whether they terminate on all valid imput. If so, give a brief justification or proof. If not, give an example input that will make the program run forever, and try to devise conditions on the input that will guarantee termination. |

This file generated Monday, December 17th, 2007 using PLT Scheme and WebIt!