Jump to content

99 Elm Problems/Problem 63

From Wikibooks, open books for an open world

Construct a complete binary tree.

A complete binary tree with height H is defined as follows:

The levels 1,2,3,...,H-1 contain the maximum number of nodes.

In level H, which may contain less than the maximum possible number of nodes, all the nodes are "left-adjusted". This means that in a level-order tree traversal all internal nodes come first, the leaves come second, and empty successors come last.

# # # THIS IS A STUB # # #

Example in Elm:
import Html exposing (text)
import List

f : Int -> Int
-- your implementation goes here

main = text (toString (f 0))

Result:

4

Solutions