对于具有n个节点的完整二叉树,叶节点有多少个节点? [英] For a complete binary tree with n nodes, how many nodes are leaf nodes?

查看:230
本文介绍了对于具有n个节点的完整二叉树,叶节点有多少个节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的幻灯片中,答案之一是n/2片叶子,但我看到的另一个答案是(n + 1)/2.我想知道哪一个是正确的,为什么?

One of the answers in our powerpoint says it is n/2 leaves, but I am seeing another answer which says (n+1)/2. I was wondering which one is correct if any, and why?

推荐答案

在最简单的情况下,一棵带有根节点的二叉树,左边和右边有3个节点,其中两个是叶节点.是(n + 1)/2 .

In the simplest case a binary tree with a root node, a left and a right has 3 nodes, two of which are leaf nodes. It's (n+1)/2.

这篇关于对于具有n个节点的完整二叉树,叶节点有多少个节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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