i have simple problem with binarysearch using arrays
Let p refer to first item in list 1, and r refer to first item in list 2 while more elements in list 1 look for item at position p of list1 at or after position r in list 2 if item found at or after position r in list 2 set r to that position *** how to set the postion in arry so that for the next iteration it will start from that position increment P else increment R look for item at position p before position r in list 2*** *** how to set the postion in array and it searchs from the postion before r
if found set r to that position advance p to next position increment N
"infyniti"- Welcome to the JavaRanch! We like to keep a professional lookin' image around here, and don't really fancy it when people try to show up the one-eyed moose. So if you could change your display name (click here), that'd be just dandy. Basically, it should be a believable first AND last name (If you'd like a more thorough reason as to why I'm asking you to change your name, check out the Naming Policy.)
Also, we don't like to do people's homework for them. But we're more than willing to help you get over specific issues that you're having. What code have you tried to use that didn't work? What problem were you experiencing? Try posting a code snippet and we'll see what we can do.
Lastly, I'm moving this to the intermediate forum where I think its a better fit. So please post your replies there.
Thanks! And again, Welcome to the JavaRanch!
Joined: Nov 12, 2004
Thanks Jessica Sant for moving my post to right place...
And i have worked it ....the only problem i am not able to set the postion of that r as explained in my previous post so that the next iteration will start from there...so i just if know if any method exists of moving to certain to location...
Check out the naming policy once more --> Basically, it should be a believable first AND last name.
As for your problem.
Why not just keep two integers that act as pointers to a position in the array?
Joined: Nov 12, 2004
Thanks Jessican sant ...I am pasting my code can u just let me know if i want to start my next iteration of sFile2 from the last found postion of list instead of searching from the first... FileReader frFile1 = new FileReader("file1"); BufferedReader brFile1 = new BufferedReader(frFile2);