• Victor@lemmy.world
    link
    fedilink
    arrow-up
    41
    arrow-down
    1
    ·
    edit-2
    5 months ago

    How in the hell does anyone f— up so bad they get O(n!²)? 🤯 That’s an insanely quickly-growing graph.

    Curious what the purpose of that algorithm would have been. 😅

    • petersr@lemmy.world
      link
      fedilink
      arrow-up
      17
      ·
      5 months ago

      Let me take a stab at it:

      Problem: Given two list of length n, find what elements the two list have in common. (we assume that there are not duplicates within a single list)

      Naive solution: For each element in the first list, check if it appears in the second.

      Bogo solution: For each permutation of the first list and for each permutation of the second list, check if the first item in each list is the same. If so, report in the output (and make sure to only report it once).

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        5 months ago

        lol, you’d really have to go out of your way in this scenario. First implement a way to get every single permutation of a list, then to ahead with the asinine solution. 😆 But yes, nice one! Your imagination is impressive.

  • Mikina@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    5 months ago

    It has been a while since I have to deal with problem complexities in college, is there even class of problems that would require something like this, or is there a proven upper limit/can this be simplified? I don’t think I’ve ever seen O(n!^k) class of problems.

    Hmm, iirc non-deterministic turing machines should be able to solve most problems, but I’m not sure we ever talked about problems that are not NP. Are there such problems? And how is the problem class even called?

    Oh, right, you also have EXP and NEXP. But that’s the highest class on wiki, and I can’t find if it’s proven that it’s enough for all problems. Is there a FACT and NFACT class?