How many nodes can a binary tree have at level n? Use induction to prove the answer.

This is homework and I didn’t have much time to spend on it, but I know some answers and need a little help plz

I think that we have:

1 node ----> Level 1

2.3 nodes ----> Level 2

3,4,5,6,7 nodes ----> level 3

4,5,6, ....., 15 knots ----> Level 4

5,6,7,8,9, ....., 31 knots ----> Level 5

node (s) interval from [min = X node (s) TO max = 2 ^ X - 1 node (s)], where X represents the level

from now on I'm confused how to finish

+4
source share
3 answers

As I recall, to use induction you need to prove the Nth case and the N + 1st case. And we see for any N that the N + 1st level has exactly twice as much. Thus, 2 ^ (N + 1) / 2 ^ N = 2 is shown

The total number of nodes can be found by taking the sum from n = 0 to N - 1 out of 2 ^ n

You probably need a more convincing and detailed answer, but that's the point.

+3
source

You seem to be right. The minimum number of nodes a binary tree can have is n, and the maximum is 2 ^ n-1

+1
source

A node at level n in a binary tree will have n ancestors. Induction proof: Show P (0): A node at level 0 has no ancestors. (This is true because it is the root.) Show P (1): A node at level 1 has one ancestor. (This is true: an ancestor is the root, his father, which is at level 0.) Suppose P (K): A node at level K has K ancestors. His father is at level K - 1. Prove that P (K + 1): A node at level K + 1 will have one more ancestor than node at level K. K + 1st element will have a parent at level ( K + 1) -1, or level K.

0
source

Source: https://habr.com/ru/post/1333657/


All Articles