@ -99,10 +99,13 @@ class PrintUtil {
static void printArray ( T * arr , int n )
static void printArray ( T * arr , int n )
{
{
cout < < " [ " ;
cout < < " [ " ;
for ( size_ t i = 0 ; i < n - 1 ; i + + ) {
for ( in t i = 0 ; i < n - 1 ; i + + ) {
cout < < arr [ i ] < < " , " ;
cout < < arr [ i ] < < " , " ;
}
}
cout < < arr [ n - 1 ] < < " ] " < < ' \n ' ;
if ( n > = 1 )
cout < < arr [ n - 1 ] < < " ] " < < endl ;
else
cout < < " ] " < < endl ;
}
}
/**
/**
@ -206,31 +209,31 @@ class PrintUtil {
}
}
string prev_str = " " ;
string prev_str = " " ;
Trunk * trunk = new T runk( prev , prev_str ) ;
Trunk t runk( prev , prev_str ) ;
printTree ( root - > right , trunk , true ) ;
printTree ( root - > right , & trunk , true ) ;
if ( ! prev ) {
if ( ! prev ) {
trunk - > str = " ——— " ;
trunk . str = " ——— " ;
}
}
else if ( isLeft ) {
else if ( isLeft ) {
trunk - > str = " /——— " ;
trunk . str = " /——— " ;
prev_str = " | " ;
prev_str = " | " ;
}
}
else {
else {
trunk - > str = " \\ ——— " ;
trunk . str = " \\ ——— " ;
prev - > str = prev_str ;
prev - > str = prev_str ;
}
}
showTrunks ( trunk ) ;
showTrunks ( & trunk ) ;
cout < < " " < < root - > val < < endl ;
cout < < " " < < root - > val < < endl ;
if ( prev ) {
if ( prev ) {
prev - > str = prev_str ;
prev - > str = prev_str ;
}
}
trunk - > str = " | " ;
trunk . str = " | " ;
printTree ( root - > left , trunk , false ) ;
printTree ( root - > left , & trunk , false ) ;
}
}
/**
/**