Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. re: Fast Searching...

re: Fast Searching...

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmsregexhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bryster
    wrote on last edited by
    #1

    Hi Here is the Problem: To access a Datafile which contains 26 Million addresses and find a given address. The Datafile is an ascii text file and is fixed What I have come up with: 1. Sort the 26 Million addresses into Postcode order. (I have application for this) 2. Using FSEEK look at the MIDDLE of the file and compare using STRNCMP the POSTCODE for searching, against the POSTCODE within the Datafile. 3. Using the result move the file pointer backwards from the middle (half it) or forwards and keep checking until a match is found. This will loop for roughly 24-25 times and not 26 Million. Is there a better way?

    L H 2 Replies Last reply
    0
    • B Bryster

      Hi Here is the Problem: To access a Datafile which contains 26 Million addresses and find a given address. The Datafile is an ascii text file and is fixed What I have come up with: 1. Sort the 26 Million addresses into Postcode order. (I have application for this) 2. Using FSEEK look at the MIDDLE of the file and compare using STRNCMP the POSTCODE for searching, against the POSTCODE within the Datafile. 3. Using the result move the file pointer backwards from the middle (half it) or forwards and keep checking until a match is found. This will loop for roughly 24-25 times and not 26 Million. Is there a better way?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I would recommend converting the text file and using a binary tree for faster searching. I can think of two libraries you could possibly use to accomplish this: QDBM http://qdbm.sourceforge.net/[^] SQLITE http://www.sqlite.org/[^] Best Wishes, -David Delaune

      B 1 Reply Last reply
      0
      • L Lost User

        I would recommend converting the text file and using a binary tree for faster searching. I can think of two libraries you could possibly use to accomplish this: QDBM http://qdbm.sourceforge.net/[^] SQLITE http://www.sqlite.org/[^] Best Wishes, -David Delaune

        B Offline
        B Offline
        Bryster
        wrote on last edited by
        #3

        Thank you, I will have a look at these.:-D

        1 Reply Last reply
        0
        • B Bryster

          Hi Here is the Problem: To access a Datafile which contains 26 Million addresses and find a given address. The Datafile is an ascii text file and is fixed What I have come up with: 1. Sort the 26 Million addresses into Postcode order. (I have application for this) 2. Using FSEEK look at the MIDDLE of the file and compare using STRNCMP the POSTCODE for searching, against the POSTCODE within the Datafile. 3. Using the result move the file pointer backwards from the middle (half it) or forwards and keep checking until a match is found. This will loop for roughly 24-25 times and not 26 Million. Is there a better way?

          H Offline
          H Offline
          Hans Dietrich
          wrote on last edited by
          #4

          Probably the easiest way to speed searching is to divide the big file into N smaller files, maybe organized by a partial postcode. Then, after you have selected the correct (smaller) file, the search will be that much faster. This involves a minimum or presort setup.

          Best wishes, Hans


          [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

          B 1 Reply Last reply
          0
          • H Hans Dietrich

            Probably the easiest way to speed searching is to divide the big file into N smaller files, maybe organized by a partial postcode. Then, after you have selected the correct (smaller) file, the search will be that much faster. This involves a minimum or presort setup.

            Best wishes, Hans


            [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

            B Offline
            B Offline
            Bryster
            wrote on last edited by
            #5

            Thank you, that sounds like a good idea.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups