Most Popular

1500 questions
12
votes
3 answers

All NP problems reduce to NP-complete problems: so how can NP problems not be NP-complete?

My book states this If a decision problem B is in P and A reduces to B, then decision problem A is in P. A decision problem B is NP-complete if B is in NP and for every problem in A in NP, A reduces to B. A decision problem C is…
rubixibuc
  • 233
  • 1
  • 2
  • 6
12
votes
4 answers

Is there an algorithm whose time complexity is between polynomial time and exponential time?

We often hear about some algorithms' running time that is polynomial, and some algorithms' running time that is exponential. But is there an algorithm whose time complexity is between polynomial time and exponential time?
lz9866
  • 317
  • 2
  • 6
12
votes
1 answer

NTIME(f) subset of DSPACE(f)

As the question states, how do we prove that $\textbf{NTIME}(f(n)) \subseteq \textbf{DSPACE}(f(n))$? Can anyone point me to a proof or outline it here? Thanks!
gdiazc
  • 221
  • 1
  • 4
12
votes
5 answers

How does editing software (like Microsoft word or Gmail) pick the 2nd string to compare in Levenshtein distance?

I understand the textbook explanation of how to use dynamic programming to find the minimum edit distance between 2 strings but how do we get to pick the 2nd string? I don't think the entire dictionary is compared as sometimes the difference is…
heretoinfinity
  • 649
  • 1
  • 6
  • 16
12
votes
3 answers

Is it possible to prove thread safety?

Given a program consisting of variables and instructions which modify these variables, and a synchronization primitive (a monitor, mutex, java's synchronized or C#'s lock), is it possible to prove that such a program is thread safe? Is there even a…
12
votes
3 answers

Simple graph canonization algorithm

I'm looking for an algorithm that provides a canonical string for a given colored graph. Ie. an algorithm that returns a string for a graph, such that two graphs get the same string if and only if they are isomorphic. In particular, I'm looking for…
Peter
  • 1,505
  • 14
  • 20
12
votes
2 answers

What is the closure of context-free languages under finite intersections?

Famously the intersection of context-free languages need not be context-free. On the other hand the intersection of context-sensitive languages is context-sensitive. So this leads to the question: what is the closure of context-free languages under…
12
votes
3 answers

How can I quickly judge whether matrix A is the inverse matrix of B?

How can I quickly judge whether matrix A is the inverse matrix of B? This is an exercise for the course I take. This question is given in the section of randomized algorithms. So I think its solution may be related to randomized algorithms.
12
votes
3 answers

What data structure would efficiently store integer ranges?

I need to keep a collection on integers in the range 0 to 65535 so that I can quickly do the following: Insert a new integer Insert a range of contiguous integers Remove an integer Remove all integers below an integer Test if an integer is…
WilliamKF
  • 427
  • 1
  • 7
  • 14
12
votes
2 answers

How is conditional jump implemented in the CPU?

After reading the question I'm still not sure how CPU does branching. I understand that we have an instruction counter which points to the current instruction. And after performing conditional jump it either stays the same (increments as usual) or…
LNK
  • 239
  • 2
  • 5
12
votes
1 answer

Counting number of sums from contiguous subarrays of an array

We are given an array $a[1 \ldots n]$ with all $a[i]>0$. Now we need to find how many distinct sums can be formed from its subarrays (where a subarray is a contiguous range of the array, i.e., $a[j\ldots k]$ for some $j,k$, the sum is the sum of all…
Salena
  • 253
  • 2
  • 7
12
votes
1 answer

Is there a simple argument why graph isomorphism is not NP-complete?

I need to provide one simple evidence that graph isomorphism (GI) is not NP-complete. I saw a number of papers on google scholar and answers on StackExchange. However, I have very limited knowledge of graph isomorphism, and I would like to just…
user60472
  • 131
  • 7
12
votes
1 answer

Monad in Haskell programming vs. Monad in category theory

I have a question about concept of monad used in Haskell programming and category theory in math. Recall in Haskell a monad consists of following components: A type constructor that defines for each underlying type how the corresponding monad type…
12
votes
3 answers

Why is the inverted index called so and not simply index?

In my notes is represented like this: From wikipedia: In computer science, an inverted index (also referred to as a postings file or inverted file) is a database index storing a mapping from content, such as words or numbers, to its locations in a…
Gerardo Zinno
  • 281
  • 3
  • 13
12
votes
1 answer

Are NP problems lower bounded by exponential order of growth?

My understanding of P. vs NP is quite limited. I can understand P refers to an algorithm with an upper bound (big O) with order of growth $n^c$ for some constant c and variable n. My question is, do NP problems have a hypothesized lower bound order…
user4779
  • 371
  • 2
  • 12