Class Main {
public void dfs() {
		// DFS using Stack data structure
		Stack stack = new Stack();
		stack.push(this.rootNode);
		rootNode.visited=true;
		printNode(rootNode);
		while(!stack.isEmpty()) {
			Node node = (Node)s.peek();
			Node child = getUnvisitedChildNode(n);
			if(child != null) {
				child.visited = true;
				printNode(child);
				s.push(child);
			}
			else {
				s.pop();
			}
		}
		// Clear visited property of nodes
		clearNodes();
	}
}

	public void bfs()
	{
		// BFS using Queue data structure
		Queue queue = new LinkedList();
		queue.add(this.rootNode);
		printNode(this.rootNode);
		rootNode.visited = true;
		while(!queue.isEmpty()) {
			Node node = (Node)queue.remove();
			Node child=null;
			while((child=getUnvisitedChildNode(node))!=null) {
				child.visited=true;
				printNode(child);
				queue.add(child);
			}
		}
		// Clear visited property of nodes
		clearNodes();
	}

Class Node {
   Char data;
   Public Node(char c) {
      this.data=c;
}

@@ -144,16 +144,46 @@
 ed=true;
+ //mark pushed node as visited
 %0A%09%09print
@@ -217,32 +217,64 @@
 ack.isEmpty()) %7B
+ //confirm there is no underflow
 %0A%09%09%09Node node = 
@@ -695,36 +695,100 @@
 rue;
-%0A%09%09while(!queue.isEmpty()) %7B
+  //mark pushed node as visited%0A%09%09while(!queue.isEmpty()) %7B  //confirm there is no underflow
 %0A%09%09%09

Update BFSDFS.java