I forgot to mention the key part of the task. The key was to constitute the tree back by reading it from the file. The writing part is trivial, the reconstitution part is not. Try it. While not impossible for a decent programmer half an hour is not sufficient who does not deal with binary trees ona daily basis.