• No results found

4: Searching Through Phone Book (a Algorithm)

Several Subclasses in

Algorithm 4. 4: Searching Through Phone Book (a Algorithm)

However, there are a class of problems which can be solved by deterministic algorithms as well as by randomized algorithms, both in polynomial time; while the randomized algorithms can yield no error whatsoever, they are much quicker than their deterministic counterparts. We will provide an example for contrasting the time complexity in a moment.

4.4.2.1 An Example of "Zero-sided-error" Algorithms

Some randomized algorithms are so natural that we have been using them instead of their deterministic counterparts for a long history. For example, to weigh an object using a steelyard[d], the user should move around the counterbalance on the scaled arm in a

randomized way which will allow one to find the weight much quicker than to do the job in a deterministic way. One such algorithm we all are familiar with is a randomized process for looking up someone's phone number from a phone book. This algorithm is specified in Alg 4.4.

[d] The weighing instrument is called "Gancheng" in Chinese and has been used for more than two thousand

years.

Algorithm 4.4: Searching Through Phone Book (a

Algorithm)

INPUT Name: a person's name;

Book: a phone book;

OUTPUT The person's phone number.

Repeat the following until Book has one page {

(a) Open Book at a random page;

(b) If Name occurs before the page, Book Earlier_pages(Book); (c) Else Book Later_pages(Book);

}

1.

Return( Phone number beside Name);

2.

Clearly, the random operation in Alg 4.4 will not introduce any error to the output result. Therefore this is indeed a "zero-sided-error" randomized algorithm. For a phone book of N pages, Alg 4.4 will only need to execute O(log N) steps and find the page containing the name and the number. We should notice that a deterministic algorithm for "searching through phone book" will execute average O(N) steps.

• Table of Contents

Modern Cryptography: Theory and Practice By Wenbo Mao Hewlett-Packard Company

Publisher: Prentice Hall PTR Pub Date: July 25, 2003

ISBN: 0-13-066943-1 Pages: 648

Many cryptographic schemes and protocols, especially those based on public-keycryptography, have basic or so-called "textbook crypto" versions, as these versionsare usually the subjects for many textbooks on cryptography. This book takes adifferent approach to introducing

cryptography: it pays much more attention tofit-for-application aspects of cryptography. It explains why "textbook crypto" isonly good in an ideal world where data are random and bad guys behave nicely.It reveals the general unfitness of "textbook crypto" for the real world by demonstratingnumerous attacks on such schemes, protocols and systems under variousreal- world application scenarios. This book chooses to introduce a set of practicalcryptographic schemes, protocols and systems, many of them standards or de factoones, studies them closely, explains their working principles, discusses their practicalusages, and examines their strong (i.e., fit-for-application) security properties, oftenwith security evidence formally established. The book also includes self-containedtheoretical background material that is the foundation for modern cryptography.

The reason why Alg 4.4 works so fast is that names in a phone book have been sorted

alphabetically. We should notice that sorting is itself a problem: "quick-sort" (see, e.g., pages 92-97 of [9]) is a randomized sorting algorithm, can sort N elements in (N log N) steps, and its random operations will not introduce any error to the outcome result. In contrast, "bubble-sort" is a deterministic sorting algorithm; it sorts N elements in (N2) steps (see e.g., pages 77 of [9]).

We can say that is a subclass of languages which can be recognized by randomized algorithms in an "always fast and always correct" fashion.

4.4.3 Subclass "Always Fast and Probably Correct"

A subclass of which we name (Monte Carlo) (where " (Monte Carlo)" stands for "Monte Carlo" which is typically used as a generic term for "randomized") if the error probability bounds in (4.4.1) and (4.4.2) have the following characterization: for any L (Monte Carlo) there exists a randomized algorithm A such that for any instance I

and

here d is any constant in the interval (0, ). However, as we have pointed out in §4.4.1.2, since for one-sided-error algorithms we do not have to use the majority election criterion in the process of reducing a soundness error probability bound, d can actually be any constant in (0, 1).

Notice that now d 0; otherwise the subclass degenerates to the special case .

Randomized algorithms with this error-probability characterization have one-sided error in the soundness side. In other words, such an algorithm may make a mistake in terms of a false recognition of a non-instance. However, if an input is indeed an instance then it will always be recognized. This subclass of algorithms are called Monte Carlo algorithms.

From our study in §4.4.1 we know that the error probability of a Monte Carlo algorithm can be reduced to arbitrarily closing to 0 by independent iterating the algorithm and the iterated algorithm remains in polynomial time. We therefore say that a Monte Carlo algorithm is always fast and is probably correct.

We now show that PRIMES (the set of all prime numbers) is in the subclass (Monte Carlo).

4.4.3.1 An Example of Monte Carlo Algorithms

Since Fermat, it has been known that if p is a prime number and x is relatively prime to p, then xp – 1 1 (mod p). This forms a basis for the following Monte Carlo method for primality test ([282]), that is, picking x U (1, p – 1] with gcd(x, p) = 1 and checking

• Table of Contents

Modern Cryptography: Theory and Practice By Wenbo Mao Hewlett-Packard Company

Publisher: Prentice Hall PTR Pub Date: July 25, 2003

ISBN: 0-13-066943-1 Pages: 648

Many cryptographic schemes and protocols, especially those based on public-keycryptography, have basic or so-called "textbook crypto" versions, as these versionsare usually the subjects for many textbooks on cryptography. This book takes adifferent approach to introducing

cryptography: it pays much more attention tofit-for-application aspects of cryptography. It explains why "textbook crypto" isonly good in an ideal world where data are random and bad guys behave nicely.It reveals the general unfitness of "textbook crypto" for the real world by demonstratingnumerous attacks on such schemes, protocols and systems under variousreal- world application scenarios. This book chooses to introduce a set of practicalcryptographic schemes, protocols and systems, many of them standards or de factoones, studies them closely, explains their working principles, discusses their practicalusages, and examines their strong (i.e., fit-for-application) security properties, oftenwith security evidence formally established. The book also includes self-containedtheoretical background material that is the foundation for modern cryptography.

Equation 4.4.7

The test is repeated k = log2p times with the –1 case occurring at least once. Alg 4.5 specifies this test algorithm.

Related documents