Moved building and displaying of trees to its own function.
Made the function a template, so the program should be able to handle any data type that supports comparisons (<, >) with minimal editing.