【发布时间】:2018-05-04 13:16:27
【问题描述】:
public void print ( BNode n )
{
for ( int k = temp ; k>=0 ; k=k-30 ) // temp = 300
{
System.out.print(" ");
}
for ( int i = 0 ; i < n.count ; i++ )
{
System.out.print ( n.getValue(i) + " " ) ;
}
if ( !n.leaf )
{
System.out.println ("") ;
for ( int j = 0; j <= n.count ; j++ )
{
temp = --temp ;
if ( n.getChild(j) != null )
{
print( n.getChild(j) ) ;
}
}
}
}
我正在尝试以预购方式打印 B 树的键值,就像给定 here 的 B 树渲染器一样。
我不想打印箭头,但想要一些好的间距。我已经尝试过我的代码,但我认为它不是正确的方法。
我该怎么做才能做到这一点?
【问题讨论】: