CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Sorting

  1. #1
    Guest

    Sorting

    what is the best way to sort 10 million strings, taking into account space & speed constraints . It takes about 5 hours for me now using a UNIX tool..


  2. #2
    Join Date
    May 1999
    Posts
    8

    Re: Sorting

    How are they stored?
    *) in memory?
    *) in flat file on hard disk?
    *) in database?


  3. #3
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: Sorting

    Hi.

    When I took C++ class, my professor told us this.
    When we want to sort the data, it is better for us to sort
    something whenever we input the data. Otherwise, the sorting time
    brings us to waste the time.

    In your case, the huge data already exists.
    It can't be helped.
    Next time, you had better change your program.

    Regards.
    -Masaaki Onishi-


  4. #4
    Guest

    Re: Sorting

    this would be in a file in the hard disk.
    The sorting involves strings. Please suggest an efficient method


  5. #5
    Join Date
    Apr 1999
    Posts
    1

    Re: Sorting

    try the quicksort rountine or try this :
    first open a second file, then read the first string in, second insertion starts to compare with a while loop, enz...
    close your file and delete the original and
    rename your second file to the first file.

    and try to keep your date in memory if you can.
    only at the last moment save it...

    hope this helps

    Luypaert Benny


  6. #6
    Guest

    Re: Sorting

    Hi,

    The best possible sort for that much data is the Radix Sort routine. The problem is getting the data from the flat file into memory. I would read the first key into a memory holder and us the file pointer to move up and down the flat file. I hope this helps. ;-)

    Later
    Ken


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured