Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Range query over binary search tree?

Name: Anonymous 2008-09-09 8:01

Okay, so does anyone know or can think of an efficient way to complete a range query over a given number range ie (x, y) in a standard binary search tree, using a minimum number of key comparisons? I wrote one that finds the minimum value <= x and then traverses the tree value by value until it finds a value that is above y, but I just realised that it would be a lot more efficient if it was recursive, and did not provide the range query's response in a sorted order.

Unfortunately, I have writer's block. Still getting used to getting my head in algorithm-space. Can anyone give me some pointers to get me started?

Name: Anonymous 2008-09-11 13:16

>>22,23
Are you fucking daft? Please re-read >>18,21 (and possibly the wikipedia article about optimizing tail recursion) to understand why any reasonable language can successfully execute >>21 without raping the stack. The code listing in >>21 was not intending to return a value (unlike your altered version in >>22), and your attempt to ``fix'' what was not already broken has revealed you are as incompetent as you are stupid.

Please refrain from posting on /prog/.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List