View worked solution
Answer: 509
In the array representation of a complete binary tree with indices starting at :
- The root is at index .
- For any node at index , its left child is at and its right child is at .
Since the tree is a Binary Search Tree (BST), the largest elements are located along the rightmost path. Let's trace the rightmost path starting from the root:
The next right child would be at index . Since the tree has elements (indices to ), index has no right child and is a leaf node.
Now, let's examine the subtree rooted at index to determine the largest elements in the tree:
- The right child of is .
- The children of are (left child) and (right child).
By the properties of a BST, for the subtree rooted at :
Since is the right child of , all elements in the subtree of are greater than the element at :
Thus, the largest elements in descending order are:
- 1st largest: index
- 2nd largest: index
- 3rd largest: index
Free practice · Your answers on this page are not saved.
