here is my code for display (code for the B-Tree specified in CLRS). Note that I used indentation to visualize parent-child relation. Aslo the depth or height is maintained in the display.
The intial call could be traverse(root, 0)
void traverse(node* x, int depth) const
{
if(x != NULL)
{
int i;
for(i=0; i<x->n; ++i)
cout<< (char)(x->key)[i] <<" ";
cout<<endl;
if(x->leaf == false)
{
for(i=0; i<=x->n; ++i)
{
for(int j=0; j<=depth; ++j)
cout<<"
";
traverse(x->c[i], depth+1);
}
}
}
}