Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: Binary Search

  1. #21
    Join Date
    Sep 2007
    Location
    Victoria, BC Canada
    Posts
    185
    Quote Originally Posted by $eymour View Post
    I tried and fail to work out why my algorithm wont find the last record in the array
    I've go the code working - that is, I find "player".

    Of course I had to make a few alteration, most just to get it to work in the test - nothing at all to the logic/flow ... the most significant in my mind was:
    Top := Length(searcharray);
    at the beginning.

    If changing that doesn't work let me know, I'll send you the test project.

  2. #22
    Join Date
    Jun 2007
    Posts
    47
    Changed to Top := Length(searcharray); but thinks Length(searcharray) = 2???

  3. #23
    Join Date
    Sep 2007
    Location
    Victoria, BC Canada
    Posts
    185
    yea, was just thinking, what is searcharray anyway, an array of records I believe. I'm using an array of string. Your code works fine with an array of strings. I think there's a problem with searcharray and/or arraysize and/or loading searcharray.

  4. #24
    Join Date
    Sep 2007
    Location
    Victoria, BC Canada
    Posts
    185
    FWIW arraysize, with a [1..6] array should be 6 check and see what you're getting.

  5. #25
    Join Date
    Jun 2007
    Posts
    47
    Found The Problem...Thanks TDelphiHobbyist. New it wasnt a problem with arraysize, thought algorithm was correct therefor i check the load array procedure and saw that i had
    Code:
    searcharray[i] := loginrec;
    read(loginfile, loginrec);
    where as it should be the other way round, this was filling the array with admin for 1 and 2 then ben 3 and so on so player never made it in the array..

  6. #26
    Join Date
    Sep 2007
    Location
    Victoria, BC Canada
    Posts
    185
    glad you found it

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •