Abstract:
A database system includes an input to a database server configured to deliver a data stream formed of a sequence of elements, D={p 1 , p 2 , . . . , p m } of size m of numbers from {1, . . . , n} to the database server. The system further includes a computer program that causes a processor to approximate frequency moments (F k ) in the data stream, such that a frequency of an element (i) is defined as f i =|{j:p j =i}| and a k-th frequency moment of D is defined as 
     
       
         
           
             
               F 
               k 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   1 
                 
                 n 
               
                
               
                 
                   m 
                   i 
                   k 
                 
                  
                 
                     
                 
                  
                 in 
                  
                 
                     
                 
                  
                 a 
               
             
           
         
       
     
     single pass through the data stream. The processor is caused to carry out the steps of locating elements (i) with a frequency ΩF k  in the data stream as heavy elements and approximating f i  as ≧ a fraction of f i  to limit memory resources used by the processor to estimate F k  to O(n 1−2/k  log(n)) bits.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    The present invention relates generally to systems and methods for signal processing. More specifically, the present invention relates to a system and method for estimating frequency moments in data stream processing algorithms. 
         [0002]    In many signal processing application, the signal must be processed in a few or, often, just one pass. For example, a “data stream” is often referred to as a sequence of data that is too large to be stored, in its entirety, in memory. Such data streams are common in communications network traffic, database transactions, satellite data feeds, and the like. In such instances, “streaming algorithms” are used to process these signals as data streams forming an input presented as a sequence of items that can be examined in very few passes. A common example of a streaming algorithm is one developed to count the number of distinct elements in a data stream. The continuous nature of the underlying signal and the resource constraints that limit the amount of repetitive processing performed general result in the algorithm producing an approximate answer based on a summary of the data stream that is stored. 
         [0003]    Alon, Matias, and Szegedy, in  The Space Complexity of Approximating the Frequency Moments,  Journal of Computer and System Sciences, 58:137-147, 1999, which is incorporated herein by reference in its entirety, approached such a signal processing problem, within the context of database processing, and introduced the concept of “frequency moments.” Namely, for a sequence of elements, D={p 1 , p 2 , . . . , p m } of size m of numbers from {1, . . . , n}, a frequency of an element, I, is defined as: 
         [0000]        f   i   =|{j:p   j   =i}|   Eqn. 1.
 
         [0004]    The k-th frequency moment of D is defined as: 
         [0000]    
       
         
           
             
               
                 
                   
                     F 
                     k 
                   
                   = 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       
                         m 
                         i 
                         k 
                       
                       . 
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   2 
                 
               
             
           
         
       
     
         [0005]    Alon, Matias, and Szegedy, when approaching the problem of approximating frequency moments in one pass over D and using sublinear space, observed a striking difference between “small” and “large” values of k. Specifically, it is possible to approximate F k  for k≦2 in polylogarithmic space. However, polynomial space is required when k&gt;2. Since the work of Alon, Matias, and Szegedy in the late 1990&#39;s, approximating F k  has become one of the most inspiring problems in the theory of data streams. 
         [0006]    For example, many have focused on efficient algorithms for estimating particular moments, such as F 2 , which is useful for computing statistical properties of the data. Others have focused on bounding the memory required of F k  approximation algorithms. For example, many proposed solutions or bounds having accuracy up to a polylogarithmic factor. However, as noted above, since a polynomial space is required when k&gt;2, suitably efficient approximations for frequency moments for k≧3 have been lacking. 
         [0007]    It would therefore be desirable to provide a system and method for approximating frequency moments with a reduced space complexity than traditional dictated for k≧3. 
       SUMMARY OF THE INVENTION 
       [0008]    The present invention overcomes the aforementioned drawbacks by providing a method of non-uniform sampling to find frequency moments in a data stream. 
         [0009]    In accordance with one aspect of the invention, a database system includes a database and a database server configured to control reading data from and writing data to the database. The system also includes an input to the database server configured to deliver a data stream formed of a sequence of elements, D={p 1 , p 2 , . . . , p m } of size m of numbers from {1, . . . , n} to the database server. The system further includes a non-transitive, computer-readable storage medium, having stored thereon, a computer program that, when executed by a processor, causes the processor to approximate frequency moments (F k ) in the data stream, such that a frequency of an element (i) is defined as f i =|{j:p j =i}| and a k-th frequency moment of D is defined as 
         [0000]    
       
         
           
             
               F 
               k 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   1 
                 
                 n 
               
                
               
                 m 
                 i 
                 k 
               
             
           
         
       
     
         [0000]    in a single pass through the data stream. The processor is caused to carry out the steps of (a) arranging a portion of the data stream in a matrix, (b) selecting an initial element in the matrix, and (c) checking the matrix for a duplicate of the initial element. Upon identifying a duplicate of the initial element in the matrix, the processor is caused carry out the step of (d) assuming that the initial element appears in each row of the matrix, assigning binary values to all other frequencies, and disregarding the initial element. Upon completing step (c) without identifying a duplicate of the initial element, the processor is caused to carry out the step of (e) assigning a binary value to all frequencies. Steps (b) through (e) are repeated as step (f) for a each subsequent element in the matrix and step (g) is performed by generating a report of approximated frequency moments in the data stream 
         [0010]    In accordance with another aspect of the invention, a method for approximating frequency moments (F k ) in data streams formed of a sequence of elements, D={p 1 , p 2 , . . . , p m } of size m of numbers from {1, . . . , n} is disclosed, such that a frequency of an element (i) is defined as f i =|{j:p j =i}| and a k-th frequency moment of D is defined as 
         [0000]    
       
         
           
             
               F 
               k 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   1 
                 
                 n 
               
                
               
                 
                   m 
                   i 
                   k 
                 
                 . 
               
             
           
         
       
     
         [0000]    The method includes the steps of (a) arranging a portion of the data stream in a matrix, (b) selecting an initial element in the matrix, and (c) checking the matrix for a duplicate of the initial element. The method also includes (d) upon identifying a duplicate of the initial element in the matrix, assuming that the initial element appears in each row of the matrix, assigning binary values to all other frequencies, and disregarding the initial element. The method further includes, (e) upon completing step (c) without identifying a duplicate of the initial element, assigning a binary value to all frequencies. The method additionally includes (f) repeating steps (b) through (e) for each subsequent element in the matrix and (g) generating a report of approximated heavy elements. 
         [0011]    In accordance with another aspect of the present invention, a a database system is disclosed that includes a database and a database server configured to control reading data from and writing data to the database. The system also includes an input to the database server configured to deliver a data stream formed of a sequence of elements, D={p 1 , p 2 , . . . , p m } of size m of numbers from {1, . . . , n} to the database server. The system further includes a non-transitive, computer-readable storage medium, having stored thereon, a computer program that, when executed by a processor, causes the processor to approximate frequency moments (F k )) in the data stream, such that a frequency of an element (i) is defined as f i =|{j:p j =i}| and a k-th frequency moment of D is defined as 
         [0000]    
       
         
           
             
               F 
               k 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   1 
                 
                 n 
               
                
               
                 m 
                 i 
                 k 
               
             
           
         
       
     
         [0000]    in a single pass through the data stream. The processor is caused to carry out the steps of locating elements (i) with a frequency ΩF k  in the data stream as heavy elements and approximating f i  as ≧ a fraction of f i  to limit memory resources used by the processor to estimate F k  to O(n 1−2/k  log(n)) bits. 
         [0012]    The foregoing and other aspects and advantages of the invention will appear from the following description. In the description, reference is made to the accompanying drawings which form a part hereof, and in which there is shown by way of illustration a preferred embodiment of the invention. Such embodiment does not necessarily represent the full scope of the invention, however, and reference is made therefore to the claims and herein for interpreting the scope of the invention. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0013]      FIG. 1  is a block diagram of a system for use with the present invention. 
           [0014]      FIG. 2  is a flow chart setting forth the steps of an exemplary method in accordance with the present invention and for use with systems, such as illustrated in  FIG. 1 . 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0015]    1. Introduction. 
         [0016]    Referring to  FIG. 1 , a system for implementing an algorithm in accordance with the present invention is illustrated. As shown in  FIG. 1 , the system  10  includes a control program  12  and a memory  14  which, for example, may be resident in a database server  16  supporting database  18 . Every data item to be input to the database  18  input through a data input channel  20  where the data item is processed by the control program  12 . 
         [0017]    As will be described, when a command is received from a computer system  22  accessing the system  10  the over a control channel  24  to provide an estimate of a frequency moment, the control program  12  is invoked to generate an estimated frequency moment for output on output channel  26 . To this point, the present invention provides a system and method for approximating frequency moments in insertion-only data streams for k≧3. For any constant, c, the present invention can show an O(n 1−2/k  log(n)log (c) (n)) upper bound on the space complexity of the problem. Here log(c)(n) is the iterative log function. To simplify the presentation, the following assumptions can be made: 
         [0018]    n and m are polynomially far; and 
         [0019]    approximation error ε and parameter k are constants. 
         [0020]    A natural bijection between streams and special matrices can be observed. As described hereafter, the present invention provides a non-uniform sampling method referred to herein as “a pick-and-drop sampling.” 
         [0021]    To illustrate a pick-and-drop method in accordance with the present invention, an example can be utilized where m=r*t and r=[n 1/5 ]. In this context and referring to  FIG. 2 , the following example of a sampling method  200  in accordance with the present invention is described. At process block  202 , the data stream is arranged into a matrix. Arranging the data stream in the matrix may be achieved via a logical arrangement. By way of the present non-limiting example, consider r×t matrix, M, with entries m ij =p k(i−1)+j . For m≦n, the following promise problem can be solved with probability ⅔: 
         [0022]    case 1—all frequencies are either zero or one; 
         [0023]    case 2—z appears in every row of M exactly once and, thus, f z =r; and 
         [0024]    all other frequencies are either zero or one. 
         [0025]    At process block  204 , an element is selected for analysis. The element may be selected at random. Specifically, r independent and identically distributed (i.i.d.) random numbers I 1 , . . . , I r , can be picked, where I i  is uniformly distributed on {1,2, . . . , t}. At decision block  206 , for a given element (and, as will be described, each i=1 . . . r−1), a check for a duplicate of m i,I     i    in the row i+1 is made. If the duplicate is found, in this example, then we output “case 2” by assuming that z appears in every row of M exactly once. More generally, at process block  208 , the i-th sample is “dropped,” and, at process block  210 , another element is selected, for example, to “pick” the (i+1)-th sample. This process is repeated T times independently. 
         [0026]    Returning to decision block  206 , if no duplicate is found, at decision block  212 , a check is made to determine whether the end of the matrix has been reached. If not, another element is selected at process block  210 . Once the end of the matrix is reached, at process block  212 , a report is generated, for example, to report the “heavy elements.” Heavy elements are the element that appear often in the data stream. Frequency moments area a function of the data stream. As will be described, the present invention provides a system and method for determining a frequency moment using heavy elements, but the heavy element can be used for other and additional purposes. 
         [0027]    By way of the present example, “case 1” is output in the report if no duplicate is found. Note, if the input represents case 1, the method will always output “case 1.” Consider case 2 and observe that, if m i,I     i   =z, then case 2 will be output. Indeed, since z appears in every row, the duplicate of z will be found. The probability to miss z entirely is: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       ( 
                       
                         1 
                         - 
                         
                           1 
                           t 
                         
                       
                       ) 
                     
                     
                       r 
                        
                       
                           
                       
                        
                       T 
                     
                   
                   . 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   3 
                 
               
             
           
         
       
     
         [0028]    Recall that m≦n,m=rt,r=[n 1/k ]. If T=O(n 1−2/k ) with sufficiently large constant, then the probability of error with respect to eqn. 3 is smaller than ⅓. Accordingly, the promise problem can be resolved with O(n 1−2/k  log(n)) space. Notably, the solution depends upon r. Thus, in general, it is prudent to carefully select the matrix. 
         [0029]    Unfortunately, the distribution of the frequent element in the stream can be arbitrary. Also the algorithm should desirably recognize “noisy” frequencies that are large but negligible. Clearly, the sampling would be desirable if more intricate but, luckily, it need not be rendered greatly more complex. 
         [0030]    Accordingly, still referring to  FIG. 2 , counters can be used. Specifically, a local counter can be introduced for each sample that counts the number of times appears in the suffix of the i-th row. Notably, such a counting method was used by Alon, Matias, and Szegedy, in  The Space Complexity of Approximating the Frequency Moments,  for the entire stream. In contrast, in the present invention it is contemplated that a global sample (and a global counter), as functions of the local samples and counters, may be used. Initially, at process block  216  the global sample is the local sample of the first row and incremented at process block  218  only when the local counter indicates such. 
         [0031]    Notably, under certain conditions, the global sample can be “dropped.” If this is the case, then the local sample of the current row is “picked” and becomes the new global sample. The global sample is “dropped” when the local counter exceeds the global one. Also, the global sample is dropped if the global counter does not grow fast enough. A function, λq, where λ is a parameter and q is the number of rows that the global counter survived. If the global counter is smaller than λq, then the global sample is “dropped.” 
         [0032]    2. Pick-and-Drop Sampling 
         [0033]    Let M be a matrix with r rows and t columns and with entries m i,j  ε [n]. For i ε [r], j ε [t], l ε [n] define: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       d 
                       
                         i 
                         , 
                         j 
                       
                     
                     = 
                     
                        
                       
                         { 
                         
                           
                             
                               
                                 j 
                                 ′ 
                               
                                
                               
                                 : 
                               
                                
                               j 
                             
                             ≤ 
                             
                               j 
                               ′ 
                             
                             ≤ 
                             t 
                           
                           , 
                           
                             
                               m 
                               
                                 i 
                                 , 
                                 
                                   j 
                                   ′ 
                                 
                               
                             
                             = 
                             
                               m 
                               
                                 i 
                                 , 
                                 j 
                               
                             
                           
                         
                         } 
                       
                        
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   4 
                 
               
             
             
               
                 
                   
                     
                       f 
                       
                         l 
                         , 
                         i 
                       
                     
                     = 
                     
                        
                       
                         { 
                         
                           
                             j 
                             ∈ 
                             
                               
                                 { 
                                 t 
                                 } 
                               
                                
                               
                                 : 
                               
                                
                               
                                 m 
                                 
                                   i 
                                   , 
                                   j 
                                 
                               
                             
                           
                           = 
                           l 
                         
                         } 
                       
                        
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   5 
                 
               
             
             
               
                 
                   
                     
                       f 
                       l 
                     
                     = 
                     
                        
                       
                         { 
                         
                           
                             
                               ( 
                               
                                 i 
                                 , 
                                 j 
                               
                               ) 
                             
                              
                             
                               : 
                             
                              
                             
                               m 
                               
                                 i 
                                 , 
                                 j 
                               
                             
                           
                           = 
                           l 
                         
                         } 
                       
                        
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   6 
                 
               
             
             
               
                 
                   
                     
                       F 
                       k 
                     
                     = 
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           1 
                         
                         n 
                       
                        
                       
                         f 
                         l 
                         k 
                       
                     
                   
                   , 
                   
                     
                       G 
                       k 
                     
                     = 
                     
                       
                         F 
                         k 
                       
                       - 
                       
                         
                           f 
                           1 
                           k 
                         
                         . 
                       
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   7 
                 
               
             
           
         
       
     
         [0034]    Note that there is a bijection between r×t matrices M and streams D of size r×t with elements p it+j =m i,j , where the definitions with respect to eqns. 2, 1 and 6, 7, define equivalent frequency vectors for a matrix and the corresponding stream. Without loss of generality, consider streams of size r×t for some r,t. The notions of a stream and its corresponding matrix can be interchanged. 
         [0035]    Let {I j } j=1   r  be i.i.d. random variables with uniform distributions on [t]. Define for i=1, . . . , r: 
         [0000]      s i =m i,I     i   , c i =d i,I   i    Eqn. 8.
 
         [0036]    Let λ be a parameter. Define the following recurrent random variables: 
         [0000]      S 1 =s 1 , C 1 =c, q 1 =1   Eqn. 9.
 
         [0037]    Also (for i=2, . . . r), if: 
         [0000]      (C i 1 &lt;max{λq i 1 ,c i })   Eqn. 10;
 
         [0038]    then define: 
         [0000]      S i =s i , C i =c i , q i =1   Eqn. 11;
 
         [0039]    otherwise, define: 
         [0000]        S   i   =S   i−1   , C   i   =C   i−1   +f   S     i     ,i   , q   i   =q   i−1 +1   Eqn. 12.
 
         [0040]    Therefore, Theorem 2.1 states: If M is a r×t matrix, there exist absolute constants α,β such that, if: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       α 
                        
                       
                         ( 
                         
                           
                             λ 
                              
                             
                                 
                             
                              
                             r 
                           
                           + 
                           
                             
                               G 
                               3 
                             
                             
                               λ 
                                
                               
                                   
                               
                                
                               t 
                             
                           
                           + 
                           
                             
                               G 
                               2 
                             
                             t 
                           
                         
                         ) 
                       
                     
                     ≤ 
                     
                       f 
                       1 
                     
                     ≤ 
                     
                       β 
                        
                       
                           
                       
                        
                       t 
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   13 
                 
               
             
           
         
       
     
         [0041]    then: 
         [0000]    
       
         
           
             
               
                 
                   
                     P 
                      
                     
                       ( 
                       
                         
                           S 
                           r 
                         
                         = 
                         1 
                       
                       ) 
                     
                   
                   ≥ 
                   
                     
                       
                         f 
                         1 
                       
                       
                         2 
                          
                         
                             
                         
                          
                         t 
                       
                     
                     . 
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   14 
                 
               
             
           
         
       
     
         [0042]    Proof. Denote Q={(i, j):m i,j =1}. For (i, j) ε Q, define: 
         [0000]        T   i,j =  ( A   i,j   ∪B   i,j   ∪H   i,j )   Eqn. 15;
 
         [0043]    where for i&gt;1: 
         [0000]        A   i,j =(( C   i−1   ≧d   i,j )∩( S   i−1 ≠1))   Eqn. 16;
 
         [0044]    for i&lt;r: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       B 
                       
                         i 
                         , 
                         j 
                       
                     
                      
                     
                       ( 
                       
                         
                           
                             ⋃ 
                             r 
                           
                           
                             h 
                             = 
                             
                               i 
                               + 
                               1 
                             
                           
                         
                          
                         
                           ( 
                           
                             
                               
                                 d 
                                 
                                   i 
                                   , 
                                   j 
                                 
                               
                               + 
                               
                                 
                                   ∑ 
                                   
                                     u 
                                     = 
                                     
                                       i 
                                       + 
                                       1 
                                     
                                   
                                   
                                     h 
                                     - 
                                     1 
                                   
                                 
                                  
                                 
                                   f 
                                   
                                     1 
                                     , 
                                     u 
                                   
                                 
                               
                             
                             &lt; 
                             
                               c 
                               h 
                             
                           
                           ) 
                         
                       
                       ) 
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   17 
                 
               
             
             
               
                 
                   
                     
                       H 
                       
                         i 
                         , 
                         j 
                       
                     
                      
                     
                       ( 
                       
                         
                           
                             ⋃ 
                             
                               h 
                               = 
                               
                                 i 
                                 + 
                                 1 
                               
                             
                           
                           r 
                         
                          
                         
                           ( 
                           
                             
                               
                                 d 
                                 
                                   i 
                                   , 
                                   j 
                                 
                               
                               + 
                               
                                 
                                   ∑ 
                                   
                                     u 
                                     = 
                                     
                                       i 
                                       + 
                                       1 
                                     
                                   
                                   
                                     h 
                                     - 
                                     1 
                                   
                                 
                                  
                                 
                                   f 
                                   
                                     1 
                                     , 
                                     u 
                                   
                                 
                               
                             
                             &lt; 
                             
                               
                                 ( 
                                 
                                   h 
                                   - 
                                   1 
                                 
                                 ) 
                               
                                
                               λ 
                             
                           
                           ) 
                         
                       
                       ) 
                     
                   
                   ; 
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   18 
                 
               
             
           
         
       
     
         [0045]    and A i,j =B r,j =H r,j =0. We have: 
         [0000]      (( s   i =1)∩( S   i 1 )∩  A i,I     i       ⊂ (( s   i =1)∩( C   i 1   &gt;c   i ))  ⊂ (( S   i =1)∩( q   i =1))   Eqn. 19
 
         [0046]    Consider the case when S i =1 and q i =1 and 
         [0000]    
       
         
           
             
               
                 d 
                 
                   i 
                   , 
                   
                     I 
                     i 
                   
                 
               
               + 
               
                 
                   ∑ 
                   
                     u 
                     = 
                     
                       i 
                       + 
                       1 
                     
                   
                   
                     h 
                     - 
                     1 
                   
                 
                  
                 
                   f 
                   
                     1 
                     , 
                     u 
                   
                 
               
             
             ≥ 
             
               
                 max 
                  
                 
                   ( 
                   
                     
                       λ 
                        
                       
                         ( 
                         
                           h 
                           - 
                           i 
                         
                         ) 
                       
                     
                     , 
                     
                       c 
                       h 
                     
                   
                   ) 
                 
               
                
               
                   
               
                
               for 
                
               
                   
               
                
               all 
                
               
                   
               
                
               h 
             
             &gt; 
             
               i 
               . 
             
           
         
       
     
         [0000]    In this case S h  will be defined by eqn. 12 and not by eqn. 11. In particular, S h =S i =1. Therefore: 
         [0000]    
       
         
           
             
               
                 
                   ( 
                   
                     
                       
                         ( 
                         
                           
                             S 
                             i 
                           
                           = 
                           1 
                         
                         ) 
                       
                       ⋂ 
                       
                         ( 
                         
                           
                             q 
                             i 
                           
                           = 
                           1 
                         
                         ) 
                       
                       ⋂ 
                       
                         
                           B 
                           
                             i 
                             , 
                             
                               I 
                               i 
                             
                           
                         
                         _ 
                       
                       ⋂ 
                       
                         
                           H 
                           
                             i 
                             , 
                             
                               I 
                               i 
                             
                           
                         
                         _ 
                       
                     
                     ⊆ 
                     
                       
                         ( 
                         
                           
                             
                               ⋂ 
                               
                                 h 
                                 = 
                                 i 
                               
                             
                             r 
                           
                            
                           
                             ( 
                             
                               
                                 S 
                                 h 
                               
                               = 
                               1 
                             
                             ) 
                           
                         
                         ) 
                       
                       . 
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   20 
                 
               
             
           
         
       
     
         [0047]    Define V 1 =((s 1 =1)∩T i,I     1   ) and, for i&gt;1, V i =((s i =1)∩(S i−1 ≠1)∩T i,I     i   ) . It follows from eqns. 19 and 20 that, for any i ε [r]: 
         [0000]        V   i   ⊂ ( S   r =1)   Eqn. 21;
 
         [0000]      V i ∩V j =0   Eqn. 22.
 
         [0048]    Thus: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       r 
                     
                      
                     
                       P 
                        
                       
                         ( 
                         
                           
                             V 
                             i 
                           
                            
                           
                             
                               ⋃ 
                               
                                 i 
                                 = 
                                 1 
                               
                             
                             r 
                           
                            
                           
                             V 
                             i 
                           
                         
                         ) 
                       
                     
                   
                   ≤ 
                   
                     
                       P 
                        
                       
                         ( 
                         
                           
                             S 
                             r 
                           
                           = 
                           1 
                         
                         ) 
                       
                     
                     . 
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   23 
                 
               
             
           
         
       
     
         [0049]    For any i&gt;1, P(V i )≧P((s i =1)∩T i,I     i   )−P(s i =S i−1 =1). Also, 
         [0000]    
       
         
           
             ( 
             
               
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       2 
                     
                     r 
                   
                    
                   
                     
                       P 
                        
                       
                         ( 
                         
                           
                             s 
                             i 
                           
                           = 
                           
                             
                               S 
                               
                                 i 
                                 - 
                                 1 
                               
                             
                             = 
                             1 
                           
                         
                         ) 
                       
                     
                      
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           2 
                         
                         r 
                       
                        
                       
                         P 
                          
                         
                           ( 
                           
                             
                               ( 
                               
                                 
                                   s 
                                   i 
                                 
                                 = 
                                 I 
                               
                               ) 
                             
                             ⋂ 
                             
                               ( 
                               
                                 
                                   ⋃ 
                                   
                                     h 
                                     ≠ 
                                     i 
                                   
                                 
                                  
                                 
                                   ( 
                                   
                                     
                                       s 
                                       h 
                                     
                                     = 
                                     1 
                                   
                                   ) 
                                 
                               
                               ) 
                             
                           
                           ) 
                         
                       
                     
                   
                 
                 ≤ 
                 
                   
                     ( 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         r 
                       
                        
                       
                         P 
                          
                         
                           ( 
                           
                             
                               s 
                               i 
                             
                             = 
                             1 
                           
                           ) 
                         
                       
                     
                     ) 
                   
                   2 
                 
               
               = 
               
                 
                   
                     ( 
                     
                       
                         f 
                         1 
                       
                       t 
                     
                     ) 
                   
                   2 
                 
                 . 
               
             
           
         
       
     
         [0050]    For any fixed (i, j)εQ events I i =j and T i,j  are independent. Indeed, A i,j  is defined by {S i−1 , C i−1 } that, in turn, id defined by {I 1 , . . . , I i−1 }. Similarly, B i,j  is defined by {I i+1 , . . . , I r }. Note that H i,j  is a deterministic event. By definition, {I 1 , . . . , I i−1 , I i−1 , . . . , I r } are independent of I i . Thus, event I i =j and T i,j =  (A i,j ∪B i,j ∪H i,j )  are independent. Thus: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       
                         
                           
                             ∑ 
                             
                               i 
                               = 
                               2 
                             
                             r 
                           
                            
                           
                             P 
                              
                             
                               ( 
                               
                                 
                                   ( 
                                   
                                     
                                       s 
                                       i 
                                     
                                     = 
                                     1 
                                   
                                   ) 
                                 
                                 ⋂ 
                                 
                                   T 
                                   
                                     i 
                                     , 
                                     
                                       I 
                                       i 
                                     
                                   
                                 
                               
                               ) 
                             
                           
                         
                         = 
                           
                          
                         
                           
                             ∑ 
                             
                               
                                 ( 
                                 
                                   i 
                                   , 
                                   j 
                                 
                                 ) 
                               
                               ∈ 
                               Q 
                             
                           
                            
                           
                             P 
                             ( 
                             
                               
                                 ( 
                                 
                                   
                                     I 
                                     i 
                                   
                                   = 
                                   j 
                                 
                                 ) 
                               
                               ⋂ 
                               
                                 T 
                                 
                                   i 
                                   , 
                                   j 
                                 
                               
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                           
                          
                         
                           
                             ∑ 
                             
                               
                                 ( 
                                 
                                   i 
                                   , 
                                   j 
                                 
                                 ) 
                               
                               ∈ 
                               Q 
                             
                           
                            
                           
                             
                               P 
                                
                               
                                 ( 
                                 
                                   
                                     I 
                                     i 
                                   
                                   = 
                                   j 
                                 
                                 ) 
                               
                             
                              
                             
                               P 
                                
                               
                                 ( 
                                 
                                   T 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                 
                                 ) 
                               
                             
                           
                         
                       
                     
                   
                   
                     
                       
                         = 
                           
                          
                         
                           
                             1 
                             t 
                           
                            
                           
                             
                               ∑ 
                               
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                   ) 
                                 
                                 ∈ 
                                 Q 
                               
                             
                              
                             
                               
                                 P 
                                  
                                 
                                   ( 
                                   
                                     T 
                                     
                                       i 
                                       , 
                                       j 
                                     
                                   
                                   ) 
                                 
                               
                               . 
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   24 
                 
               
             
           
         
       
     
         [0051]    Thus, 
         [0000]    
       
         
           
             
               P 
                
               
                 ( 
                 
                   S 
                   = 
                   1 
                 
                 ) 
               
             
             ≥ 
             
               
                 
                   1 
                   t 
                 
                  
                 
                   
                     ∑ 
                     
                       
                         ( 
                         
                           i 
                           , 
                           j 
                         
                         ) 
                       
                       ∈ 
                       Q 
                     
                   
                    
                   
                     P 
                      
                     
                       ( 
                       
                         T 
                         
                           i 
                           , 
                           j 
                         
                       
                       ) 
                     
                   
                 
               
               - 
               
                 
                   
                     ( 
                     
                       
                         f 
                         1 
                       
                       t 
                     
                     ) 
                   
                   2 
                 
                 . 
               
             
           
         
       
     
         [0000]    As will be clear, Lemma 2.2 implies that Σ (i,j)εQ P(T i,j )≧0.8f 1 . Thus, if β&lt;0.3, then 
         [0000]    
       
         
           
             
               
                 P 
                  
                 
                   ( 
                   
                     
                       S 
                       r 
                     
                     = 
                     1 
                   
                   ) 
                 
               
                
               
                 
                   f 
                   1 
                 
                 t 
               
                
               
                 ( 
                 
                   0.8 
                   - 
                   
                     
                       f 
                       1 
                     
                     t 
                   
                 
                 ) 
               
             
             ≥ 
             
               
                 
                   f 
                   1 
                 
                 
                   2 
                    
                   t 
                 
               
               . 
             
           
         
       
     
         [0000]    Here, only the second part of eqn. 13 was used. The first part is used in the proof of Lemma 2.2. 
         [0052]    Lemma 2.2. There exists absolute constants α,β such that eqn. 13 implies 
         [0000]    
       
         
           
             
               
                 ∑ 
                 
                   
                     ( 
                     
                       i 
                       , 
                       j 
                     
                     ) 
                   
                   ∈ 
                   Q 
                 
               
                
               
                 P 
                  
                 
                   ( 
                   
                     T 
                     
                       i 
                       , 
                       j 
                     
                   
                   ) 
                 
               
             
             &gt; 
             
               0.8 
                
               
                   
               
                
               
                 
                   f 
                   1 
                 
                 . 
               
             
           
         
       
     
         [0053]    It follows from Lemmas 2.9, 2.17, and 2.14 and the union bound that there exists at lest 0.97f 1  pairs (i, j) εQ, such that P(A i,j ∪B i,j ∪H i,j )≦0.02. Recall that T i,j =  (A i,j ∪B i,j ∪H i,j ) . The lemma follows. 
         [0054]    Events of type A. 
         [0055]    For (i, j) ε Q  such that  i&gt;1 and for l&gt;1, define: 
         [0000]    
       
         
           
             
               
                 Y 
                 
                   l 
                   , 
                   
                     ( 
                     
                       i 
                       , 
                       j 
                     
                     ) 
                   
                 
               
               = 
               
                 
                   1 
                   
                     A 
                     
                       i 
                       , 
                       j 
                     
                   
                 
                  
                 
                   1 
                   
                     ( 
                     
                       
                         S 
                         
                           i 
                           - 
                           1 
                         
                       
                       = 
                       l 
                     
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 Y 
                 
                   l 
                   , 
                   i 
                 
               
               = 
               
                 
                   ∑ 
                   
                     
                       j 
                       ∈ 
                       
                         [ 
                         t 
                         ] 
                       
                     
                     , 
                     
                       
                         ( 
                         
                           i 
                           , 
                           j 
                         
                         ) 
                       
                       ∈ 
                       Q 
                     
                   
                 
                  
                 
                   Y 
                   
                     l 
                     , 
                     
                       ( 
                       
                         i 
                         , 
                         j 
                       
                       ) 
                     
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 Y 
                 l 
               
               = 
               
                 
                   ∑ 
                   
                     i 
                     = 
                     2 
                   
                   r 
                 
                  
                 
                   Y 
                   
                     l 
                     , 
                     i 
                   
                 
               
             
             , 
             
               
 
             
              
             
               Y 
               = 
               
                 
                   ∑ 
                   
                     l 
                     = 
                     2 
                   
                   n 
                 
                  
                 
                   Y 
                   l 
                 
               
             
             , 
           
         
       
     
         [0056]    Fact 2.3. C i ≦fs i ,i. Also, if q i =1, then C i ≦fs i ,i. 
         [0057]    Proof. It follows directly from eqns. 11 and 12 that it is sufficient to prove, for any i, there exists a set Q i , such that C i ≦|Q i | and, simultaneously, Q i  is a subset of {(i′,j):m i′,j =S i , i′≦i}. Through the induction on i, the above claim can be proven. For i=1, the claim is true since we can define Q 1 ={(1, j):j≧I 1 }. For i&gt;2, the description of the algorithm implies the following. If q i =1, then we can put Q i ={(i, j):j≧I i }. If q i &gt;1, then define Q i =Q i−1 ∩{(i, j):m i,j =S i }. Note that in this case, S i =S i−1 . The second part follows form the description of the algorithms. Namely, if p i =1, then C i =c i , S i =s i , and c i =d i,I     i   (s)≦f s     i     ,i . 
         [0058]    Fact 2.4. 
         [0059]    1. Y l,i ≦f l , 
         [0060]    2. If q i&#39;1 =1, then Y l,i ≦f l,i−1    
         [0061]    Proof. Let (i, j) ε Q be such that d i,j &gt;f l ; then Y l,(i,j) =1 (c     i−1     ≧d   i,j   ) 1 (s     i−1     =1)   =1(d     l     ≧c     i−1)   1 (c     i−1     ≧d     i,j)   1 (s     i−1     =1) . Use Fact 2.3 for this last equality. Thus, Y l,(i,j) =0. The definition of d i,j  implies |{j:(i,j)εQ,d i,j ≦f l f}|≦f l  for any fixed i and l. Thus, 
         [0000]    
       
         
           
             
               Y 
               
                 l 
                 , 
                 i 
               
             
             = 
             
               
                 
                   ∑ 
                   
                     
                       j 
                       ∈ 
                       
                         [ 
                         t 
                         ] 
                       
                     
                     , 
                     
                       
                         ( 
                         
                           i 
                           , 
                           j 
                         
                         ) 
                       
                       ∈ 
                       Q 
                     
                   
                 
                  
                 
                   Y 
                   
                     l 
                     , 
                     
                       ( 
                       
                         i 
                         , 
                         j 
                       
                       ) 
                     
                   
                 
               
               ≤ 
               
                 
                   f 
                   l 
                 
                 . 
               
             
           
         
       
     
         [0000]    Part 2 follows by repeating the above arguments and using the second statement of Fact 2.3. 
         [0062]    Definition 2.5. Let 1≦r 1 ≦r 2 ≦r and l ε [n]. Call a pair [r 1 ,r 2 ] an I-epoch if ∀i=r 1 , . . . , r 2 : S i =l and q r1 =q r2+1 =1, and ∀i=r+1 1 , . . . , r 2 :q i =q i−1 +1. 
         [0063]    Lemma 2.6. Let [r 1 ,r 2 ] be an I-epoch. If r 2 &gt;r 1 , then, 
         [0000]    
       
         
           
             
               
                 r 
                 2 
               
               - 
               
                 r 
                 1 
               
             
             ≤ 
             
               
                 1 
                 λ 
               
                
               
                 
                   ∑ 
                   
                     i 
                     = 
                     
                       r 
                       1 
                     
                   
                   
                     
                       r 
                       2 
                     
                     - 
                     1 
                   
                 
                  
                 
                   
                     f 
                     
                       l 
                       , 
                       i 
                     
                   
                   . 
                 
               
             
           
         
       
     
         [0064]    Proof. First, observe that q r     2     −1 =r 2 −r 1 . Second, q i &gt;1 implies that S i  is defined by eqn. 12 and not by eqn. 11 for all r 1 &lt;i≦r 2 . In particular, C r1 ≦f l,r     1    and for r 1 &lt;i≦r 2  we have C i =C i−1 +f l,i . Thus, 
         [0000]    
       
         
           
             
               C 
               
                 
                   r 
                   2 
                 
                 - 
                 1 
               
             
             ≤ 
             
               
                 ∑ 
                 
                   i 
                   = 
                   
                     r 
                     1 
                   
                 
                 
                   
                     r 
                     2 
                   
                   - 
                   1 
                 
               
                
               
                 
                   f 
                   
                     l 
                     , 
                     i 
                   
                 
                 . 
               
             
           
         
       
     
         [0000]    Third, C r     2     −1 ≧λq r     2     −1 , since eqn. 10 must be false for i=r 2 . Therefore, 
         [0000]    
       
         
           
             
               
                 r 
                 2 
               
               - 
               
                 r 
                 1 
               
             
             = 
             
               
                 
                   q 
                   
                     r 
                     2 
                   
                 
                 - 
                 1 
               
               ≤ 
               
                 
                   1 
                   λ 
                 
                  
                 
                   C 
                   
                     
                       r 
                       2 
                     
                     - 
                     1 
                   
                 
               
               ≤ 
               
                 
                   1 
                   λ 
                 
                  
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       
                         r 
                         1 
                       
                     
                     
                       
                         r 
                         2 
                       
                       - 
                       1 
                     
                   
                    
                   
                     
                       f 
                       
                         l 
                         , 
                         i 
                       
                     
                     . 
                   
                 
               
             
           
         
       
     
         [0065]    Lemma 2.7. 
         [0000]    
       
         
           
             
               Y 
               l 
             
             ≤ 
             
               
                 
                   f 
                   l 
                   2 
                 
                 λ 
               
               + 
               
                 
                   f 
                   l 
                 
                 . 
               
             
           
         
       
     
         [0066]    Proof. Observe that the set {i:S i =l} is a collection of disjoint I-epochs. Recall that and Y l Σ i=2   r  Y l,i  and Y l,i  is non-zero only if S i−1  is equal to l. Thus, Y l  can be rewritten as 
         [0000]    
       
         
           
             
               Y 
               l 
             
             = 
             
               
                 ∑ 
                 
                   
                     
                       ( 
                       
                         
                           r 
                           1 
                         
                         , 
                         
                           r 
                           2 
                         
                       
                       ) 
                     
                      
                     is_an 
                      
                     _l 
                   
                   - 
                   epoch 
                 
                 
                     
                 
               
                
               
                 
                   ( 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         
                           
                             r 
                             1 
                           
                           + 
                           1 
                         
                       
                       
                         
                           r 
                           2 
                         
                         + 
                         1 
                       
                     
                      
                     
                       Y 
                       
                         l 
                         , 
                         i 
                       
                     
                   
                   ) 
                 
                 . 
               
             
           
         
       
     
         [0000]    For any epoch such that r 2 &gt;r 1 , we have by Lemmas 2.4 and 2.6: 
         [0000]    
       
         
           
             
               Y 
               l 
             
             = 
             
               
                 
                   
                     ∑ 
                     
                       
                         
                           ( 
                           
                             
                               r 
                               1 
                             
                             &lt; 
                             
                               r 
                               2 
                             
                           
                           ) 
                         
                          
                         is_an 
                          
                         _l 
                       
                       - 
                       epoch 
                     
                     
                         
                     
                   
                    
                   
                     ( 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           
                             
                               r 
                               1 
                             
                             + 
                             1 
                           
                         
                         
                           
                             r 
                             2 
                           
                           + 
                           1 
                         
                       
                        
                       
                         Y 
                         
                           l 
                           , 
                           i 
                         
                       
                     
                     ) 
                   
                 
                 + 
                 
                   
                     ∑ 
                     
                       
                         
                           ( 
                           
                             
                               r 
                               1 
                             
                             = 
                             
                               r 
                               2 
                             
                           
                           ) 
                         
                          
                         is_an 
                          
                         _l 
                       
                       - 
                       epoch 
                     
                     
                         
                     
                   
                    
                   
                     Y 
                     
                       l 
                       , 
                       
                         
                           r 
                           2 
                         
                         + 
                         1 
                       
                     
                   
                 
               
               = 
               
                 
                   
                     
                       ∑ 
                       
                         
                           
                             ( 
                             
                               
                                 r 
                                 1 
                               
                               &lt; 
                               
                                 r 
                                 2 
                               
                             
                             ) 
                           
                            
                           is_an 
                            
                           _l 
                         
                         - 
                         epoch 
                       
                       
                           
                       
                     
                      
                     
                       ( 
                       
                         
                           ∑ 
                           
                             i 
                             = 
                             
                               
                                 r 
                                 1 
                               
                               + 
                               1 
                             
                           
                           
                             r 
                             2 
                           
                         
                          
                         
                           Y 
                           
                             l 
                             , 
                             i 
                           
                         
                       
                       ) 
                     
                   
                   + 
                   
                     
                       ∑ 
                       
                         
                           
                             ( 
                             
                               
                                 r 
                                 1 
                               
                               , 
                               
                                 r 
                                 2 
                               
                             
                             ) 
                           
                            
                           is_an 
                            
                           _l 
                         
                         - 
                         epoch 
                       
                       
                           
                       
                     
                      
                     
                       Y 
                       
                         l 
                         , 
                         
                           
                             r 
                             2 
                           
                           + 
                           1 
                         
                       
                     
                   
                 
                 ≤ 
                 
                   
                     
                       
                         f 
                         l 
                       
                       λ 
                     
                      
                     
                       
                         ∑ 
                         
                           
                             
                               ( 
                               
                                 
                                   r 
                                   1 
                                 
                                 &lt; 
                                 
                                   r 
                                   2 
                                 
                               
                               ) 
                             
                              
                             is_an 
                              
                             _l 
                           
                           - 
                           epoch 
                         
                         
                             
                         
                       
                        
                       
                         ( 
                         
                           
                             ∑ 
                             
                               i 
                               = 
                               
                                 r 
                                 1 
                               
                             
                             
                               
                                 r 
                                 2 
                               
                               - 
                               1 
                             
                           
                            
                           
                             f 
                             
                               l 
                               , 
                               i 
                             
                           
                         
                         ) 
                       
                     
                   
                   + 
                   
                     
                       ∑ 
                       
                         
                           
                             ( 
                             
                               
                                 r 
                                 1 
                               
                               , 
                               
                                 r 
                                 2 
                               
                             
                             ) 
                           
                            
                           is_an 
                            
                           _l 
                         
                         - 
                         epoch 
                       
                       
                           
                       
                     
                      
                     
                       f 
                       
                         l 
                         , 
                         
                           
                             r 
                             2 
                           
                           + 
                           1 
                         
                       
                     
                   
                 
                 ≤ 
                 
                   
                     
                       f 
                       l 
                       2 
                     
                     λ 
                   
                   + 
                   
                     
                       f 
                       l 
                     
                     . 
                   
                 
               
             
           
         
       
     
         [0067]    Lemma 2.8. 
         [0000]    
       
         
           
             
               P 
                
               
                 ( 
                 
                   
                     Y 
                     l 
                   
                   &gt; 
                   0 
                 
                 ) 
               
             
             ≤ 
             
               
                 
                   f 
                   l 
                 
                 t 
               
               . 
             
           
         
       
     
         [0068]    Proof. Since I i  are independent and 
         [0000]    
       
         
           
             0 
             ≤ 
             
               
                 f 
                 
                   l 
                   , 
                   i 
                 
               
               t 
             
             ≤ 
             1 
           
         
       
     
         [0000]    we can apply Fact 2.10 as 
         [0000]    
       
         
           
             
               P 
                
               
                 ( 
                 
                   
                     ⋂ 
                     
                       i 
                       = 
                       1 
                     
                     r 
                   
                    
                   
                     ( 
                     
                       
                         m 
                         
                           i 
                           , 
                           
                             I 
                             i 
                           
                         
                       
                       ≠ 
                       l 
                     
                     ) 
                   
                 
                 ) 
               
             
             = 
             
               
                 
                   ∏ 
                   
                     i 
                     = 
                     1 
                   
                   r 
                 
                  
                 
                     
                 
                  
                 
                   ( 
                   
                     1 
                     - 
                     
                       
                         f 
                         
                           l 
                           , 
                           i 
                         
                       
                       t 
                     
                   
                   ) 
                 
               
               ≥ 
               
                 
                   ( 
                   
                     1 
                     - 
                     
                       
                         f 
                         l 
                       
                       t 
                     
                   
                   ) 
                 
                 . 
               
             
           
         
       
     
       Thus: 
       [0069]    
       
         
           
             
               
                 
                   
                     
                       P 
                        
                       
                         ( 
                         
                           
                             Y 
                             l 
                           
                           &gt; 
                           0 
                         
                         ) 
                       
                     
                      
                     
                       P 
                        
                       
                         ( 
                         
                           
                             ⋃ 
                             
                               i 
                               = 
                               1 
                             
                             r 
                           
                            
                           
                             ( 
                             
                               
                                 m 
                                 
                                   i 
                                   , 
                                   
                                     I 
                                     i 
                                   
                                 
                               
                               = 
                               l 
                             
                             ) 
                           
                         
                         ) 
                       
                     
                   
                   ≤ 
                   
                     
                       
                         f 
                         l 
                       
                       t 
                     
                     . 
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   25 
                 
               
             
           
         
       
     
         [0070]    Lemma 2.9. There exists an absolute constant α such that eqn. 13 implies that P(A i,j )≦0.01 for at least 0.99 f 1  pairs (i,j) ε Q. 
         [0071]    Proof. From Lemmas 2.7 and 2.8, 
         [0000]    
       
         
           
             
               
                 E 
                  
                 
                   ( 
                   
                     Y 
                     l 
                   
                   ) 
                 
               
               ≤ 
               
                 
                   
                     f 
                     l 
                   
                   t 
                 
                  
                 
                   ( 
                   
                     
                       
                         f 
                         l 
                         2 
                       
                       λ 
                     
                     + 
                     
                       f 
                       l 
                     
                   
                   ) 
                 
               
             
             , 
             
               
 
             
              
             
               
                 E 
                  
                 
                   ( 
                   l 
                   ) 
                 
               
               = 
               
                 
                   
                     ∑ 
                     
                       l 
                       = 
                       2 
                     
                     n 
                   
                    
                   
                     E 
                      
                     
                       ( 
                       
                         Y 
                         l 
                       
                       ) 
                     
                   
                 
                 ≤ 
                 
                   
                     
                       G 
                       3 
                     
                     
                       λ 
                        
                       
                           
                       
                        
                       t 
                     
                   
                   + 
                   
                     
                       
                         G 
                         2 
                       
                       t 
                     
                     . 
                   
                 
               
             
           
         
       
     
         [0000]    It follows that Σ (i,j)⊂Q 1 A   i,j −Y. Recall that by eqn. 13, 
         [0000]    
       
         
           
             
                
               Q 
                
             
             = 
             
               
                 f 
                 1 
               
               ≥ 
               
                 α 
                  
                 
                   ( 
                   
                     
                       
                         G 
                         3 
                       
                       
                         λ 
                          
                         
                             
                         
                          
                         t 
                       
                     
                     + 
                     
                       
                         G 
                         2 
                       
                       t 
                     
                   
                   ) 
                 
               
               ≥ 
               
                 α 
                  
                 
                     
                 
                  
                 
                   
                     E 
                     ( 
                     
                       
                         ∑ 
                         
                           
                             ( 
                             
                               i 
                               , 
                               j 
                             
                             ) 
                           
                           ∈ 
                           Q 
                         
                         
                             
                         
                       
                        
                       
                         1 
                         
                           Ai 
                           , 
                           j 
                         
                       
                     
                     ) 
                   
                   . 
                 
               
             
           
         
       
     
         [0000]    Fact 2.11 implies that there exists an absolute constant α such that the lemma is true. 
         [0072]    The following fact is well known. For completeness, the proof is presented below. 
         [0073]    Fact 2.10. Let α 1 , . . . , α r  be real numbers in [0,1]. Then, 
         [0000]    
       
         
           
             
               
                 ∏ 
                 
                   i 
                   = 
                   
                     
                       1 
                        
                       i 
                     
                     = 
                     1 
                   
                 
                 r 
               
                
               
                   
               
                
               
                 ( 
                 
                   1 
                   - 
                   
                     α 
                     i 
                   
                 
                 ) 
               
             
             ≥ 
             
               1 
               - 
               
                 
                   ( 
                   
                     
                       ∑ 
                       r 
                     
                      
                     
                       α 
                       i 
                     
                   
                   ) 
                 
                 . 
               
             
           
         
       
     
         [0074]    Proof. If Σ i=1   r α l ≧1, then 
         [0000]    
       
         
           
             
               
                 ∏ 
                 
                   i 
                   = 
                   
                     
                       1 
                        
                       i 
                     
                     = 
                     1 
                   
                 
                 r 
               
                
               
                   
               
                
               
                 ( 
                 
                   1 
                   - 
                   
                     α 
                     i 
                   
                 
                 ) 
               
             
             ≥ 
             0 
             ≥ 
             
               1 
               - 
               
                 
                   ( 
                   
                     
                       ∑ 
                       r 
                     
                      
                     
                       α 
                       i 
                     
                   
                   ) 
                 
                 . 
               
             
           
         
       
     
         [0075]    Thus, we can assume that Σ i=1   r α i &lt;1. This claim can be proven by induction on r. For r=2, we obtain (1−α 1 )(1−α 2 )=(1−α 1 −α 2 x+α 1 α 2 )≧(1−α 1 −α 2 ). For r&gt;2, we have, by induction, 
         [0000]    
       
         
           
             
               
                 ∏ 
                 
                   i 
                   = 
                   1 
                 
                 r 
               
                
               
                   
               
                
               
                 ( 
                 
                   1 
                   - 
                   
                     α 
                     i 
                   
                 
                 ) 
               
             
             ≥ 
             
               
                 ( 
                 
                   1 
                   - 
                   
                     ( 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         
                           r 
                           - 
                           1 
                         
                       
                        
                       
                         α 
                         i 
                       
                     
                     ) 
                   
                 
                 ) 
               
                
               
                 ( 
                 
                   1 
                   - 
                   
                     α 
                     r 
                   
                 
                 ) 
               
             
             ≥ 
             
               1 
               - 
               
                 
                   ( 
                   
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                       
                       r 
                     
                      
                     
                       α 
                       i 
                     
                   
                   ) 
                 
                 . 
               
             
           
         
       
     
         [0076]    Fact 2.11. Let X 1 , . . . , X u  be a sequence of indicator random variables. Let S={i:P(X l =1)≦v}. If E(Σ i=1   u X i )≦μu then 
         [0000]    
       
         
           
             
                
               S 
                
             
             ≥ 
             
               
                 ( 
                 
                   1 
                   - 
                   
                     μ 
                     v 
                   
                 
                 ) 
               
                
               
                 u 
                 . 
               
             
           
         
       
     
         [0077]    Proof. Indeed, 
         [0000]    
       
         
           
             
               μ 
                
               
                   
               
                
               u 
             
             ≥ 
             
               
                 ∑ 
                 
                   i 
                   ∉ 
                   S 
                 
                 
                     
                 
               
                
               
                 P 
                  
                 
                   ( 
                   
                     
                       X 
                       i 
                     
                     = 
                     1 
                   
                   ) 
                 
               
             
             ≥ 
             
               
                 v 
                  
                 
                   ( 
                   
                     u 
                     - 
                     
                        
                       S 
                        
                     
                   
                   ) 
                 
               
               . 
             
           
         
       
     
         [0078]    Events of type B. 
         [0079]    For (i, j)ε Q let Z (i,j) =1 B     i,j   . Let Z=Σ (i,j)εQ Z (i,j) . We use arguments that are similar to the ones from the previous section. To stress the similarity, we abuse the notation and denotation by Y l,j(i,j)  the indicator of the event that h&gt;i+1,s h =l and 
         [0000]    
       
         
           
             
               ( 
               
                 
                   d 
                   
                     i 
                     , 
                     j 
                   
                 
                 + 
                 
                   
                     ∑ 
                     
                       u 
                       = 
                       
                         i 
                         + 
                         1 
                       
                     
                     
                       h 
                       - 
                       1 
                     
                   
                    
                   
                     f 
                     
                       1 
                       , 
                       u 
                     
                   
                 
               
               ) 
             
             &lt; 
             
               
                 c 
                 h 
               
               . 
             
           
         
       
     
         [0080]    Define Y l,j =Σ (i,j)εQ Y l,h,(i,j) , Y l =Σ h=1   r Y l,h . 
         [0081]    Fact 2.12. Y l ≦f l . 
         [0082]    Proof. Repeating the arguments from Fact 2.4, we have c h 1 s     h     =1 ≦f l,h  and thus Y l,h ≦f l,h . 
         [0083]    Fact 2.13. 
         [0000]    
       
         
           
             
               P 
                
               
                 ( 
                 
                   
                     Y 
                     l 
                   
                   &gt; 
                   0 
                 
                 ) 
               
             
             ≤ 
             
               
                 
                   f 
                   l 
                 
                 t 
               
               . 
             
           
         
       
     
         [0084]    Proof. The proof is identical to the proof of Lemma 2.8. 
         [0085]    Lemma 2.14. There exists absolute constants α,β such that eqn. 13 implies that P(B i,j )≦0.01 for at least 0.99 f 1  pairs (i, j)ε Q. 
         [0086]    Proof. Denote Y=Σ i=1   n  Y l . It follows that Z≦Y and E(Z)≦E(Y). By Facts 2.13 and 2.12, it follows that 
         [0000]    
       
         
           
             
               E 
                
               
                 ( 
                 
                   Y 
                   l 
                 
                 ) 
               
             
             ≤ 
             
               
                 
                   f 
                   l 
                   2 
                 
                 t 
               
               . 
             
           
         
       
     
       Thus, by eqn. 13, 
       [0087]    
       
         
           
             
               
                 E 
                  
                 
                   ( 
                   Z 
                   ) 
                 
               
               ≤ 
               
                 E 
                  
                 
                   ( 
                   Y 
                   ) 
                 
               
               ≤ 
               
                 
                   F 
                   2 
                 
                 t 
               
             
             = 
             
               
                 
                   
                     G 
                     2 
                   
                   t 
                 
                 + 
                 
                   
                     f 
                     1 
                   
                    
                   
                     
                       f 
                       1 
                     
                     t 
                   
                 
               
               ≤ 
               
                 
                   ( 
                   
                     α 
                     + 
                     β 
                   
                   ) 
                 
                  
                 
                   
                     f 
                     1 
                   
                   . 
                 
               
             
           
         
       
     
         [0088]    We repeat the arguments from Lemma 2.9. 
         [0089]    Events of type H 
         [0090]    Definition 2.15. 
         [0091]    Let U={u l , . . . , u t } and W={w l , . . . , w t } be two sequences of non-negative integers. Let (i,j) be a pair such that 1≦i≦t and 1≦j≦u i . Denote (i,j) as a loosing pair (with respect to sequences U,W) if there exists h,i≦h≦t such that 
         [0000]    
       
         
           
             
               
                 - 
                 j 
               
               + 
               
                 
                   ∑ 
                   
                     s 
                     = 
                     i 
                   
                   h 
                 
                  
                 
                   ( 
                   
                     
                       u 
                       s 
                     
                     - 
                     
                       w 
                       s 
                     
                   
                   ) 
                 
               
             
             &lt; 
             0. 
           
         
       
     
         [0000]    Denote any pair that is not a loosing pair as a winning pair. 
         [0092]    Now, we consider the following pair (U,W) then H i,j′  does not occur where j′ is such that m i,j′=1  and d i,j′ =f l,i −j+1. 
         [0093]    Proof. By Definition 2.15, for every i≦h≦r: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       - 
                       j 
                     
                     + 
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           i 
                         
                         h 
                       
                        
                       
                         u 
                         l 
                       
                     
                   
                   ≥ 
                   
                     
                       ∑ 
                       
                         l 
                         = 
                         i 
                       
                       h 
                     
                      
                     
                       
                         w 
                         l 
                       
                       . 
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   26 
                 
               
             
           
         
       
     
         [0094]    Since Σ l=i   h w i =(h−i+1)λ and d i,j′ =f l,i −j+1, for every i≦h≦t, 
         [0000]    
       
         
           
             
               
                 d 
                 
                   i 
                   , 
                   
                     j 
                     ′ 
                   
                 
               
               + 
               
                 
                   ∑ 
                   
                     l 
                     = 
                     
                       i 
                       + 
                       1 
                     
                   
                   h 
                 
                  
                 
                   d 
                   
                     l 
                     , 
                     1 
                   
                 
               
             
             = 
             
               
                 
                   - 
                   j 
                 
                 + 
                 1 
                 + 
                 
                   
                     ∑ 
                     
                       l 
                       = 
                       
                         i 
                         + 
                         1 
                       
                     
                     h 
                   
                    
                   
                     f 
                     
                       l 
                       , 
                       1 
                     
                   
                 
               
               = 
               
                 
                   
                     
                       - 
                       j 
                     
                     + 
                     1 
                     + 
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           i 
                         
                         h 
                       
                        
                       
                         u 
                         l 
                       
                     
                   
                   ≥ 
                   
                     
                       - 
                       j 
                     
                     + 
                     
                       
                         ∑ 
                         
                           l 
                           = 
                           i 
                         
                         h 
                       
                        
                       
                         u 
                         l 
                       
                     
                   
                   ≥ 
                   
                     
                       ∑ 
                       
                         l 
                         = 
                         i 
                       
                       h 
                     
                      
                     
                       w 
                       l 
                     
                   
                 
                 = 
                 
                   
                     ( 
                     
                       h 
                       - 
                       i 
                       + 
                       1 
                     
                     ) 
                   
                    
                   λ 
                 
               
             
           
         
       
     
         [0095]    Substitute h by h−1 (for h&gt;i), such that 
         [0000]    
       
         
           
             
               
                 d 
                 
                   i 
                   , 
                   
                     j 
                     ′ 
                   
                 
               
               + 
               
                 
                   ∑ 
                   
                     l 
                     = 
                     
                       i 
                       + 
                       1 
                     
                   
                   h 
                 
                  
                 
                   d 
                   
                     l 
                     , 
                     1 
                   
                 
               
             
             ≥ 
             
               
                 ( 
                 
                   h 
                   - 
                   i 
                 
                 ) 
               
                
               
                 λ 
                 . 
               
             
           
         
       
     
         [0000]    Thus, H i,j′  does not occur, by eqn. 18. 
         [0096]    Lemma 2.17. There exists an absolute constant α, such that eqn. 13 implies that H i,j  does not occur for at least 0.99 f 1  pairs (i, j) ε W. 
         [0097]    Proof. By Lemma 2.20, there exists at least 
         [0000]    
       
         
           
             
               ∑ 
               
                 i 
                 = 
                 1 
               
               r 
             
              
             
               ( 
               
                 
                   u 
                   i 
                 
                 - 
                 
                   w 
                   i 
                 
               
               ) 
             
           
         
       
     
         [0000]    winning pairs (i,j) with respect to the (U,W). Also, Σ i=1   r u i =Σ i=1   r f l,i =f 1  and Σ l=1   r uw=λr. Thus, there exist at least f 1 −λr winning pairs (i, j) with respect to the (U,W). In the statement of Fact 2.16, the mapping from j to j′ is bijection. Thus, there exist at exist f 1 −λr winning pairs (i,j′) such that m i,j′ =1 and H i,j′  does not occur. By eqn. 13, we have f 1 ≧αλr and the lemma follows. 
         [0098]    Definition 2.18. Let U={u 1 , . . . , u t } and W={w l , . . . , w t } be two sequences of non-negative integers. Let 1≦h&lt;t. Let U′,W′ be two sequences of size t−h defined by p′ i =u i+h ,q′ i =w i+h  for i=1, . . . , t−h. Denote U′,W′ as h-tail of the sequences U,W. 
         [0099]    Fact 2.19. If (i, j) is a winning pair with respect to h-tail of U,W then (i+h, j) is a winning pair with respect to U,W. If (i,j) is a winning pair with respect to h-tail of U,W the (i, j) is a winning pair with respect to U,W. 
         [0100]    Proof. Follows directly from Definitions 2.15 and 2.18. 
         [0101]    Lemma 2.20. If Σ s=1   t (u s −w s )&gt;0, then there exist at least Σ s=1   t (u s −w s ) winning pairs. 
         [0102]    Proof. We use induction on t. For t=1, any pair (1, j) is winning if 1≦j≦u 1 −w 1 . Consider t&gt;1 and apply the following case analysis. 
         [0103]    1. Assume that there exist 1≦h&lt;t, such that Σ s=1   h (u s −w s )≦0. Consider the h-tail of U,W. By induction and by Fact 2.19, there exist at least Σ s=h+1   t (u s −w s )≧Σ s=1   t (u s −w s ) winning pairs with respect to U,W. 
         [0104]    2. Assume that (1,u 1 ) is a winning pair. It follows that (1, j), j&lt;u 1  is a winning pair as well. If Σ s=2   t (u s −w s )&gt;0, then, by induction and by Fact 2.19, there exist at least Σ s=2   t (u s −w s ) winning pairs of the form (i,j) where i&gt;1. In total there are u 1 +Σ s=2   t (u s −w s )≧Σ s=1   t (u s −w s ) winning pairs with respect to U,W. The case when Σ s   2   t (u s −w s )&lt;0 is trivial. 
         [0105]    Assume that eqns. 1 and 2 do not hold. Then, u l &gt;0. Indeed otherwise u 1 −w 1 ≦0 and, thus, eqn. 1 is true. Also, (1,1) is a winning pair. Indeed, otherwise there exists 1&lt;h&lt;t such that − 1+Σhd i=1   t (u i −w i )&lt;0. All numbers are integers. Thus, Σ i=1   h (u i −w i )≦0 and eqn. 1 is true. Thus, (1,1) is a winning pair and (1,u 1 ) is not a winning pair (by eqn. 2). Therefore, there exist 1&lt;u≦u 1 , such that (1,u−1) is a winning pair and (1,u) is not a winning pair. In particular, there exist 1≦h&lt;t, such that 
         [0000]    
       
         
           
             
               
                 - 
                 u 
               
               + 
               
                 
                   ∑ 
                   
                     s 
                     = 
                     1 
                   
                   h 
                 
                  
                 
                   ( 
                   
                     
                       u 
                       s 
                     
                     - 
                     
                       w 
                       s 
                     
                   
                   ) 
                 
               
             
             &lt; 
             0. 
           
         
       
     
         [0000]    On the other hand, (1,u−1) is a winning pair, thus, 
         [0000]    
       
         
           
             0 
             ≤ 
             
               1 
               - 
               u 
               + 
               
                 
                   ∑ 
                   
                     s 
                     = 
                     1 
                   
                   h 
                 
                  
                 
                   
                     ( 
                     
                       
                         u 
                         s 
                       
                       - 
                       
                         w 
                         s 
                       
                     
                     ) 
                   
                   . 
                 
               
             
           
         
       
     
         [0000]    All numbers are integers and, thus, it can be concluded that 
         [0000]    
       
         
           
             
               
                 ∑ 
                 
                   s 
                   = 
                   1 
                 
                 h 
               
                
               
                 ( 
                 
                   
                     u 
                     s 
                   
                   - 
                   
                     w 
                     s 
                   
                 
                 ) 
               
             
             = 
             
               u 
               - 
               1. 
             
           
         
       
     
         [0000]    Consider the h-tail of U,W. By induction, there exists at least 
         [0000]    
       
         
           
             
               
                 ∑ 
                 
                   i 
                   = 
                   
                     h 
                     + 
                     1 
                   
                 
                 t 
               
                
               
                 ( 
                 
                   
                     u 
                     i 
                   
                   - 
                   
                     w 
                     i 
                   
                 
                 ) 
               
             
             = 
             
               
                 
                   ∑ 
                   
                     i 
                     = 
                     1 
                   
                   t 
                 
                  
                 
                   ( 
                   
                     
                       u 
                       i 
                     
                     - 
                     
                       w 
                       i 
                     
                   
                   ) 
                 
               
               - 
               
                 ( 
                 
                   u 
                   - 
                   1 
                 
                 ) 
               
             
           
         
       
     
         [0000]    winning pairs with respect to the h-tail of U,W of the form (i, j) , where i&gt;1. By properties of u, there exist additional (u−1) winning pairs of the form (1, j), j≦u−1. Summing up, the fact is obtained. 
         [0106]    3. The Streaming Algorithm 
         [0107]    Fact 3.1. Let v 1 , . . . , v n  be a sequence of non-negative numbers and let k&gt;2. Then, 
         [0000]    
       
         
           
             
               
                 ( 
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       1 
                     
                     n 
                   
                    
                   
                     v 
                     i 
                     2 
                   
                 
                 ) 
               
               
                 ( 
                 
                   k 
                   - 
                   1 
                 
                 ) 
               
             
             ≤ 
             
               
                 ( 
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       1 
                     
                     n 
                   
                    
                   
                     v 
                     i 
                     k 
                   
                 
                 ) 
               
                
               
                 
                   
                     ( 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         n 
                       
                        
                       
                         v 
                         i 
                       
                     
                     ) 
                   
                   
                     ( 
                     
                       k 
                       - 
                       2 
                     
                     ) 
                   
                 
                 . 
               
             
           
         
       
     
         [0108]    Proof. Define 
         [0000]    
       
         
           
             
               λ 
               i 
             
             = 
             
               
                 
                   v 
                   i 
                 
                 
                   
                     ∑ 
                     
                       j 
                       = 
                       1 
                     
                     n 
                   
                    
                   
                     v 
                     j 
                   
                 
               
               . 
             
           
         
       
     
         [0000]    Since g(x)=x k−1  is convex on the interval [0, ∞), we can apply Jensen&#39;s inequality and obtain 
         [0000]    
       
         
           
             
               
                 ( 
                 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       v 
                       i 
                       2 
                     
                   
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       v 
                       i 
                     
                   
                 
                 ) 
               
               
                 k 
                 - 
                 1 
               
             
             = 
             
               
                 
                   
                     ( 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         n 
                       
                        
                       
                         
                           λ 
                           i 
                         
                          
                         
                           v 
                           i 
                         
                       
                     
                     ) 
                   
                   
                     ( 
                     
                       k 
                       - 
                       1 
                     
                     ) 
                   
                 
                 ≤ 
                 
                   ( 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       
                         λ 
                         i 
                       
                        
                       
                         v 
                         i 
                         
                           ( 
                           
                             k 
                             - 
                             1 
                           
                           ) 
                         
                       
                     
                   
                   ) 
                 
               
               = 
               
                 
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       v 
                       i 
                       k 
                     
                   
                   
                     
                       ∑ 
                       
                         i 
                         = 
                         1 
                       
                       n 
                     
                      
                     
                       v 
                       i 
                     
                   
                 
                 . 
               
             
           
         
       
     
         [0109]    Let D be a stream. Define: 
         [0000]    
       
         
           
             
               
                 
                   
                     ψ 
                     = 
                     
                       
                         
                           n 
                           
                             1 
                             - 
                             
                               ( 
                               
                                 1 
                                 / 
                                 k 
                               
                               ) 
                             
                           
                         
                          
                         
                           G 
                           k 
                           
                             1 
                             / 
                             k 
                           
                         
                       
                       
                         F 
                         1 
                       
                     
                   
                   , 
                   
                     δ 
                     = 
                     
                       2 
                        
                       
                         ⌈ 
                         
                           0.5 
                            
                           
                               
                           
                            
                           
                             
                               log 
                               2 
                             
                              
                             
                               ( 
                               ψ 
                               ) 
                             
                           
                         
                         ⌉ 
                       
                     
                   
                   , 
                   
                     t 
                     = 
                     
                       ⌈ 
                       
                         
                           δ 
                            
                           
                               
                           
                            
                           
                             F 
                             1 
                           
                         
                         
                           n 
                           
                             1 
                             / 
                             k 
                           
                         
                       
                       ⌉ 
                     
                   
                   , 
                   
                     
                       λ 
                       = 
                       
                         ⌈ 
                         
                           
                             
                               F 
                               1 
                             
                              
                             
                               δ 
                               3 
                             
                           
                           n 
                         
                         ⌉ 
                       
                     
                     ; 
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   27 
                 
               
             
           
         
       
     
         [0110]    where eqn. 2 was used to define F k . We will make the following assumptions: 
         [0000]        f   1 ≦0.1 F   1   , t≦F   1   ,F   1 (mod t )=0   Eqn. 28.
 
         [0111]    Then, it is possible to define a r×t matrix M, where r=F 1 /t and with entries m i,j =p ir+j . 
         [0112]    Fact 3.2. 1≦δ≦2 n   (k−1)/2k . 
         [0113]    Proof. Indeed G 1 ≦G k   1/k n 1−1/k  by Holder inequality and since f 1 ≦0.1F 1  by eqn. 28, we have ψ≧0.5. Thus, ┌0.5 log 2 (ψ)┐≧0 and the lower bound follows. Also, F k   1/k  is the L k  norm for the frequency vector since all frequencies are non-negative. Since L k ≦L 1 , we conclude that ψ≦n 1−1/k  and the fact follows. 
         [0114]    Observe that there exists a frequency vector with δ=O(1): put f j =1 for all i ε [n]. At the same time there exists a vector with δ=Ω(n (k−1)/2k ): put f 1 =n and f j =1 for j&gt;2. It is not hard to see that if δ is sufficiently large ten a naive sampling method will find a heavy element. For example, in the latter case, the heavy element occupies half of the stream. 
         [0115]    Fact 3.3. λr≦4G k   1/k . 
         [0116]    Proof. Recall that F 1 =rt. The fact follows from the definitions of λ and t. 
         [0117]    Fact 3.4. 
         [0000]    
       
         
           
             
               
                 G 
                 2 
               
               t 
             
             ≤ 
             
               
                 G 
                 k 
                 
                   1 
                   / 
                   k 
                 
               
               . 
             
           
         
       
     
         [0118]    Proof. Define 
         [0000]    
       
         
           
             α 
             = 
             
               
                 
                   k 
                   - 
                   3 
                 
                 
                   2 
                    
                   
                     ( 
                     
                       k 
                       - 
                       2 
                     
                     ) 
                   
                 
               
               . 
             
           
         
       
     
         [0000]    We have by Holder inequality: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       G 
                       2 
                       α 
                     
                     ≤ 
                     
                       
                         G 
                         k 
                         
                           
                             2 
                              
                             α 
                           
                           k 
                         
                       
                        
                       
                         n 
                         
                           α 
                            
                           
                             ( 
                             
                               1 
                               - 
                               
                                 2 
                                 k 
                               
                             
                             ) 
                           
                         
                       
                     
                   
                   = 
                   
                     
                       G 
                       k 
                       
                         
                           k 
                           - 
                           3 
                         
                         
                           k 
                            
                           
                             ( 
                             
                               k 
                               - 
                               2 
                             
                             ) 
                           
                         
                       
                     
                      
                     
                       
                         n 
                         
                           
                             k 
                             - 
                             3 
                           
                           
                             2 
                              
                             k 
                           
                         
                       
                       . 
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   29 
                 
               
             
           
         
       
     
         [0119]    Also, by Fact 3.1: 
         [0000]    
       
         
           
             
               
                 
                   
                     G 
                     2 
                     
                       1 
                       - 
                       α 
                     
                   
                   = 
                   
                     
                       G 
                       k 
                       
                         
                           k 
                           - 
                           1 
                         
                         
                           2 
                            
                           
                             ( 
                             
                               k 
                               - 
                               2 
                             
                             ) 
                           
                         
                       
                     
                     ≤ 
                     
                       
                         G 
                         k 
                         
                           1 
                           
                             k 
                              
                             
                               ( 
                               
                                 k 
                                 - 
                                 2 
                               
                               ) 
                             
                           
                         
                       
                        
                       
                         
                           G 
                           1 
                           
                             1 
                             2 
                           
                         
                         . 
                       
                     
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   30 
                 
               
             
           
         
       
     
         [0120]    Thus, 
         [0000]    
       
         
           
             
               
                 G 
                 2 
               
               ≤ 
               
                 
                   G 
                   k 
                   
                     
                       k 
                       - 
                       3 
                     
                     
                       k 
                        
                       
                         ( 
                         
                           k 
                           - 
                           2 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   n 
                   
                     
                       k 
                       - 
                       3 
                     
                     
                       2 
                        
                       k 
                     
                   
                 
                  
                 
                   G 
                   k 
                   
                     1 
                     
                       2 
                        
                       
                         ( 
                         
                           k 
                           - 
                           2 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   F 
                   1 
                   
                     1 
                     2 
                   
                 
               
             
             = 
             
               
                 
                   G 
                   k 
                   
                     1 
                     k 
                   
                 
                  
                 
                   
                     F 
                     1 
                   
                   
                     n 
                     
                       1 
                       / 
                       5 
                     
                   
                 
                  
                 
                   
                     ( 
                     
                       
                         
                           G 
                           k 
                           
                             1 
                             k 
                           
                         
                          
                         
                           n 
                           
                             
                               k 
                               - 
                               1 
                             
                             k 
                           
                         
                       
                       
                         F 
                         1 
                       
                     
                     ) 
                   
                   
                     1 
                     / 
                     2 
                   
                 
               
               = 
               
                 t 
                  
                 
                     
                 
                  
                 
                   
                     G 
                     k 
                     
                       1 
                       k 
                     
                   
                   . 
                 
               
             
           
         
       
     
         [0121]    Fact 3.5. 
         [0000]    
       
         
           
             
               
                 G 
                 3 
               
               
                 λ 
                  
                 
                     
                 
                  
                 t 
               
             
             ≤ 
             
               
                 G 
                 k 
                 
                   1 
                   / 
                   k 
                 
               
               . 
             
           
         
       
     
         [0122]    Proof. By Holder inequality: 
         [0000]        G   3 ≦G k   3/k   n   1−(3/k)    Eqn. 31.
 
         [0123]    Thus, 
         [0000]    
       
         
           
             
               
                 G 
                 3 
               
               
                 λ 
                  
                 
                     
                 
                  
                 t 
               
             
             = 
             
               
                 
                   
                     n 
                     
                       1 
                       + 
                       
                         ( 
                         
                           1 
                           / 
                           k 
                         
                         ) 
                       
                     
                   
                    
                   
                     G 
                     3 
                   
                 
                 
                   
                     F 
                     1 
                     2 
                   
                    
                   
                     δ 
                     4 
                   
                 
               
               ≤ 
               
                 
                   
                     n 
                     
                       2 
                       - 
                       
                         ( 
                         
                           2 
                           / 
                           k 
                         
                         ) 
                       
                     
                   
                    
                   
                     G 
                     k 
                     
                       3 
                       / 
                       k 
                     
                   
                 
                 
                   
                     F 
                     1 
                     2 
                   
                    
                   
                     δ 
                     4 
                   
                 
               
               ≤ 
               
                 
                   G 
                   k 
                   
                     1 
                     / 
                     k 
                   
                 
                 . 
               
             
           
         
       
     
         [0124]    Theorem 3.6. Let M be a r×t matrix, such that eqn. 27 is true. Then, there exist absolute constants α,β such that: 
         [0000]      α G   k   1/k   ≦f   1   ≦βt    Eqn. 32;
 
         [0125]    imply: 
         [0000]    
       
         
           
             
               
                 
                   
                     P 
                      
                     
                       ( 
                       
                         
                           S 
                           r 
                         
                         = 
                         1 
                       
                       ) 
                     
                   
                   ≥ 
                   
                     
                       δ 
                       
                         2 
                          
                         
                             
                         
                          
                         
                           n 
                           
                             1 
                             - 
                             
                               ( 
                               
                                 2 
                                 / 
                                 k 
                               
                               ) 
                             
                           
                         
                       
                     
                     . 
                   
                 
               
               
                 
                   Eqn 
                   . 
                   
                       
                   
                    
                   33 
                 
               
             
           
         
       
     
         [0126]    Proof. By eqn. 32 and Facts 3.3, 3.4, and 3.5, 
         [0000]    
       
         
           
             
               6 
                
               
                   
               
                
               
                 α 
                 ( 
                 
                   
                     λ 
                      
                     
                         
                     
                      
                     r 
                   
                   + 
                   
                     
                       G 
                       3 
                     
                     
                       λ 
                        
                       
                           
                       
                        
                       t 
                     
                   
                   + 
                   
                     
                       G 
                       2 
                     
                     t 
                   
                 
                 ) 
               
             
             ≤ 
             
               f 
               1 
             
             ≤ 
             
               β 
                
               
                   
               
                
               
                 t 
                 . 
               
             
           
         
       
     
         [0000]    Also, eqn. 27 implies 
         [0000]    
       
         
           
             
               
                 f 
                 1 
               
               / 
               t 
             
             ≥ 
             
               
                 δ 
                 
                   n 
                   
                     1 
                     - 
                     
                       ( 
                       
                         2 
                         / 
                         k 
                       
                       ) 
                     
                   
                 
               
               . 
             
           
         
       
     
         [0000]    Thus, eqn. 33 follows from Theorem 2.1. 
         [0127]    This describes an exemplary implementation of pick-and-drop sampling in accordance with the present invention, which can be represented in exemplary code as follows: 
         [0000]    
       
         
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
           
               
                   
               
               
                 Algorithm 1 P&amp;D (M, r, t, λ) 
               
               
                   
               
             
             
               
                   
               
             
          
           
               
                   
                 Generate independent identically distributed random variables, 
               
               
                   
                 {I j } j=1   r  with uniform distribution on [t]. 
               
               
                   
                 S 1  = m 1,I     1     
               
               
                   
                 C 1  = d 1,I     1     
               
               
                   
                 q 1  = 1. 
               
               
                   
                 for i = 2 → r do 
               
             
          
           
               
                   
                 if (C i−1  &lt; max{λq i−1, c i }) then 
               
             
          
           
               
                   
                 S i  = s i  , 
               
               
                   
                 C i  = c i  , 
               
               
                   
                 q i  = 1 
               
             
          
           
               
                   
                 else 
               
             
          
           
               
                   
                 S i  = S i−1  , 
               
               
                   
                 C i  = c i  + fs i,l  , 
               
               
                   
                 q i  = q i−1  +1 
               
             
          
           
               
                   
                 end if 
               
             
          
           
               
                   
                 end for 
               
               
                   
                 Output (S r ,C r ) 
               
               
                   
                   
               
             
          
         
       
     
         [0128]    Theorem 3.7. Denote f i   k &gt;100Σ j≠i f j   k  as a heavy element. There exist a (constructive) algorithm that makes one pass over the stream and uses O(n 1−2/k  log(n)) bits. The algorithm outputs a pair (i,{tilde over (f)} i ), such that with probability 1. If there exists a heavy element f i , then also with constant probability, the algorithm will output (i, {tilde over (f)} i ), such that (1−ε)f i ≦{tilde over (f)} i . 
         [0129]    Proof. Define t as in eqn. 27. Without loss of generality, we can assume F 1  is divisible by t. Note that if t&gt;F 1  or f 1 ≧0.1F 1 , then it is possible to find a heavy element with O(n 1−2/k ) bits by existing methods such as in Moses Charikar, Kevin Chen, and Martin Farach-Colton. Finding frequent items in data streams. In ICALP &#39;02: Proceedings of the 29th International Colloquium on Automata, Languages and Programming, pages 693-703, London, UK, 2002. Springer-Verlag, which is incorporated herein by reference. Otherwise, a stream D defines a matrix M for which we compute O(n 1−2/k /ε δ) independent pick-and-drop samples. Since we do not know the value of δ, we should repeat the experiment for all possible values of δ. Output the element with the maximum frequency. With constant probability, the output of the pick-and-drop sampling will include a (1−ε) approximation of the frequency f i . Thus, there will be no other f j  that can give a larger approximation and replace a heavy element. The total space will define geometric series that sums to O(n 1−2/k  log(n)). 
         [0130]    If we know F 1  ahead of time then we can compute the value of t for any possible δ and thus solve the problem in one pass. However, one can show that the well-known doubling technique (when we double our parameter t each time the size of the stream doubles) will work in our case and, thus, one pass is sufficient even without knowing F 1 . 
         [0131]    Previously, such as described in Vladimir Braverman and Rafail Ostrovsky. Recursive sketching for frequency moments. CoRR, abs/1011.2571, 2010, which is incorporated herein by reference, we developed a method of recursive sketches with the following property: Given an algorithm that finds a heavy element and uses memory μ(n), it is possible to solve the frequency moment problem in space O(μ(n)log (c) (n)). In this previous work, we applied recursive sketches with the method of Charikar et.al. cited above. Thus, we can replace the method from Charikar et al. with Theorem 3.7 and obtain: 
         [0132]    Theorem 3.8. Let ε and k be constants. There exists a (constructive) algorithm that computes (1±ε)-approximation of F k , uses O(n 1−2/5  log(n)log (c) (n)) memory bits, makes one pass, and errs with probability at most ⅓. 
         [0133]    The above analysis focuses on the case when 1 is a “heavy element,” but it is possible to repeat arguments for any i. The above Theorem 2.1 claims that 1 will be outputted with probability 
         [0000]    
       
         
           
             Ω 
              
             
               ( 
               
                 
                   f 
                   1 
                 
                 t 
               
               ) 
             
           
         
       
     
         [0000]    for sufficiently large f 1 . Notably, Theorem 2.1 holds for arbitrary distributions of frequencies. Furthermore, as addressed with respect to Theorem 3.6, there exist r,t,λ such that a bound similar to eqn. 3 holds. This new method can be combined with other method to obtain, for example, Theorem 3.8 
         [0134]    Thus, the pick-and-drop sampling method samples a heavy element, such as an element i with frequency Ω(F k )) with probability Ω(1/n 1−2/k ) and gives approximation {tilde over (f)} i ≧(1−ε)f i . In addition, the estimations never exceed the real values, that is f i ≦f j  for all j. As a result, the space complexity of finding a heavy element can be reduced to O(n 1−2/k  log(n)) bits. Recursive sketches can be used to resolve the problem with O(n 1−2/k  log(n)log (c) (n)) bits. Advantageously, optimizing the space complexity as a function of ε can be avoided. 
         [0135]    The present invention has been described in terms of one or more preferred embodiments, and it should be appreciated that many equivalents, alternatives, variations, and modifications, aside from those expressly stated, are possible and within the scope of the invention.