Preorder, inorder, postorder for tree in C++11
Memory management

Don't think that is the appropriate smart pointer.

shared_ptr&lt;node&gt; newNode (int i)


Do you have plans to actually share ownership of a node? Or is it more likely that ownership will be done by the patent of the node? I would have gone with unique_ptr&lt;node&gt; if I was going to use smart pointers.

make_X

You should not be using new with smart pointers. There are make_XXX commands that combine all the memory allocation required into a single operation (thus making it more efficient).

   std::shared_ptr&lt;node&gt; n  = std::make_shared&lt;node&gt;(val);  // or make_unique


Using

I suppose this is better than using namespace std;

using std::cout;
using std::endl;
using std::shared_ptr;


But its still pretty sloppy and lazy. Pull those declarations into the tightest scope possible (ie inside a function).

Braces

This looks strange

preOrder((n-&gt;left));
preOrder((n-&gt;right));


Now I am all for using braces to make expression easy to read or to force a particular evaluation order. But this just looks strange and does not help in the evaluation.

Prefer '\n'

Prefer '\n' to std::endl.

The difference between the two is that std::endl forces a flush after placing the new line on the stream. It is very rare that you actually want to force a flush (as the runtime is much better at making that decision than you). Excessive flushing just makes the stream libraries slow.


“\n” or '\n' or std::endl to std::cout?
Why does endl get used as a synonym for “\n” even though it incurs significant performance penalties?