public static void simulateLogic(Gate g){
  if (g.is_unvisited()) {
    ArrayList<Gate> children=g.getChildren();
    for (    Gate child : children) {
      if (child.is_unvisited()) {
        simulateLogic(child);
      }
    }
    g.set_unvisited(false);
    g.set_logics(GateUtil.computeGateLogics(g));
  }
}

public static void simulateLogic ( Gate g ) { if ( g . is_unvisited ( ) ) { ArrayList < Gate > children = g . getChildren ( ) ; for ( Gate child : children ) { if ( child . is_unvisited ( ) ) { simulateLogic ( child ) ; } } g . set_unvisited ( false ) ; g . set_logics ( GateUtil . computeGateLogics ( g ) ) ; } }
synopsis [ ] keep tracing back to child until find one with logics defined assume it has either 1 or 2 children this method is recursive note : recursion is not necessary and does not occur if we sort the gates by distance to input , then simulate logic in that order . logic is computed according to gate type and input logics
