用于在完整二叉树中跟踪路径的算法 [英] Algorithm for tracing the path in a full binary tree

查看:64
本文介绍了用于在完整二叉树中跟踪路径的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个完整的二叉树找到i和第j个位置,并找到路径并跟踪移动。

解决方案

你必须只在步骤后记录所有操作步骤满足您需求的问题。您只能记录是选择左侧还是右侧节点。因此,您将留下LRLRRR或010111等日志。如果你保存了树木行走的深度,你可以使用位移操作。



听起来像是一个青少年作业。 :-O

given a full binary tree find i and jth positions and also find the path and trace the movements.

解决方案

you must only log all operation step after step in a matter which suites your needs. You must only log whether you choose the left or the right node. So you will left with a log like "LRLRRR" or "010111". If you save the depth of your tree walk you can use bit shift operations.

Sounds like a teenager homework. :-O


这篇关于用于在完整二叉树中跟踪路径的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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