Construction of a binary tree of a one-dimensional array

The specified one-dimensional array of dimension n.

Required: 1). Sort elements in ascending order, using the method of the bubble.

2). Among the elements of an ordered array to construct a tree by the following rule:

a) the median element is the top of the tree. The array is divided into two parts, the left array from the top and right.

b) elements of the median obtained arrays are the vertices of the next level, which are, respectively, the left and right top of the tree node.

c) an array is divided into four parts. Medial elements of these arrays are respectively next-level nodes of the tree and the left and right upper level node etc. tree is built up until are tried array elements. At the last level of nodes can not be left or right node.

Required to find the left and right nodes of any selected node to construct a function


Additional information http://labworks.zz.mu/index.php/2012-12-29-19-25-29/3-binartrees