Skip to content

Instantly share code, notes, and snippets.

@slallum
Created May 12, 2013 22:20
Show Gist options
  • Save slallum/5565132 to your computer and use it in GitHub Desktop.
Save slallum/5565132 to your computer and use it in GitHub Desktop.
public static String order(RBNode node, String type) {
String right = (node.getRight() != null) ? "," + order(node.getRight(), type)
.toString() : "";
String left = (node.getLeft() != null) ? order(node.getLeft(), type)
.toString() + "," : "";
switch (type) {
case "pre":
return node.getKey() + left + right;
case "post":
return left + right + node.getKey();
default:
return left + node.getKey() + right;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment