4 ms·
A storage requirement of O(n!) Sorting a mere 13 items of 1-byte each would require 6.2 GB of storage.
by Sohcahtoa82 8y ago
A storage requirement of O(n!)
Sorting a mere 13 items of 1-byte each would require 6.2 GB of storage.
- senatorobama 8y agoGood interview question ;)
- dmichulke 8y agoWe just generate them on the fly - after all we're not stupid ;-) https://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations https://en.wikipedia.org/wiki/Permutation#Algorithms_to_gene... .. and there "Generation in lexicographic order" This algorithm only requires you to hold the last permutation in memory to obtain a new (distinct) one.