Skip to content

Instantly share code, notes, and snippets.

@aurorapar
Last active November 25, 2016 20:59
Show Gist options
  • Save aurorapar/74d05302ce70a08e82ffd9f017ce1759 to your computer and use it in GitHub Desktop.
Save aurorapar/74d05302ce70a08e82ffd9f017ce1759 to your computer and use it in GitHub Desktop.
if(testData != '(' && testData != ')')
{
Node prevNode = node;
debug("Creating right child for '" + Character.toString(node.getData()) + "'");
Node tempNode = new Node();
node.setRight(tempNode);
node = tempNode;
debug("Right child should be set to " + Character.toString(input.charAt(0)));
node.setData(input.charAt(0));
debug("Right child (pushed as well): " + Character.toString(node.getData()));
if(prevNode.getRight() == null)
{
debug("WARNING!!! RIGHT CHILD NOT SET!");
debug("This node is prevNode: " + Character.toString(prevNode.getData()));
}
else
{
debug("Right child of previous node: " + Character.toString(prevNode.getRight().getData()));
}
}
/*
Aurora Pariseau
Class for Node implementation
*/
import java.util.*;
class Node
{
private Node left = null;
private char data = Character.MIN_VALUE;
private Node right = null;
public Node()
{
}
public Node(char data)
{
this.setData(data);
}
public char getData()
{
return this.data;
}
public void setData(char input)
{
this.data = input;
}
public Node getLeft()
{
return this.left;
}
public void setLeft(Node node)
{
this.left = node;
}
public Node getRight()
{
return this.left;
}
public void setRight(Node node)
{
this.right = node;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment