/** pre order traversal */ private String preOrder(Node ptr) { String prefix = ""; if (ptr != null) { prefix = prefix.trim() + ptr.data; preOrder(ptr.left); preOrder(ptr.right); } return prefix; }