Problem Detail: A pizza commercial claims that you can combine their ingredients to 34 million different combinations. I didn’t believe it, so I dusted off my rusty combinatorics skills and tried to figure it out. Here’s what I have so far: Read More …
Blog
Rule of thumb to know if a problem could be NP-complete
Problem Detail: This question was inspired by a comment on StackOverflow. Apart from knowing NP-complete problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one? I Read More …
Randomized Selection
Answered By : Louis Suppose your array has $n$ elements. As you have noted, the median is always in the bigger part after the first partition. The bigger part has size at most $alpha n$ if the smaller part has size Read More …
Is there a known maximum for how much a string of 0’s and 1’s can be compressed?
Answered By : D.W. Kolmogorov complexity is one approach for formalizing this mathematically. Unfortunately, computing the Kolmogorov complexity of a string is an uncomputable problem. See also: Approximating the Kolmogorov complexity. It’s possible to get better results if you analyze the Read More …
Find maximum element in sorted arrays in logarithmic time
Answered By : Aryabhata If the elements need not be distinct, then you cannot have an $O(log n)$ time algorithm. Consider the sorted array $[0,0, dots, 1]$ which has been cyclic shifted $k$ (unknown) times and you need to find where Read More …
What is difference between Buffering and Spooling with respect to Operating System
Answered By : D.W. There’s not really a significant difference. Spooling uses buffering. Buffering can be used for other purposes, too. The second quote you include in your question (I/O overlap, etc.) looks to me like it’s not very helpful. The Read More …
Is the set of Turing machines which stop in at most 50 steps on all inputs, decideable?
Answered By : Niel de Beaudrap Let’s consider the more general problem of machines which stop after at most $N$ steps, for some $N geqslant 1$. (The following is a substantial simplifcation of a previous version of this answer, but is Read More …
are NP Complete languages closed under any regular operations?
Answered By : David Richerby For all of the examples in this answer, I’m taking the alphabet to be ${0,1}$. Note that the languages $emptyset$ and ${0,1}^*$ are definitely not NP-complete. The class of NP-complete languages is not closed under intersection. Read More …
Is finding the longest path of a graph NP-complete?
Answered By : Juho First, it is easy to see that the problem is in $text{NP}$. The longest path is a Hamiltonian one since it visits all vertices. Indeed, there is a straightforward reduction from $text{HAM-PATH}$ to it. For details and Read More …
Easy reduction from 3SAT to Hamiltonian path problem
Answered By : c c The number of vertices in the well-known reduction from 3SAT to directed Hamiltonian Path(dHAMPATH) can be easily reduced to $O(n+k)$, where $n$ is the number of variables and $k$ is the number of clauses, therefore the Read More …