Mugtrio, surely
Mugtrio, surely
This is interesting. Naively I’d expect that each number in a shuffled array of length n has a 1/n chance of ending up in the correct position, so there ought to be on average 1 correctly placed number regardless of the array length. I might be neglecting a correlation here, where each incorrectly placed number decreases the odds for the remaining numbers. Assuming the above though, the whole problem becomes recursive, since we’d be left with an unsorted array of length n-1 on average. The expected number of sorts would then just be n. For the time complexity, we’d have O(n) for the original shuffle, plus O(n-1) for the next, and so on, yielding O(n^2) overall.
Half the time another dev asks me a question they either a) haven’t even googled the error message, or b) are trying to offload their work while keeping any credit.
Definitely help your coworkers when reasonable, but set limits and don’t let yourself be taken advantage of.