dim cstack(20)
dim top
dim current
top=-1
top=top+1
cstack(top)=根结点
'前序
while not top=-1
current=cstack(top)
response.write current
top=top-1
if current的右结点不为空 then
top=top+1
cstack(top)=current的右结点
end if
if current的左结点不为空 then
top=top+1
cstack(top)=current的右结点
end if
wend
'中序
temp=树的结点数
dim PopTim(temp)
for i= 0 to temp-1
PopTim(i)=0'初始化计数组
next
top=top+1
cstack(top)=根结点
while not top=-1
PopTim(top)=PopTim(top)+1
current=cstack(top)
top=top-1
if(PopTim(top+1)=2) then
response.write current
if(current的右结点不为空) then
top=top+1
cstack(top)=current的右结点
end if
end if
top=top+1
cstack(top)=current
if(current的左结点不为空) then
top=top+1
cstack(top)=current的左结点
end if
wend
'后序
temp=树的结点数
dim PopTim(temp)
for i= 0 to temp-1
PopTim(i)=0'初始化计数组
next
top=top+1
cstack(top)=根结点
while not top=-1
PopTim(top)=PopTim(top)+1
current=cstack(top)
top=top-1
if(PopTim(top+1)=3) then
response.write current
end if
top=top+1
cstack(top)=current
if(PopTim(top-1)=1) then
if(current的左结点不为空) then
top=top+1
cstack(top)=current的左结点
else
top=top+1
cstack(top)=current的右结点
end if
end if
top=top+1
cstack(top)=current
if(current的左结点不为空) then
top=top+1
cstack(top)=current的左结点
end if