Search code examples
algorithmtime-complexitybig-olittle-o

Example of an algorithm that is too time complex?


As much as i've searched online, I cannot find examples of algorithms that aren't solvable in practice due to the amount of time that they'd take to compute.

I was trying to think of an example such as counting the number, size, and location of each star that passes closest to a rocket ship on it's trip to alpha centauri. Would this be a good example? I mean, the star system is nearly 26 trillion miles away.

EDIT: I'm doing a short presentation on Big-O and Little-O notation and wanted to think of something out of the ordinary as to WHY solutions to problems can be solvable in practice, but they may not be solvable in principle due to the extremely large amount of time to compute, thus why Big-O is used to create estimations. The reason I wanted to go with stars is because it seems more interesting than some other subjects.

Thanks!


Solution

  • Imagine you have an array denoting a deck of 52 cards [AS, 2S, 3S, ... , JH, QH, KH] and you want to return all the different ways these cards can be shuffled.

    The first card has 52 possibilities, the second card has 51, the third has 50, and so on. There are a total of 52 factorial (52 * 51 * 50 * ... * 3 * 2 * 1) combinations, which is over 10^67 (close to the number of atoms in the universe I think).

    A lot of complex problems arise from having to reuse the same data in many different ways, not just having a lot of data.