binode=RECORD data:ElemType; lchild
PROC PreOrder(bt:bitreptr); //非遞歸前序遍列二叉樹
VAR S:ARRAY[
inits(S);//棧初始化
WHILE (bt<>NIL) OR (NOT empty(S)) DO
[WHILE (bt<>NIL )DO
[write(bt↑data); push(S
WHILE (NOT empty(S) AND top(S)=NIL) bt:=pop(S);// 退棧
IF NOT empty(S) THEN bt:=pop(S);
] ENDP;
[算法討論]若不要求使用top(S)
int Leaves(int h) //求深度為h以順序結構存儲的二叉樹的葉子結點數
{int BT[]; int len=
for (i=
if (BT[i]!=
if(i*
else if(BT[
return (count)
} //結束Leaves
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23721.html