CompleteKaryTree

CompleteKaryTree[n]
gives the complete binary tree with n levels.

CompleteKaryTree[n,k]
gives the complete k-ary tree with n levels.

Details and OptionsDetails and Options

  • The complete k-ary tree with n levels is a rooted tree with k branches at each node and n levels deep.
  • The complete k-ary tree with n levels has vertices.
  • CompleteKaryTree[,DirectedEdges->True] gives a directed complete k-ary tree.
  • CompleteKaryTree takes the same options as Graph.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

A complete binary tree with 5 levels:

In[1]:=
Click for copyable input
Out[1]=

A complete ternary tree with 3 levels:

In[1]:=
Click for copyable input
Out[1]=

Use directed edges:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2010
(8.0)
Translate this page: