Exemplo n.º 1
0
  public Node DFS() {
    boolean found;
    Math math;
    int tmp;
    math = new Math();
    found = false;
    currVal = 0;
    while (!found) {
      System.out.println(currNode.getId());
      if (math.equal(currNode.getVal(), value)) {
        found = true;
      } else {
      }

      if (!found && math.equal(currVal, currNode.getNumChilds())) {
        if (stack.isEmpty()) {
          found = true;
        } else {
          currNode = currNode.getParent();
          currVal = stack.pop();
        }
      } else if (!found) {
        tmp = currNode.getNode(currVal).setParent(currNode);
        currNode = currNode.getNode(currVal);

        currVal = currVal + 1;
        tmp = stack.push(currVal);
        currVal = 0;
      } else {
      }
    }

    return currNode;
  }
Exemplo n.º 2
0
 public Node getNode(int i) {
   Math math;
   Node node;
   math = new Math();
   if (math.equal(i, 0)) node = _a_0;
   else if (math.equal(i, 1)) node = _a_1;
   else if (math.equal(i, 2)) node = _a_2;
   else if (math.equal(i, 3)) node = _a_3;
   else node = this;
   return node;
 }