Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove Circular Dependency in FOLLOW set

Consider a short gramma bellow

S -> Bc | DB
B -> ab | cS
D -> d | epsilon

The FIRST set is

FIRST(S) ={a,c,d}
FIRST(B) = { a,c }
FIRST(D)= { d, epsilon }

in it the

Follow(S)={ Follow(B) }

and

Follow(B) ={ c , Follow(S) }

my question is that how to resolve this circular dependency ?

like image 659
Zabi Avatar asked Sep 24 '11 13:09

Zabi


People also ask

How do I get rid of circular dependency?

The Mediator Pattern can also help to lift circular dependencies by encapsulating the bidirectional interaction of two or more objects. The downside of your current code is (besides the circular dependency), that whenever class A changes and also data persistence changes, you have to touch and modify class B.

How do I get rid of circular references in Excel?

To fix the problem, you can move the formula to another cell. Press Ctrl+X to cut the formula, select another cell, and press Ctrl+V to paste it. You can also try one of these techniques: If you just entered a formula, start with that cell and check to see if you refer to the cell itself.

How do I get rid of cyclic dependency in Java?

A simple way to break the cycle is by telling Spring to initialize one of the beans lazily. So, instead of fully initializing the bean, it will create a proxy to inject it into the other bean. The injected bean will only be fully created when it's first needed.

How do I remove circular dependency in DAX?

Therefore, you experience circular dependency only once you have created the second column. The correct solution to avoid this is to restrict the list of columns that the calculated column depends on, by using ALLEXCEPT or REMOVEFILTERS and keeping only the table's primary key.


1 Answers

This circular dependency shouldn't be there to start with. this is the algorithm for finding 'follow's:

Init all follow groups to {}, except S which is init to {$}.
While there are changes, for each A∈V do:
  For each Y → αAβ do:
    follow(A) = follow(A) ∪ first(β)
    If β ⇒* ε, also do: follow(A) = follow(A) ∪ follow(Y)

So in your case, you should get:
Follow(S)={c,$}
Follow(B)={c,$}
Follow(D)={a,c}

like image 183
Eran Zimmerman Gonen Avatar answered Sep 24 '22 06:09

Eran Zimmerman Gonen