Computer Science Canada Binary Search Help |
Author: | Qamar [ Tue Feb 24, 2009 8:59 pm ] | ||
Post subject: | Binary Search Help | ||
one of our assignments is to ask the user to enter in a last name to find from a text file, we have to take the text file and put it into an array... then call a function to do a binary search to find it... the code compiles fine, but when i call the function on line 19 it says the variable has no value...
|
Author: | Tony [ Tue Feb 24, 2009 9:04 pm ] |
Post subject: | RE:Binary Search Help |
well, what are the values of all the variables used on that line? Also, I'm really impressed by how your bin_search runs in O(1) |
Author: | Qamar [ Tue Feb 24, 2009 9:10 pm ] | ||
Post subject: | Re: Binary Search Help | ||
on the line, name is passed by choice, so that should be the name that is entered and lastname (mid) is the name on the array. and i made the array global. i'm not seeing why either of the variables shouldn't have a value. and ... thank you ? haha are i'm not sure if your joking about it being a binary search or not ... this is what our teacher called it. edit: ops.. ignore the
i just had that there to make sure that the file was going into the array.[/syntax] |
Author: | Qamar [ Tue Feb 24, 2009 10:49 pm ] | ||
Post subject: | Re: Binary Search Help | ||
never mind... i got it to work... my mid wasn't being declared properly... so i had to figure out the actual max of the array... why wouldn't upper / lower work ?... because wouldn't it determine the beginning and the end of the array ? here's my code...
|