【发布时间】:2019-11-26 21:30:11
【问题描述】:
我有一个项目需要在 MIPS 中创建一个二叉搜索树。我在 C 中很好理解,但 MIPS 是我迷路的地方。我的教授已包含此代码以使用插入方法。我对 addNodeToTree 和 addNode 之间的区别感到困惑:
# add a node to tree
#
# input: $a0 the address of the tree
# $a1 the value you want to add to the tree
addNodeToTree :
subu $sp, $sp, 4 # adjust the stack pointer
sw $ra, 0($sp) # save the return address on stack
subu $sp, $sp, 4 # adjust the stack pointer
sw $a0, 0($sp) # save the parameter
lw $a0, 0($a0) # addNode(bTree->root);
jal addNode
lw $a0, 0($sp) # get the parameter
addu $sp, $sp, 4 # adjust the stack pointer
lw $ra, 0($sp) # get the return address
addu $sp, $sp, 4 # adjust the stack pointer
jr $ra
# please implement this method
#
# add a node to tree
#
# input: $a0 the address of the root node
# $a1 the value you want to add to the tree
#
# hint: you need to write a recursive call here
addNode :
jr $ra # to return
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
-
我想这就是你要找的BInary tree project
标签: binary binary-search-tree mips