There is a binary search tree equipped with the following methods besides the usual ones:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The following data (in the following order) are inserted into the binary search tree:
10, 4, 17, 2, 15, 1, 6, 29, 9, 14, 13, 8, 16
If the output of
printRLC
is
, compute
.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The BST that we get by inserting the given set of values in order is as follows;
And the
printRLC(root)
gives the following result; 16,13,14,15,17,29,1,2,4,8,9,6,10. Therefore; i = 0 ∑ 1 2 ( i × a i ) = 0 × 1 6 + 1 × 1 3 + 2 × 1 4 + 3 × 1 5 + 4 × 1 7 + 5 × 2 9 + 6 × 1 + 7 × 2 + 8 × 4 + 9 × 8 + 1 0 × 9 + 1 1 × 6 + 1 2 × 1 0 = 6 9 9Following is the python3 code;
printRLC(root)
on that.