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

Threaded View

  1. #6
    Join Date
    May 2008
    Posts
    300

    Re: Not repeating an operation to cutdown runtime

    Problem here is you need either remember the result, or calculate them again. And recalculating is seemingly more expensive.

    A most simple way is a constant sized buffer, that you know the work won't exceed that buffer.

    If you are not sure about the working size, dynamic-sized buffer.

    A chain of buffers is a little complex, but could be more efficent.

    If you are handling something too large, write it to file. Files are good dynamic-sized buffers if you don't access them often.

    p.s. maybe just loop until NUM / the_first_prime_you_found, or simpler NUM / 2, which is less efficient.
    Last edited by DreamShore; June 2nd, 2008 at 03:14 AM.
    Nope

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