• Hudell@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    13 hours ago

    This might be a stupid question but I have just some limited experience with sorting algorithms and was wondering something: could some algorithm like this be improved specifically for multi-threaded processing? I mean, an algorithm that is generally NOT the best option with a single thread, become better than other algorithms when it can delegate part of the work to different threads?

    Perhaps something that runs the same algorithm on several threads, each starting at a different point of the map, but sharing their findings with the other threads?

    • TehPers@beehaw.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 hours ago

      Algorithms can be designed for multithreading yes. Divide and conquer algorithms, like this one, break the problem into independent chunks, and a map reduce on that work can force it to be done across multiple threads.

      The real question is whether you gain anything from it. Creating a thread and sending data back and forth has a cost as well, and it’s usually a pretty big one relative to the work being done.