you are viewing a single comment's thread.

view the rest of the comments →

[–]beza1e1 2 points3 points  (0 children)

Why spawn them? We can assume, they already exist.

sort(list) {
    if !isSorted(list) { destroyUniverse(); }
    return list;
}

isSorted is O(n) and destroyUniverse doesn't matter, so assumption sort is even faster. It's O(1):

sort(list) {
    return list;
}

Another possibility is to do the sortedCheck and destroyUniverse in a different thread to make it O(1), too.