汇编实现简单二叉树
来源:百度文库 编辑:神马文学网 时间:2024/10/01 10:48:19
TITLE Binary
INCLUDE Irvine32.inc
.data
array BYTE 50 dup('0')
strAskRoot BYTE 0dh,0ah,"Root:" ,0
strAskLeft BYTE 0dh,0ah,"left:" ,0
strAskRight BYTE 0dh,0ah,"Right:" ,0
strOrder BYTE 0dh,0ah,"Order:" ,0
.code
main proc
;mov ax,@data
;mov ds,ax
mov edx,offset strAskRoot
call WriteString
mov ebx,1
call CreateBT ;递归建树
mov edx,offset strOrder
call WriteString
mov ebx,1
call Order ;前序遍历树
exit
main endp
CreateBT proc uses eax ebx
mov eax,0
call ReadChar
cmp al,0dh
je Exit
mov array[ebx],al
call WriteChar
call LeftChild
call RightChild
Exit:
ret
CreateBT endp
LeftChild proc uses eax edx ebx
mov edx,offset strAskLeft
call WriteString
push ebx
shl ebx,1
call CreateBT
pop ebx
ret
LeftChild endp
RightChild proc uses eax edx ebx
mov edx,offset strAskRight
call WriteString
push ebx
shl ebx,1
inc ebx
call CreateBT
pop ebx
ret
RightChild endp
Order proc uses eax ebx edx ;该过程为前序遍历,中序遍历、后序遍历与前序遍历大致相同
cmp array[ebx],'0'
je return1
mov al,array[ebx]
call WriteChar
call PrintLeft
call PrintRight
return1:
ret
Order endp
PrintLeft proc uses ebx
push ebx
shl ebx,1
call Order
pop ebx
ret
PrintLeft endp
PrintRight proc uses ebx
push ebx
shl ebx,1
inc ebx
call Order
pop ebx
ret
PrintRight endp
end main
INCLUDE Irvine32.inc
.data
array BYTE 50 dup('0')
strAskRoot BYTE 0dh,0ah,"Root:" ,0
strAskLeft BYTE 0dh,0ah,"left:" ,0
strAskRight BYTE 0dh,0ah,"Right:" ,0
strOrder BYTE 0dh,0ah,"Order:" ,0
.code
main proc
;mov ax,@data
;mov ds,ax
mov edx,offset strAskRoot
call WriteString
mov ebx,1
call CreateBT ;递归建树
mov edx,offset strOrder
call WriteString
mov ebx,1
call Order ;前序遍历树
exit
main endp
CreateBT proc uses eax ebx
mov eax,0
call ReadChar
cmp al,0dh
je Exit
mov array[ebx],al
call WriteChar
call LeftChild
call RightChild
Exit:
ret
CreateBT endp
LeftChild proc uses eax edx ebx
mov edx,offset strAskLeft
call WriteString
push ebx
shl ebx,1
call CreateBT
pop ebx
ret
LeftChild endp
RightChild proc uses eax edx ebx
mov edx,offset strAskRight
call WriteString
push ebx
shl ebx,1
inc ebx
call CreateBT
pop ebx
ret
RightChild endp
Order proc uses eax ebx edx ;该过程为前序遍历,中序遍历、后序遍历与前序遍历大致相同
cmp array[ebx],'0'
je return1
mov al,array[ebx]
call WriteChar
call PrintLeft
call PrintRight
return1:
ret
Order endp
PrintLeft proc uses ebx
push ebx
shl ebx,1
call Order
pop ebx
ret
PrintLeft endp
PrintRight proc uses ebx
push ebx
shl ebx,1
inc ebx
call Order
pop ebx
ret
PrintRight endp
end main
汇编实现简单二叉树
二叉树及其遍历
第五章 二叉树
二叉树及其遍历
二叉树的遍历
第六章 树和二叉树
编程论坛-平衡二叉树[原创]
编程论坛-关于平衡二叉树
编程论坛-平衡二叉树[原创]
第二十四课 遍历二叉树
求!!建立平衡二叉树的源程序1
第二十七课 实验六 二叉树实验
文件上传原理简单实现
有限状态机(FSM)简单实现
文件上传原理简单实现
技术文章-单点登录的简单实现
--利用Compass实现一个简单的搜索引擎
Linux串口上网的简单实现
嵌入式多级目录简单数据库实现架构
Linux串口上网的简单实现
简单的答案 快速的实现
Ps简单实现酷炫融化效果
简单3步,实现你的人生目标!
简单3步,实现你的人生目标