Most Popular

1500 questions
13
votes
2 answers

Can the "divide" step in a merge sort be avoided?

So merge sort is a divide and conquer algorithm. While I was looking at the above diagram, I was thinking if it was possible to basically bypass all the divide steps. If you iterated over the original array while jumping by two, you could get the…
Jimmy_Rustle
  • 245
  • 3
  • 6
13
votes
3 answers

Easy proof for context-free languages being closed under cyclic shift

The cyclic shift (also called rotation or conjugation) of a language $L$ is defined as $\{ yx \mid xy \in L \}$. According to wikipedia (and here) the context-free languages are closed under this operation, with references to papers from Oshiba and…
Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109
13
votes
2 answers

Importance of recursion in computability theory

It is said that computability theory is also called recursion theory. Why is it called like that? Why recursion has this much importance?
user5507
  • 2,251
  • 4
  • 25
  • 41
13
votes
3 answers

Proving P = NP without mathematical statements / computer program

This is my first post after being a passive user for some time now. I wish to ask some questions if I may. I am not a mathematician but my question relates to the field of maths/computer science. In particular, the P vs NP problem. I am aware…
user5287
13
votes
1 answer

Random Access Machines with only addition, multiplication, equality

The literature is fairly clear that unit-cost RAMs with primitive multiplication are unreasonable, in that they cannot be simulated by Turing machines in polynomial time can solve PSPACE-complete problems in polynomial time However, all of the…
13
votes
7 answers

How to check if two strings are permutations of each other using O(1) additional space?

Given two strings how can you check if they are a permutation of each other using O(1) space? Modifying the strings is not allowed in any way. Note: O(1) space in relation to both the string length AND the size of the alphabet.
Teodor Dyakov
  • 1,341
  • 1
  • 13
  • 22
13
votes
3 answers

Discrepancy between heads and tails

Consider a sequence of $n$ flips of an unbiased coin. Let $H_i$ denote the absolute value of the excess of the number of heads over tails seen in the first $i$ flips. Define $H=\text{max}_i H_i$. Show that $E[H_i]=\Theta ( \sqrt{i} )$ and…
Plummer
  • 443
  • 2
  • 7
13
votes
3 answers

Optimal strategy for an abstract game

I've been given the following problem in an interview (that I've already failed to solve, not trying to cheat my way past): The game starts with a positive integer number $A_0$. (E.g. $A_0 = 1234$.) This number is converted to binary representation,…
millimoose
  • 233
  • 2
  • 6
13
votes
2 answers

Counting permutations whose elements are not exactly their index ± M

I was recently asked this problem in an algorithmic interview and failed to solve it. Given two values N and M, you have to count the number of permutations of length N (using numbers from 1 to N) such that the absolute difference between any…
Gena
  • 151
  • 4
13
votes
3 answers

How does 0 have two values in one's complement?

It is said that in 2's complement 0 has only one value, while in 1's complement both +0 and -0 have separate values. What are they?
user136782
  • 233
  • 1
  • 2
  • 5
13
votes
1 answer

Finding optimal sequence of questions to minimize total student time

Suppose there is a tutorial session at a university. We have a set of $k$ questions $Q = \{ q_1 \ldots q_k \}$ and a set of $n$ students $S = \{ s_1 \ldots s_n \}$. Each student has a doubt in a certain subset of questions, i.e. for each student…
skankhunt42
  • 517
  • 2
  • 13
13
votes
2 answers

Decidable restrictions of the Post Correspondence Problem

The Post Correspondence Problem (PCP) is undecidable. The bounded version of the PCP is $\mathrm{NP}$-complete and the marked version of the PCP (the words of one of the two lists are required to differ in the first letter) is in $\mathrm{PSPACE}$…
Vor
  • 12,743
  • 1
  • 31
  • 62
13
votes
2 answers

Matrix chain multiplication and exponentiation

If I have two matrices $A$ and $B$, of dimensions $1000\times2$ and $2\times1000$, respectively, and want to compute $(AB)^{5000}$, it's more efficient to first rewrite the expression as $A(BA)^{4999}B$ and only then evaluate numerically, because…
isekaijin
  • 405
  • 2
  • 9
13
votes
1 answer

Gödelization in Turing Machine

I was looking at Gödelization in Theory of Computation course. I could understand the Gödel numbering concepts, but couldn't understand its importance in Theory of Computation. Could anyone please point to some good materials or point out its…
user5507
  • 2,251
  • 4
  • 25
  • 41
13
votes
1 answer

Algorithms with O(sqrt(N)) SPACE complexity?

Are there any known algorithms for formulated problems that require a SPACE complexity of O(sqrt(N))? I know that algorithms with that big-O time complexity exist.