02-12-2007 10:42 AM
if i have 10 fields in a table . i sorted a table w.r .t 1,2 field. can binary search work on second field.
02-12-2007 10:50 AM
Hi Sreedhar,
No. It will not work.(It may still give the correct output, but the performance improvement that is expected will not be there).
Regards,
Ravi
02-12-2007 10:46 AM
Hi,
binary search will give good performance when u use the keys which u specified in the SORT. So sort the table with the keys which you will use to read the table for better performance outcome.
regards,
madhumitha
02-12-2007 10:50 AM
Hi Sreedhar,
No. It will not work.(It may still give the correct output, but the performance improvement that is expected will not be there).
Regards,
Ravi
02-12-2007 11:26 AM
Hi ,
the output may not be correct if u sort with X1,x2 and read it with x2. the output will be correct one incase x1 is constant. otherwise you will not get the desired output.
regards,
madhu
02-14-2007 4:45 AM
Hi,
The binary search will ot work.
but if you are sort with
sort int by a b.
and then reading with
read int with key a =some value
b = some value.
It will work.
02-14-2007 6:51 AM
Hi sreedar,
it won't work ... if you want to read with one key then sort the table with the same key only .. then it'll work. because sorting with fields a and b. whereas reading the table with key b and binary search addition requires sorted table in ascending order of b alone ...
Sort the table with key a b alone ... then it'll work..
02-14-2007 10:39 AM
Hello,
In your case doing binary search on 2nd field alone will not work out and performance will be defínitely bad.
Regs,
Venkat Ramanan N