in , , , ,

Algorithm correctness

Algorithm correctness | code-memes, computer-memes, tech-memes, development-memes, engineer-memes, engineering-memes, testing-memes, test-memes, electron-memes, random-memes, git-memes, list-memes, algorithm-memes, forms-memes, error-memes, crypto-memes, IT-memes, ide-memes, cryptography-memes, cs-memes, runtime-memes, graph-memes | ProgrammerHumor.io
code-memes, computer-memes, tech-memes, development-memes, engineer-memes, engineering-memes, testing-memes, test-memes, electron-memes, random-memes, git-memes, list-memes, algorithm-memes, forms-memes, error-memes, crypto-memes, IT-memes, ide-memes, cryptography-memes, cs-memes, runtime-memes, graph-memes | ProgrammerHumor.io

Content

Of cour de vide COLOR Exercise 1.17 Most Lisp implementations include a primitive called runtime which returns an integer that specifies the amount of time the system has been running (measured. for example, in microseconds). The following timed-prime-test procedure, when called with an integer n, prints n and checks to see if n is prime. If n is prime, the procedure prints three asterisks followed by the number of microseconds used in performing the test. (define (timed-prime-test n) (define start-time (runtime)) (define found-prime? (prime? n)) 41 In testing primality of very large numbers chosen at random, the chance of stumbling upon a value that fools the Fermat test is less than the chance that cosmic radiation will cause the computer to make an error in carrying out a "correct" algorithm. Considering an algorithm to be inadequate for the first reason but not for the second illustrates the difference between mathematics and engineering. 42 One of the most striking applications of probabilistic prime testing has been to the field of cryptography. Although it is now computationally infeasible to factor an arbitrary 200-digit number, the primality of such a number can be checked in a few seconds with the Fermat test. This fact forms the basis of a technique for constructing "unbreakable codes" suggested by Rivest, Shamir, and Adelman (1977). Because of this and related developments, the study of prime numbers, once considered the epitome of a topic in "pure" mathematics to be studied only for its own sake, now turns out to have important practical applications to cryptography, electronic funds transfer, and information retrieval.