Breadth-first tree traversal using STL list
Don't use malloc(). If you do then you will need to track memory that is allocated with new and that allocated with malloc and use the appropriate de-allocation functions. Also using new calls the constructor and makes sure the object is correctly initialized.

#include&lt;malloc.h&gt; //on llvm we don't need this


Don't do this:

using namespace std;


See Why is “using namespace std;” considered bad practice?

In C++ you don't need to typedef structs. struct names are in the same namespace as everything else. Also Add a constructor to make sure things are correctly initialized.

typedef struct Node{
    int val;
    struct Node* left;
    struct Node* right;
}node;

// Prefer
struct Node
{
     int    val;
     Node*  left;
     Node*  right;
     Node(int v):val(v), left(NULL), right(NULL) {}
};


When pushing a value onto a tree or list. Return the new value rather than pass out values.

void push(node** root,int val)

// Your current usage is:
push(&amp;head, 5);

// Easier usage
head = push(head, 5);


Don't use C casts

        node* temp=(node*)malloc(sizeof(node));


If you must cast then use one of the C++ cast's. But any casts are a sign of bad design. Also using new means this is not required.

// Easier implementation of push:
Node* push(Node* current, value)
{
    if (current == NULL)
    {   return new Node(value);
    }

    if (value &lt;= current-&gt;value)
        current-&gt;left  = push(current-&gt;left,  value);
    else
        current-&gt;right = push(current-&gt;right, value); 

    return current;
}


In your breadth first printing of the tree don't treat the head as special. You should just push the head node onto the list. The loop while the list is not empty. Thus you remove the item at the top of the loop not the bottom.

// Code deliberately left out to make you work.


Don't free the nodes as past of the print function. Add a destructor to your node. So that it calls delete on left and right.

~Node()
{    delete left;
     delete right;
}


Then all you need to do is delete the head and all the nodes will be destroyed correctly.

Your design should hide the memory management. You should put the head node inside its own structure. So that it hides all the memory management and you the user of your class does not need to worry about any of that

class Tree
{ 
    Node*   head;
    Tree(Tree const&amp; copy);
    Tree&amp; operator=(Tree const&amp; rhs);
    public:
        Tree(): head(NULL) {}  // Set up empty tree.
       ~Tree() {delete head;}  // Memory management done.

        void push(int val)
        {
            head = ::push(head, val);
        }
        void printBF()
        {
            ::printout(head);
        }
};


Note the functions you wrote should also made as members of Node.