Top-down Parsing - Time and Space Complexity of Top-down Parsing

Time and Space Complexity of Top-down Parsing

When top-down parser tries to parse an ambiguous input with respect to an ambiguous CFG, it may need exponential number of steps (with respect to the length of the input) to try all alternatives of the CFG in order to produce all possible parse trees, which eventually would require exponential memory space. The problem of exponential time complexity in top-down parsers constructed as sets of mutually recursive functions has been solved by Norvig in 1991. His technique is similar to the use of dynamic programming and state-sets in Earley's algorithm (1970), and tables in the CYK algorithm of Cocke, Younger and Kasami.

The key idea is to store results of applying a parser p at position j in a memotable and to reuse results whenever the same situation arises. Frost, Hafiz and Callaghan also use memoization for refraining redundant computations to accommodate any form of CFG in polynomial time (Θ(n4) for left-recursive grammars and Θ(n3) for non left-recursive grammars). Their top-down parsing algorithm also requires polynomial space for potentially exponential ambiguous parse trees by 'compact representation' and 'local ambiguities grouping'. Their compact representation is comparable with Tomita’s compact representation of bottom-up parsing.

Using PEG's, another representation of grammars, packrat parsers provide an elegant and powerful parsing algorithm. See Parsing expression grammar.

Read more about this topic:  Top-down Parsing

Famous quotes containing the words time and, time, space and/or complexity:

    By Time and Age full many things are taught.
    Aeschylus (525–456 B.C.)

    Earth has waited for them,
    All the time of their growth
    Fretting for their decay:
    Now she has them at last!
    Isaac Rosenberg (1890–1918)

    For good teaching rests neither in accumulating a shelfful of knowledge nor in developing a repertoire of skills. In the end, good teaching lies in a willingness to attend and care for what happens in our students, ourselves, and the space between us. Good teaching is a certain kind of stance, I think. It is a stance of receptivity, of attunement, of listening.
    Laurent A. Daloz (20th century)

    It is not only their own need to mother that takes some women by surprise; there is also the shock of discovering the complexity of alternative child-care arrangements that have been made to sound so simple. Those for whom the intended solution is equal parenting have found that some parents are more equal than others.
    Elaine Heffner (20th century)