HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Is the Berkeley tutorial on Fibonacci trees using wrong figures?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thefibonaccifigurestreestutorialusingberkeleywrong

Problem

I'm confused about the figures in a Berkeley tutorial on Fibonacci trees, which depicts fibtree(2) as

and fibtree(3) as

I thought fibtree(3) looks like the following

(the figure is adapted from another StackOverflow post).

Do I misunderstand something? Or is the Berkeley tutorial misusing the figures?

Solution

I would like to say both you and that Berkeley tutorial are correct.

As commented by chepner, the trees in Berkeley tutorial and the trees you thought are the same semantically; only the labels of the nodes are different.

Every node in all figures represents a call to compute the corresponding Fibonacci number.

The difference is that you prefer to use strings "F(0)", "F(1)", "F(2)", etc. to represent the calls that compute the 0-th Fibonacci number, the 1-st Fibonacci number, the 2-nd Fibonacci number, etc. respectively while the Berkeley tutorial uses those Fibonacci numbers themselves, $0, 1, 1$, i.e., the results of those calls to represent the same calls respectively.

Your preference is more illustrative since the string "F(0)", "F(1)", "F(2)", "F(3)", etc. are obviously descriptive while the Fibonacci numbers $0, 1, 1, 2$, etc. do not indicate the calls immediately without additional explanation. Furthermore, both the node representing the call "F(1)" and the node representing a different call "F(2)" are labelled $1$ in Berkeley tutorial, which may lead to confusion.

Context

StackExchange Computer Science Q#148275, answer score: 21

Revisions (0)

No revisions yet.