Most Popular

1500 questions
38
votes
4 answers

Generalised 3SUM (k-SUM) problem?

The 3SUM problem tries to identify 3 integers $a,b,c$ from a set $S$ of size $n$ such that $a + b + c = 0$. It is conjectured that there is not better solution than quadratic, i.e. $\mathcal{o}(n^2)$. Or to put it differently: $\mathcal{o}(n \log(n)…
bitmask
  • 1,755
  • 2
  • 16
  • 20
38
votes
5 answers

How can I verify a solution to Travelling Salesman Problem in polynomial time?

So, TSP (Travelling salesman problem) decision problem is NP complete. But I do not understand how I can verify that a given solution to TSP is in fact optimal in polynomial time, given that there is no way to find the optimal solution in polynomial…
Lazer
  • 1,077
  • 2
  • 10
  • 8
38
votes
7 answers

Does an Operating System inject its own machine code when you open a program?

I'm studying CPU's and I know how it reads a program from the memory and execute its instructions. I also understand that an OS separates programs in processes, and then alternate between each one so fast that you think that they're running at the…
Revering Sumoda
  • 457
  • 6
  • 8
38
votes
2 answers

Hash tables versus binary trees

When implementing a dictionary ('I want to look up customer data by their customer IDs'), the typical data structures used are hash tables and binary search trees. I know for instance that the C++ STL library implements dictionaries (they call them…
Alex ten Brink
  • 9,066
  • 3
  • 35
  • 63
38
votes
2 answers

Is there a difference between top-down and bottom-up dynamic programming?

Is there a fundamental difference between top-down and bottom-up dynamic programming? In particular, is there a problem which can be solved bottom-up but not top-down? Or is the bottom-up approach just an unwinding of the recurrence in the top-down…
user695652
  • 783
  • 1
  • 5
  • 14
38
votes
1 answer

Is it NP-hard to fill up bins with minimum moves?

There are $n$ bins and $m$ type of balls. The $i$th bin has labels $a_{i,j}$ for $1\leq j\leq m$, it is the expected number of balls of type $j$. You start with $b_j$ balls of type $j$. Each ball of type $j$ has weight $w_j$, and want to put the…
Chao Xu
  • 3,083
  • 17
  • 34
38
votes
2 answers

How do I construct reductions between problems to prove a problem is NP-complete?

I am taking a complexity course and I am having trouble with coming up with reductions between NPC problems. How can I find reductions between problems? Is there a general trick that I can use? How should I approach a problem that asks me to prove a…
Anonymous
  • 381
  • 1
  • 4
  • 3
38
votes
4 answers

How to measure "sortedness"

I'm wondering if there is a standard way of measuring the "sortedness" of an array? Would an array which has the median number of possible inversions be considered maximally unsorted? By that I mean it's basically as far as possible from being…
Robert S. Barnes
  • 2,911
  • 5
  • 24
  • 24
37
votes
2 answers

Quantum lambda calculus

Classically, there are 3 popular ways to think about computation: Turing machine, circuits, and lambda-calculus (I use this as a catch all for most functional views). All 3 have been fruitful ways to think about different types of problems, and…
Artem Kaznatcheev
  • 4,862
  • 2
  • 27
  • 57
37
votes
4 answers

Would the P vs. NP problem become trivial as a result of the development of universal quantum computers?

If someone were to build a universal quantum computer, would that have any implications on the problem of P vs. NP?
Barte
  • 503
  • 1
  • 5
  • 6
37
votes
5 answers

Is there a known maximum for how much a string of 0's and 1's can be compressed?

A long time ago I read a newspaper article where a professor of some sort said that in the future we will be able to compress data to just two bits (or something like that). This is of course not correct (and it could be that my memory of what he…
x457812
  • 481
  • 4
  • 5
37
votes
2 answers

What does "context" in "context-free grammar" refer to?

There are lots of definitions online about what a Context-Free Grammar is, but nothing I find is satisfying my primary trouble: What context is it free of? To investigate, I Googled "context sensitive grammar" but I still failed to find what the…
CodyBugstein
  • 2,957
  • 10
  • 30
  • 45
37
votes
3 answers

Intro to Martin-Löf type theory

What would be the best introduction to Per Martin-Löfs ideas about type theory? I've looked at some lectures from the Oregon PL summer school, but I'm still sort of puzzled by the following question: What is a type? I know what a set is, since you…
dst
  • 373
  • 4
  • 4
36
votes
7 answers

Clear, intuitive derivation of the fixed-point combinator (Y combinator)?

The fixed-point combinator FIX (aka the Y combinator) in the (untyped) lambda calculus ($\lambda$) is defined as: FIX $\triangleq \lambda f.(\lambda x. f~(\lambda y. x~x~y))~(\lambda x. f~(\lambda y. x~x~y))$ I understand its purpose and I can trace…
BlueBomber
  • 1,297
  • 12
  • 15
36
votes
2 answers

Why is the log in the big-O of binary search not base 2?

I am new to understanding computer science algorithms. I understand the process of the binary search, but I am having a slight misunderstanding with its efficiency. In a size of $s = 2^n$ elements, it would take, on average, $n$ steps to find a…
Cyclopropane
  • 463
  • 1
  • 4
  • 7