문제

I was studying Syntax Directed Definition from the "Compilers: Principles, Techniques and Tools by Aho, Ullman, Sethi and Lam" when I came across the following line in context of circular dependencies of attributes in parse tree:

It is computationally difficult to determine whether or not there exist any circularities in any of the parse trees that a given SDD could have to translate. (section: 5.1.2)

Also in http://cs.nyu.edu/courses/fall12/CSCI-GA.2130-001/lecture8.pdf it is mentioned that

Detecting cycles has exponential time complexity

But there is Tarjan's strongly connected components algorithm that can find cycles in O(E+V). So why are the above sources contradicting this?

Can anyone tell me what I am missing?

도움이 되었습니까?

해결책

It's O(E+V) to find a cycle in some parse tree. But that's not the problem. The problem is to

determine whether or not there exist any circularities in any of the parse trees that a given SDD could have to translate. (Emphasis added).

That's a rather more difficult problem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top