在不使用递归的情况下查找二叉搜索树的高度 [英] finding height of a binary search tree without using recursion

查看:45
本文介绍了在不使用递归的情况下查找二叉搜索树的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经获得了这个界面,

I have been given this interface,

展开 | 选择 | Wrap | 行号

推荐答案

提示:方法是应用到对象。使用height方法,您似乎只想将对象作为参数传递。嗯......
Hint: methods are applied to objects. With your height method, you seem to only want to pass objects as arguments. Hmmm...


大多数处理树的递归方法都可以用一些循环编写 - 一般来说,试着想一想你的递归调用会做什么,然后尝试用循环来模仿它。
Most recursive methods dealing with trees can be written with some loops - try thinking of, in general, what your recursive calls would do, then try to mimic that with loops.



处理树的大多数递归方法都可以用一些循环编写 - 一般来说,试着考虑你的递归调用会做什么,然后尝试用循环来模仿它。
Most recursive methods dealing with trees can be written with some loops - try thinking of, in general, what your recursive calls would do, then try to mimic that with loops.



我在原始帖子中没有看到任何地方(其他主题!),其中OP需要写一个不是递归的高度函数,只是一个有效!

I didn''t see anywhere (other that the topic!) in the original post where the OP was required to write a height function that wasn''t recursive, just one that worked!


这篇关于在不使用递归的情况下查找二叉搜索树的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆