trees-diskspace.html
来自「经典的数据结构源代码(java 实现)」· HTML 代码 · 共 24 行
HTML
24 行
<html><head><title>Code Fragment</title></head><body text=#000000><center></center><br><br><dl><dd><pre> <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>static</font> <E> <font color=#8000a0><font color=#8000a0>int</font> </font><font color=#0000ff>diskSpace </font>(Tree<E> T, Position<E> v) { <font color=#8000a0><font color=#8000a0>int</font> </font>s = <font color=#0000ff>size</font>(v); <font color=#ff0080>// start with the size of the node itself</font> <font color=#ff8000>for</font><font color=#0000ff> </font>(Position<E> w : T.<font color=#0000ff>children</font>(v)) <font color=#ff0080>// add the recursively computed space used by the children of v</font> s += <font color=#0000ff>diskSpace</font>(T, w); <font color=#ff8000>if</font><font color=#0000ff> </font>(T.<font color=#0000ff>isInternal</font>(v)) { <font color=#ff0080>// print name and disk space used</font> System.out.<font color=#0000ff>print</font>(<font color=#0000ff>name</font>(v) + <font color=#008000>": "</font> + s); } <font color=#8000a0><font color=#ff8000>return</font> </font>s; }</dl></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?