Randomized Algorithms: Methods and Techniques: Kuldeep Sharma Dr. Deepak Garg
Randomized Algorithms: Methods and Techniques: Kuldeep Sharma Dr. Deepak Garg
ABSTRACT
Randomized Algorithms are now gaining the attention of researchers. The reason is that some of the randomized algorithms have been successfully implemented in important applications reducing the time complexity and other computing resources. This paper reviews the different methods and techniques available in randomized algorithms. Paper also gives the gaps in the existing research and the future scope of research in this area.
might change between executions. A typical example is the well-known Quick sort method. Usually M onte Carlo methods reduce problems to the approximate calculation of mathematical expectations. Observe that any Las Vegas Algorithm can be converted into a M onte Carlo Algorithm, by having it output an arbitrary, possibly incorrect answer if it fails to complete within a specified time [1]. A randomized algorithm is one that receives, in addition to its input data, a stream of random bits that it can use for the purpose of making random choices. Even for a predetermined input, diverse runs of a randomized algorithm may give altered results; as a consequence it is inevitable that a description of the properties of a randomized algorithm will engage probabilistic statements. For example, even when the input is preset, the execution time of a randomized algorithm is a random variable. Behavior of randomized algorithm varies from one execution to another even with a fixed input. Random variable is a function. For case in point, we can talk formally about these dice is to define the random variable Y1 representing the result of the first die, Y2 representing the result of the second die, and Y = Y1 + Y2 representing the sum of the two. We could then ask: what is the probability that Y = 7? One property of a random variable we often care about is its expectation. Randomized algorithms are tool in computational number theory; have by now found widespread application. Growth has been fuelled by the two major benefits of randomization one is its simplicity another one is speed. Numerous applications found that randomized algorithm is the fastest algorithm available, or the simplest in most of cases it is both. In the analysis of a randomized algorithm which establish bounds on the expected value of a performance measure (e.g., the running time of the algorithm) that are valid for every input; the distribution of the performance measure is on the random choices made by the algorithm based on the random bits provided to it [2].
Keywords:
M onte Carlo.
1. INTRODUCTION
Everybody in the theory of computing community is well acquainted with the concept of randomization. It is not an exaggeration to say that randomization is currently one of the major approaches to algorithm design. A randomized algorithm is an algorithm which typically uses the random input in the hope of achieving good performance in the "average case". Formally, the algorithm's performance will be a random variable determined by the random inputs, with good expected value. The "worst case" is typically so unlikely to occur that it can be ignored. Consider the problem of finding a P in an array of n elements, given that half are Ps and the other half are Qs. The obvious approach is to look at each element of the array, but this would take very long (n/2 operations ) if the array were ordered as P first followed by Q. There is a similar drawback with checking in the reverse order, or checking every second element. In fact, with any strategy at all in which the order in which the elements will be checked is fixed, i.e. a deterministic algorithm, we cannot guarantee that the algorithm will complete quickly for all possible inputs. On the other hand, if we were to check array elements at random, then we will quickly find P with high probability, whatever is the input. In the example above, the randomized algorithm always outputs the correct answer, it is just that there is a small probability of taking long to execute. Sometimes we want an algorithm which always complete quickly, but allow a small probability of error. M onte Carlo methods are methods of approximation of the solution to problems of computational mathematics, by using random processes for each such problem, with the parameters of the process equal to the solution of the problem. The method can guarantee that the error of M onte Carlo approximation is smaller than a given value with a certain probability. So, M onte Carlo methods always produce an approximation of the solution, but one can control the accuracy of this solution in terms of the probability error. The Las Vegas method is a randomized method which also uses random variable or random processes, but it always produces the correct result (not an approximation). The only variant is that its running time
29
International Journal of Computer Applications (0975 8887) Volume 28 No.11, August 2011
Then, the (worst case) time complexity of A is TimeA(n)= max { TimeA(x) | x is an input of size n }. This definition may be misleading in some cases. This is because randomized algorithms may allow infinite runs provided that they occur with a reasonably small probability on any given input. Randomized algorithms are better than deterministic ones simple example is Quick Sort. Randomized Quick sort (RQS) Input: S = {a1. . . an} Step 1: Step 2: Choose an i {1 . . . n} uniformly at random if n = 1 output(S) S<:= {b S|b < ai} else S=:= {b S|b = ai} S>:= {b S|b > ai} Step 3: Output: Recursively sort S< and S > RQS(S<), S=, RQS(S>)
In simple algorithm the worst case complexity is O (n2) where in Randomized Algorithm its O (n log n) [3].
OF
Time and again a computational problem required a witness or a certificate that capably authenticate a hypothesis. Say, a number x has certain property i.e. x is prime; to justify this property it need proof (witness) but for many problems, the witness lies in a search space that is too large to be searched exhaustively. However, if the search space were to contain a relatively large number of witnesses, a randomly chosen element is likely to be a witness. Further, autonomous repetitions of the sampling reduce the probability that a witness is not found on any of the repetitions. The most prominent examples of this phenomenon occur in number theory. Indeed, the problem of testing a given integer for primality has no known deterministic polynomial-time algorithm. There are, however, several randomized polynomial-time algorithms [4] that will, on any input, correctly perform this test with high probability.
30
International Journal of Computer Applications (0975 8887) Volume 28 No.11, August 2011 This method is at the core of a number of algorithms used in statistical physics. Examples include algorithms for estimating the number of perfect matchings in a graph [12, 13]. The all-pair shortest paths problem can be solved in O (nm) time, as follows: from each vertex i , compute the breadth-first search tree Ti rooted at i. Each such tree can be computed in O (m) time and in any tree Ti the (unique) path from i to any vertex j is the shortest path between them. Given the collection of breadth-first search trees the distance matrix can be computed in O (n2) time by assigning level numbers to the vertices in each tree. The class of algorithms of Dijkstra, Floyd- Warshall and Johnson solve all-pair shortest paths in O (n3), where as in randomized its O (MM (n) log2n). [15].
6. REFERENCES
[1] Donald Knuth.1997 The Art of Computer Programming, Volume 3: Sorting and Searching, Third Edition. Addison-Wesley,. ISBN 0-201-89685-0. Pages 113122 of section 5.2.2: Sorting by Exchanging [2] Rajeev M otwani and Prabhakar Raghavan: 1996 Randomized Algorithms in ACM Computing Surveys Vol.28, No.1 Page no 33-37. [3] Hoare, C. A. R.1961 Partition: Algorithm 63, Quicksort: Algorithm 64, and Find: Algorithm 65. Comm. ACM 4(7), 321-322, [4] Fig 1. Distances to facilities serving clients [5] Solovay, R. and Strassen, V. 1977. A fast M onte-Carlo test for primality. SIAM J. Comput. 6, 84 85 & SIAM J. Comput. 7, 1 (Feb.), 1978, 118. Karp R.M., Rabin M .O., 1987, Efficient randomized pattern-matching algorithms. IBM J. Res. Dev. 31(2):249-260. Carter, Larry; Wegman, M ark N. 1979. Universal Classes of Hash Functions. Journal of Computer and System Sciences 18 (2): 143154. Freivalds, R. 1977. Probabilistic machines can use less running time. In Information Processing 77, Proceedings of IFIP Congress 77, Gilchrist, Ed., (Aug.), North-Holland, Amsterdam, 839842.
ALL
PAIR
[6]
Let G (V,E) be an undirected, connected graph with V={1..n} and |E|=m. The adjacency matrix A is n x n 0-1 matrix with Aij = A ji = 1 if and only if the edge (i,j) is present in E. Given A, we define the distance matrix D and n x n matrix with non-negative integer entries such that D ij equals the length of a shortest path from vertex i to vertex j. The diagonal entries in both A and D are zeroes. Since G is connected, all entries in D are finite; this is not a restrictive assumption since a graph can be decomposed easily into connected components in linear time. The all-pair shortest path problem is to compute a representation of the shortest paths between all pairs of vertices, i.e., the paths that determine the entries in the distance matrix.
[7]
[8] Yao,A.C-C.1977.Probabilistic computations Towards a unified measure of complexity. In Proceedings of the 17th Annual Symposium on Foundations of Computer Science, 222227.
31
International Journal of Computer Applications (0975 8887) Volume 28 No.11, August 2011 [9] R.W and Rivest 1975. Expected time bounds for selection. Commun. ACM 18, 165172. [13] Karp, R.M :1991 AN introduction to randomized algorithm, Discrete Applied M athematics 165-201. [14] Jaroslaw Byrka, Aravind Srinivasan, Chaitanya Swamy: 2010 Fault-Tolerant Facility Location: a randomized dependent LP-rounding algorithm CoRR abs/ 1003.1295 [15] Floyd, R.W and Rivest, R.L:1975. Expected time bounds for selection. Commun. ACM 18, 165172.
[10] Snir,M . 1985. Lower bounds on probabilistic linear decision trees. Theory of Computer Science. 38, 6982. [11] Sinclair, A. 1992. Algorithms for Random Generation and Counting: A M arkov Chain Approach. Progress in Theoretical Computer Science. Birkhauser, Boston. [12] Wai Ki Ching, M ichael K. Ng- 2006 M arkov Chains: M odels, algorithm and applications ISBN-10:0-38729335-3
32