单选题:对于如下代码段,说法不正确的是:
对于如下代码段,说法不正确的是: @[B](2)
```
class TreeNode:
def __init__(self, value):
self.leftChild = None
self.rightChild = None
self.value = value
def tree_test_function(T):
L = [T]
while len(L) > 0:
p = L[-1]
del L[-1]
print(p.value)
if p.leftChild != None:
L.append(p.leftChild)
if p.rightChild != None:
L.append(p.rightChild)
```
A. 若 `T` 为空值 `None`, 则函数 `tree_test_function` 无法正常工作
B. `tree_test_function` 函数的功能是输出一棵二叉树的先序遍历序列
C. `tree_test_function` 函数能输出二叉树中的所有元素
D. `L` 实现了栈的功能
A.若 `T` 为空值 `None`, 则函数 `tree_test_function` 无法正常工作
B.`tree_test_function` 函数的功能是输出一棵二叉树的先序遍历序列
C.`tree_test_function` 函数能输出二叉树中的所有元素
D.`L` 实现了栈的功能
答案:B
```
class TreeNode:
def __init__(self, value):
self.leftChild = None
self.rightChild = None
self.value = value
def tree_test_function(T):
L = [T]
while len(L) > 0:
p = L[-1]
del L[-1]
print(p.value)
if p.leftChild != None:
L.append(p.leftChild)
if p.rightChild != None:
L.append(p.rightChild)
```
A. 若 `T` 为空值 `None`, 则函数 `tree_test_function` 无法正常工作
B. `tree_test_function` 函数的功能是输出一棵二叉树的先序遍历序列
C. `tree_test_function` 函数能输出二叉树中的所有元素
D. `L` 实现了栈的功能
A.若 `T` 为空值 `None`, 则函数 `tree_test_function` 无法正常工作
B.`tree_test_function` 函数的功能是输出一棵二叉树的先序遍历序列
C.`tree_test_function` 函数能输出二叉树中的所有元素
D.`L` 实现了栈的功能
答案:B