Question

Given an AVL tree show (using pseudocode and/or plain English) how to support the following query...

Given an AVL tree show (using pseudocode and/or plain English) how to support the following query called RangeReport(k1, k2) which lists all the keys in AVL tree which are in between k1 and k2 in O(log n + output) time. (Hint: Think of modifying Inorder).

Homework Answers

Answer #1

Algorithm for above problem

void RangeReport(root,k1,k2):
   if(root==null):
       return;
   if(node.data>=k1 and node.data<=k2):
       print(root.data)
       RangeReport(root.left,k1,k2)
       RangeReport(root.right,k1,k2)
   else if(node.data<low):
       RangeReport(root.left,k1,k2)
   else:
       RangeReport(root.right,k1,k2)

Mention in comments if any mistakes or errors are found. Thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT