汇编实现二叉树的建立与遍历

时间:2012-06-02 04:03:26
【文件属性】:
文件名称:汇编实现二叉树的建立与遍历
文件大小:5KB
文件格式:TXT
更新时间:2012-06-02 04:03:26
汇编二叉树 二叉树的建立 二叉树的遍历 这个汇编程序是利用数组和递归实现二叉树的建立与遍历,带注释的,下面是部分代码,与大家分享了 .model small .stack 64 .data Array db 32 dup(0,0,0) MSG1 db 0ah,0dh,'$' MSG2 db "Please input the root node of the binary: ",'$' MSG3 db "'s leftchild is(no leftchild,press ENTER):",'$' MSG4 db "'s rightchild is(no rightchild,press ENTER):",'$' MSG5 db "Preorder is:",'$' ;先序结果 MSG6 db 0ah,0dh,"Inorder is:",'$' ;中序结果 MSG7 db 0ah,0dh,"Postorder is:",'$' ;后序结果 ;主过程======================================================== .code main proc far mov ax,@data mov ds,ax ;初始化段寄存器 lea si,Array ;将数组的首地址放进索引寄存器SI sub cx,cx mov ah,09h lea dx,MSG2 int 21h ;提示输入根结点 mov ah,01h int 21h cmp al,0dh je exit call storage ;调用存储部分 call preorder ;先序遍历 lea dx,MSG6 call prepare call inorder ;中序遍历 lea dx,MSG7 call prepare call postorder ;后序遍历 exit: mov ah,4ch int 21h main endp

网友评论