Problem Detail: This grew out of a discussion of deliberately bad algorithms; credit to benneh on the xkcd forums for the pseudocode algorithm, which I’ve translated to Python so you can actually run it: def sort(list): if len(list) < 2: return Read More …
Author: ignougroup
[Solved]: Show that a regular language L contains only palindromes if and only if all words of length at most 3n are palindromes
Problem Detail: This is an extension of a previous question asked by a different user earlier: Let $x, u, v, w, y, x’, u’, v’, w’, y’$ be words satisfying $y’x’ = xy$. $y’u’x’ = xuy$. $y’v’x’ = xvy$. $y’w’x’ = Read More …
[Solved]: Fast implementation of basic addition algorithm
Problem Detail: Write code for a modified version of the Grade School addition algorithm that adds the integer one to an m-digit integer. Thus, this modified algorithm does not even need a second number being added. Design the algorithm to Read More …
[Solved]: Travelling with the most efficient path
Problem Detail: A friend of mine actually asked me a very interesting computer science related question, and I have been stuck on it for a long time. The problem is: you have to travel $1000$ km. The only gas station is Read More …
[Solved]: Proving that the language of TMs with finite left head moves is undecidable
Problem Detail: I’m trying to prove that the following language is undecidable:$$ { langle M, w rangle ~|~ M text{ is a TM where its head moves left a finite number of times on } w } $$ But I’m having Read More …
[Solved]: Are there languages generated by linear grammar which aren’t regular?
Problem Detail: Are there languages generated by linear grammer which aren’t regular? Asked By : Iancovici Answered By : Shaull Of course. Look at the first example on Wikipedia: $qquad S to aSb mid varepsilon$ is linear and generates ${a^nb^n mid n in Read More …
[Solved]: Is this language defined using twin primes regular?
Problem Detail: Let $qquad L = {a^n mid exists_{p geq n} p,, p+2 text{ are prime}}.$ Is $L$ regular? This question looked suspicious at the first glance and I’ve realized that it is connected with the twin prime conjecture. My problem Read More …
[Solved]: Why does merging two sorted arrays take 2N – 1 comparisons?
Problem Detail: A friend of mine asked me a question on how to prove that merging two sorted arrays requires at least 2N – 1 comparisons Prove that merging two sorted arrays of N items requires at least 2N-1 comparisons. /* Read More …
[Solved]: Number of possible programs in a language
Problem Detail: Is the number of possible programs usually finite or infinite? I’m playing with the idea of generating all possible programs for a language – is that even a finite number or must we be more specific, finite RAM etc? Read More …
[Solved]: Why do the swap step in Prim’s algorithm for minimum spanning trees?
Problem Detail: I was watching the video lecture from MIT on Prim’s algorithm for minimum spanning trees. Why do we need to do the swap step for proving the theorem that if we choose a set of vertices in minimum spanning Read More …