The input file input.txt:
"AAA" 16 32
"BBB" 32 128
"CCC" 16 128
"DDD" 96 192
"EEE" 192 224
Sample queries with results:
% java intervalquery input.txt 10 250
Looked at seg-tree nodes 0-255, 0-128, 0-64, 0-32, 16-32,
32-64, 64-128, 128-255, 128-192, 192-255, 192-224
Found nothing
% java intervalquery input.txt 18 30
Looked at seg-tree nodes 0-255, 0-128, 0-64, 0-32, 16-32
Found
AAA 16 32
CCC 16 128
% java intervalquery input.txt 34 90
Looked at seg-tree nodes 0-255, 0-128, 0-64, 32-64, 64-128
Found
BBB 32 128
CCC 16 128
% java Intervalquery input.txt 100 120
Looked at seg-tree nodes 0-255, 0-128, 64-128, 96-128
Found
BBB 32 128
CCC 16 128
DDD 96 192
The output file segment_tree.txt for all the above inputs:
Node 1
Parent: none
Low: 0
High: 255
Lines: none
Node 2
Parent: 1
Low: 0
High: 128
Lines: none
Node 4
Parent: 2
Low: 0
High: 64
Lines: none
Node 8
Parent: 4
Low: 0
High: 32
Lines: none
Node 17
Parent: 8
Low: 16
High: 32
Lines: AAA, CCC
Node 9
Parent: 4
Low: 32
High: 64
Lines: BBB, CCC
Node 5
Parent: 2
Low: 64
High: 128
Lines: BBB, CCC
Node 11
Parent: 5
Low: 96
High: 128
Lines: DDD
Node 3
Parent: 1
Low: 128
High: 255
Lines: none
Node 6
Parent: 3
Low: 128
High: 192
Lines: DDD
Node 7
Parent: 3
Low: 192
High: 255
Lines: none
Node 14
Parent: 7
Low: 192
High: 224
Lines: EEE