Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

The algorithmic problem Range

Posted on 2011-10-16
1
Medium Priority
?
253 Views
Last Modified: 2012-05-12
Consider the algorithmic problem Range de fined as follows:
Input: a, possibly NULL, node x in a binary search tree; two key values a,b with a less or egual to b;
Output: the sequence of entries in the binary search tree with root x whose key values are in the range [a..b].
Give a recursive algorithm to solve the above problem.
0
Comment
Question by:gudni12345
1 Comment
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
ID: 36975963
It's really easy. It's supposed to be recursive and you know in a binary search tree that every node less than the root is on the left of the root and every node greater is on the right side.
So all you need to do is look at x and see where it falls in the range. Then just recurse the tree from x putting all the values in the range out as output.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question