Data Structure & Algorithm: Level-1 Problem #18. Utopian Tree

The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases by 1 meter.

A Utopian Tree sapling with a height of 1 meter is planted at the onset of spring. How tall will the tree be after  growth cycles?

For example, if the number of growth cycles is 5, the calculations are as follows:

PeriodHeight
01
12
23
36
47
514

数据结构和算法:初级练习题 #18 – 乌托邦树


乌托邦树每年经历2个生长周期。每年春天,它的高度都会翻倍。每年夏天,它的高度都会增加1米。

对于一颗在春天开始时种下的高1米的树,问经过指定周期后,树的高度为多少?

譬如前五个周期的计算结果如下:

周期高度
01
12
23
36
47
514

Python Solution

Utopian Tree