Question: Given an AVL tree show (using pseudocode) how to support the following queries: 1) RangeCount(k1, k2): Count the number of keys in the AVL tree
Given an AVL tree show (using pseudocode) how to support the following queries:
1) RangeCount(k1, k2): Count the number of keys in the AVL tree which are between k1 and k2 in O(log n) time (Hint: Recall the size field).
2) RangeReport(k1, k2): List all the keys in AVL tree which are in between k1 and k2 in O(log n + output) time.
3) RangeMin(k1, k2): Consider the field data stored in each node to be an integer. Find the key with minimum data values among all the keys which are between k1 and k2 in O(log n) time. (Hint: Consider storing an additional field in the Node structure and show how can this field be maintained during updates)
Step by Step Solution
3.40 Rating (166 Votes )
There are 3 Steps involved in it
To address these queries in an AVL tree context we need to make certain modifications to the AVL tre... View full answer
Get step-by-step solutions from verified subject matter experts
