This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Thursday, November 21, 2002, at 07:38 PM, Roger Sayle wrote:
No, honest. I don't think it is. The typical fold code looks like this:On Thursday, November 21, 2002, at 05:37 PM, Roger Sayle wrote:The problem I've noticed is that the recursion in "fold" appears to be O(n^2) instead of O(n).I don't believe it is. Try it out. I think one the first ply is folded, thus limiting the amount of work done.I believe it really is O(n^2).
Given a unary-tree, even if each level is actually transformed only once,In that case, we have:
fold will still retraverse the levels below it confirming that nothing can
be done. So in a tree/list N-levels deep, the leaf will be checked N times
(the level above that N-1 etc...). It takes a synthetic example, such as
(((A+-B)+-C)+-D)+-E to show it, but big-O notation is for the worst case.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |