instruction
stringlengths
35
29.1k
I built a recursion tree like this: 0 / \ 0 0 /\ /\ ... ... So the tree has height n, and width $2^n$. But if the sum of all levels is $\sum_{i=0}^{n}0$, then is the function simply $O(1)$?
:) Currently I am browsing through the internet on the hunt for a topic for my bachelors thesis. Whilst being on Reddit I discovered an interesting repo (https://github.com/mxgmn/MarkovJunior) for a probabilistic PL that uses markovs algorithm(https://en.wikipedia.org/wiki/Markov_algorithm?wprov=sfti1) for some awesome...
I'm trying to figure out whether the following problem is R.E.? Given a turing machine $M$ with alphabet $\Sigma$ is it the case that: $L(M) = \{w \in \Sigma^* | |w| \space is \space prime\}$ I think I have a reduction from $HALT$ complement which is co - R.E. to the problem proving that it's not R.E. but I'm not entir...
Note this question was originally asked on Theoretical CS Stack Exchange, but it is not a research level question so it is being closed, and I am asking here instead. Suppose we simulated a Turing machine on a long string $s$, where $|s| = 10^{100}$ for example. Then if we wanted to learn the value of $s_i$, the $i$th...
I do not know with which technique i can prove if a LTL forumula is valid. Let's say we have for example this one: ¬q U(¬p ∧ ¬q) → ¬Gp. How can prove if this valid or not? (should be true in any state of any model).
I've been asked to list the frontier steps for greedy best-first search for the graph in the picture below. I've attempted to recreate the algorithm in Golang, as shown below: // Do takes a source (starting point), a target (endpoint) func (g *GreedySearch[T]) Do(source, target *node.NodeWithCost[T]) []T { path := ...
Looking at the image above, thinking in terms of A* search. I don't fully understand the heuristic function. The cost makes sense, so thinking in terms of a traditional map or navigation scenario. I'd see the heuristic function here as the number of direct steps. Or the number of cities we pass through, for example. T...
Could someone please help me check if my automaton is correctly designed? $$L = \{ 0^i1^j2^{i+j} | i \ge 0, j \ge 0, i+j > 0 \}$$ This was an exercise from our workbook, but their solution is a bit different
I read two definitions of cluster graphs that seem in conflict to me. One is from Koller: We begin by defining a cluster graph — a data structure that provides a graphical flowchart of the factor-manipulation process. Each node in the cluster graph is a cluster, which is associated with a subset of variables; the grap...
We know that A read-only Turing machine or Two-way deterministic finite-state automaton (2DFA)is class of models of computability that behave like a standard Turing machine and can move in both directions across input, except cannot write to its input tape. The machine in its bare form is equivalent to a Deterministic ...
The problem: in 2d, given a line and an unordered set of $N$ points with real coordinates, find the intersection between the line and the convex hull of the points. Clearly, one can explicitly construct the convex hull and find the answer in $O(N \log N)$. Is there a faster approach? Is there a superlinear lower bound ...
Imagine a machine that can only hold N-bit values (N-bit uint). The machine can also calculate the 2N-bit result of two operations: mult, exp. The 2N-bit result is stored across 2 N-bit values (high/low bits). How could we then code the mult (or exp) of 2 2N-bit values that would result in a 4N-bit value? The 2 2N-bit ...
someone sent me a question lately and I wasn't able to solve it so I'm asking for help. Question: Given the language $$L=\{w\in\{0,1\}^*:|w| \text{ is even and the first half of it has a balanced string of length } 100\}$$ Balanced: A string $w\in\{0,1\}^*$ is said to balanced if it has the same number of $0$'s and $1$...
I've found two slightly different Bellman Equations. Are they totally equivalent? I see the one on the bottom has an s' in the reward. Does this or anything else about the groupings change anything fundamental about the equation? I'm not totally math literate so I'm not sure which max a we are taking. Is it just the ac...
In my understanding, if we could prove one of the NP-complete problems is a P problem, then all of the NP problems are P problems. Because P problems are NP problems and NP problems are P problems, P=NP. I thought if P=NP, then all NP-complete problems are also P problems, but not all P problems are NP-complete. But it...
This algorithm solves the Two-Sum problem$^1$ assuming that the input array/list is sorted. class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: N = len(nums) l, r = 0, N-1 while l < r: comp = target - nums[l] r = bisect_left(nums, comp, lo=l+1...
Ok so I'm learning Finite Automata in my Theory of Computation course and understand the basic FSM but can't wrap my head around this question: The AC should only turn on if a person is detected in the room and the temperature is hot (80 degrees or higher). It turns off when no one is detected in the room, the window i...
I'm looking for an algorithm that finds a simple path from S to T in a directed graph (which might have cycles) so that the product of edge weights in the path is maximum. All the edge weights of the graph are larger than zero. For any pair of nodes, there might be more than 1 edge. I thought of the following approach....
$L = \{a^nb^m | n \le m \le 3n \} $ This is by far the hardest pushdown automaton I had to design. I literally have no idea where to start. Here's my thought process. Firstly, I thought that for each valid pair $(n,m)$ the differences between the number of $b$s abd $a$s will be the same. That wasn't true, as the number...
A bipartite graph corresponds to a rectangle of ones in the adjacency matrix of this graph. Having a sparse graph, I would like to find the largest approximated bipartite graph. approximated means that some edges not in the sparse graph will be in the bipartite graph. I think this problem can be reformulated in: Given ...
I reached a subproblem where I have an array of numbers (0 to n) un-sorted and I want to retrieve, for each element, the index of the farthest value from it to the RIGHT of that element. Like 0 1 2 3 4 5 6 7 8 (indexes) 0 3 7 5 4 2 8 1 6 (array) so the answer would be 6 6 7 7 6 6 7 8 -1 Can anyone suggest some algori...
Splaying trees are a heavily researched of theoretical computer science as they are conjectured to be optimal binary trees. They were first presented by Sleator & Tarjan in Self-Adjusting Binary Search Trees. In their paper, on pages 19-20, they propose to reduce the number of operations needed for a splay, by only doi...
Is there an NFA with n states so that the DFA resulting from the standard conversion of the NFA to a DFA has at least $2^n - \alpha$ reachable states for some integer $\alpha \ge 1$? Let $N= (Q, \Sigma, \mu, q_0, F)$ be the NFA. Construct a DFA $M = (Q',\Sigma, \delta, q, F')$ as follows: $Q' = \mathcal{P}(Q), F' = \...
$L= \{ a^nb^m | n \le m \le 2n \}$ As you may recall, I posted a question a few hours ago about designing a PDA for a language similar to the one I have now. I have seen that the easiest way to construct it is to define a CFG for the language, and then transform it to non-deterministic PDA which accepts strings by empt...
By "physical means", I mean, for example, using water pouring down tubes, or combining chemicals, etc. Basically, using some experiment in the physical world to perform some computation. I'll call this physical computation. As the simplest example, if I want to add the numbers 3 and 5, I could just pour 3mL into a cup ...
I am trying to find the Gesalt similarity of a string $S$ and all substrings of $T$ using Gestalt Pattern Matching (Ratcliff Obershelp Algorithm) This algorithm requires me to find the matches of S and T which is defined as follows $$ matches(S,T) = \begin{cases} matches(S1,T1) + [LCS(S,T)] + matches(S1,T2)&\text{if } ...
The "classical" partition problem asks whether a given multiset $S$ of positive integers can be partitioned into two subsets $S_1$ and $S_2$ such that the sum of the numbers in $S_1$ equals the sum of the numbers in $S_2$. The problem is known to be NP-hard. I want to know if a similar problem is also NP-hard (I believ...
Suppose that I have proof tree starting with some statement |- B in a sequent calculus, leading to two premises/leafs |- A. Is it always possible to transform such a proof tree into another proof tree, which only contains one leaf |- A only using standard rules of natural deduction? More schematically I want to perform...
In "OpenGL superbible" 4th Edition by RICHARD S.WRIGHT JR page 60, there's this piece of code that confuses me: // Reset coordinate system glMatrixMode(GL_PROJECTION); glLoadIdentity() aspectRatio = (GLfloat)w / (GLfloat)h; if (w <= h) glOrtho (-100.0, 100.0, -100 / aspectRatio...
I have a doubt on my solution of the following: Formalize the language of a Turing machine that takes a Turing machine "M" and a character "a" as input, the language recognizes all and only the Turing machines that write "a" on the tape for every possible input w prove that this language is undecidable. Formalization: ...
To show that any formal language is NP Complete first it must be showed that this formal language is both in NP and NP Hard. So to show that Horn Satisfiability is NP Complete first it must be showed that Horn Satisfiability is both in NP and NP Hard. Horn Satisfiability is definitely in NP because Horn Satisfiability ...
Are all np-complete problems also np-hard? In other words, is np-complete a subset of np-hard? I don't think it is entirely clear from the illsutration below, so I just wanted to quickly ask to ask to be completely sure. The np-hard area also includes the np-complete section right? Just a quick "yes" or "no" is all I ...
Suppose we have a dataframe with ~10M rows with ~9M duplicate records. What is the most time efficient way of selecting the unique records from this dataframe? Some sort of sampling algorithm?
I'm reading the DFS section of CLRS-Introduction to Algorithms, and confuse on the $\Leftarrow$ direction of the proof of the white-path theorem of DFS algorithm in this book. Note that each node u in the graph has 2 timestamps: $u.d$ records when u is discovered and $u.f$ records when the search finishes examining u’s...
I was reading this paper, and the author (in private correspondence, though I'm sure it's also in the paper) explains that a bit string generated through Solomonoff induction will have growing (and unbounded) Kolmogorov complexity. This sounds counterintuitive to me: Solomonoff induction tends to favor bit strings that...
I need to calculate the LR(1) items of the following grammar: S -> E E -> E + T E -> T T -> ID T -> ( E ) I can not even calculate the first group {[S -> .E, $]} correctly, I read and tried to run the algorithm and did not understand why the correct answer for state 0 should be the group of items: {[S -> .E, $]; [E -...
I'm having trouble figuring out why using XOR for this problem works; I've done it a couple of times by-hand, and can't really seem to understand it. I know that XOR is commutative and associative, which is why it's good for finding (missing) duplicated numbers in a list. But applying that to the following problem does...
I'm doing an implementation of the traveling salesman problem using genetic algorithms, but I can't get it: If we need to get the best route in a certain set of cities and then go back to the first city, how can we do that without going through cities we've already been through again? What would this route look like? I...
I'm unsure as to the amount of operations in Dijkstra's shortest path in terms of $|V|$ and $|E|$. My guess is that there are (worst case - complete graph): $$|V| + \sum^{|V|}_{i=1}{(|V|-i)} = \frac{|V| \cdot (|V| + 1)}{2} \implies O(|V|^2)$$ operations for a graph $G = (V, E)$, assuming there are no negative cycles. ...
Prove that if $C$ and $D$ are context-free languages, then so is $C\circ D := \cup_{n\ge 0} C^n D C^n $. I know that $\{0^n 1 0^n : n\ge 0\}$ is context free, being the intersection of $L(0^* 10^*)$ and $L(G)$, where $G$ is the context free grammar with start symbol S given by $S\mapsto S1 S | 0S | \epsilon$. Also, I...
It is a well known fact that the following 'subset-product' problem is $\mathsf{NP}$-complete when $n/\log M \in \Theta(1)$. Consider a size-$n$ subset of a multiplicative group $\mathbb{G}\cong\mathbb{Z}^{*}_M$. Then an instance of the subset-product problem consists of $(a_1, a_2,\dots,a_n, t)$ with each $a_i, t\in ...
I have a 2D array of some rows and columns which are having only 0's and 1's. I would want to know if there is a way to optimize the number of rows so that maximum number of columns have their column sum greater than a threshold (this is known). In the end, I should be able to get the rows which should be considered to...
To prove PSAPCE = NP we will show following inclusions : NP $\subseteq$ PSPACE : If every NP-hard language is PSPACE-hard then SAT is also PSPACE-hard. Since every language in PSPACE can be reduced polynomially to PSPACE-hard implies SAT $\in$ PSPACE. SAT $\in$ PSPACE. If L $\leq_{P}$ B and B $\in$ PSPACE $\implies$ ...
I am not a Regular Experssion expert, but my request is simple: I need to match any string that has at least 3 characters of B and at most 2 characters of A so for example: "ABABBB" => Accepted "ABBBBBB" => Accepted "BBB" => Accepted "ABB" => Rejected "AABB" => Rejected "AA" => Rejected
To those of you who saw my post from an hour ago - I deleted it because I came up with an idea. To summarize, I have to design a PDA for this language, without using the usual method of firstly defining a CFG then transforming it to a PDA. $ L = \{ a^{3n}b^{2n} | n \ge 0 \}$ Here is my proposed solution: Since I didn'...
In the Silberschatz's book "operating systems" the author talks about the allocation of memory via system buddy and slab. My first question is: in the book, both memory allocation methods are described as allocation method that the kernel use to allocate memory only for kernel's process, not for user's process. Is it t...
I'm trying to understand IEEE 754 floating point. when I try convert 0.3 from decimal to binary with online calculator, it said the significand value was 1.2 Where 1.2 come from? I did understand another bits like exponent and sign bit. .3 if converted to binary it will be .3 * 2 = .6 + 0 .6 * 2 = .2 + 1 .2 * 2 = .4 + ...
The Wikipedia explanation is clear to convert unsigned integer binary format into Binary Coded Decimal. The double-dabble algorithm is trying separate binary digit to BCD for example: Given 4-bit input 1101 (13 in decimal) will produce 0001 0011 The input from example clearly is unsigned integer, but how about IEEE754 ...
I got an exercise about a variation of RB trees but I am struggling to see how to solve it, therefore I'll be happy to hear your opinion about it. The exercise is: Let us define a binary search tree which we will call Red-Red-Black tree if it satisfies the following: Every node is either red or black. Every leaf (NIL...
Show that P and NP are closed under Kleene star. I found possible solutions to these problems, more specifically: P - finding all subwords from a giving word and looking if there is a connection between them (idea: https://louis.jachiet.com/lfcc/final_solutions.pdf) NP - non-deterministically dividing word for m subwo...
Let $C$ be a regular language. Prove that the language $D = \{x x^R : x\in C\}$ is context-free. It's clearly important that $C$ is regular; if the hypothesis were weakened to C being context-free, then we would have the counterexample $C = \{0^n 1^n : n\ge 0\}, D = \{0^n 1^{2n} 0^n:n\ge0\},$ which isn't context-free...
Let $A$ be an array of numbers. Let $y$ be positive. We want to find two numbers $A[i]$ and $A[j]$ such that their absolute difference is at most $y$.
In articles or Quora posts about category theory, I often find mentions of the programming language Haskell. I have little knowledge of category theory and even less of programming. Could someone please explain how category theory is important in Haskell?
I wonder if we take the current state of our machine as input, is it possible to generate a function to estimate the future state? Of course I mean like we get the 10 minutes after status within 1 minute of computing. Is it a possible things? If not, then why is it impossible? I know it's quite a weird question. : ) Th...
I have found that a problem that I'm analyzing is equivalent to the following variant of the Exact Cover problem: Partition into $k$ Exact Covers Input: A universe $U$ and a family $C\subseteq 2^U$ of subsets of $U$ in which each element $x\in U$ occurs in exactly $k$ subsets of $C$. Question: Can the family $C$ be pa...
I am trying to solve T(n) = 4*T(n/4) + n*[log(n)]^2 I decided to use Master Theorem so I found a,b=4 and logb(a)=1. I thought that 3rd case is the solution but I don't know actually how to solve this. Any help appreciated. Thanks in advance !
Task: Input: DFA $M = (Z, Σ, δ, q_S, E)$ $T(M)$ := Language that $M$ accepts. Question: Does $T(M)$ contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$ My attempt: Since the language $\{w\in Σ^* \mid |w| = n^2 \} $is not regular. You cannot create DFA $M'$ which accepts this language and use...
Assuming we have a DAG, $G = (V, E)$, and we know that we can calculate $G$'s transitive closure in time complexity of $f(|V|, |E|)$, whereas $f$ is monotonic increasing function. Show that given a directed graph (not necessarily DAG) $G^{'}$, we can calculate it's transitive closure, $G^{+}=(V, E^{+})$, in time comple...
Given a list of positive integers with sum $s$, decide if there is a subset with sum $0.5s$. This is the well-known PARTITION problem, which is NP-hard. What about the following: Given a list of positive integers with sum $s$, decide if there is a subset with sum in the range $[0.49s, 0.51s]$. Can this problem be solve...
Is there any cellular automaton on the Eisenstein integers? By this I mean that the triangles formed by the Eisenstein integers are considered as cells and each triangle has three neighbours plus itself. I programmed in python such a cellular automaton and am curious what properties it has. git: https://gist.github.com...
Is there a notation for statements like the following: If both operands are of type int, then the result is of type int. If either operand is of type float, then the result is of type float. e.g. for the first case, can I say something like: $$int \ \text{op} \ int \rightarrow int$$ where $\text{op}$ is an operator w...
Problem: In this problem, we discuss Data-Structures that maintain a group of ordered elements. We must support the operations $ DecreaseKey, FindMin, Insert $ in time $ O(1) $ and the operation $ DeleteMin $ in time $ O(\log n) $. All the time-complexities are Amortized. We'll remind that so far, Fibonacci Heaps answe...
The latest development in solving the max-flow problem promises a ${\displaystyle O(E^{1+o(1)}\log U)}$ solution. What does it mean, this $O(n^{1+o(1)})$-complexity?
We say that if an algorithm takes p time for an input size of n (here, p is a polynomial in n, and the degree of p is y), then the algorithm's complexity is O(n^y). In the image, when n is very large it does not seem to matter much if it's x^2 or 2x^2. but, it clearly seems to matter if it's x or 2x. So, then why do we...
I have a straightforward task that can be done in $O(n^2)$ time. I'm now wondering if the task can be done in time $O(n^{2-\epsilon})$ if we are allowed to do some pre-processing. The problem exists of two steps. In the first (preprocessing) step, we are given an $n \times n$ array $A_{i,j}$: $n$ permutations of the nu...
Prove that the following language is context-free by giving a context-free grammar that generates the language: $A = \{a \in \{0,1\}^* : \text{ no character in an even position is a 0 or no character in an odd position is a 1}\}$, where the first position is position 1. For instance, $01110, 01010$ are both in $A.$ I...
I was looking for implementations of counting sort and most of them are implemented with cumulative counts like this: public void SortArray1(int[] nums) { var output = new int[nums.Length]; var count = new int[nums.Max() + 1]; foreach (var num in nums) count[num]++; for...
I am trying to solve one of the sample test problems in which I have to write an expression/pattern for the following language: $\{w \in \{0, 1, 2\}^*: {\#}_{0}(w) ∗ {\#}_{1}(w) \text{ is even}\}$ I was thinking about the approach of getting all strings with even number of 0s and 1s first and then make a complement of...
So, I have been looking into the famous back tracking problem called N Queens. The problem is essentially finding the number of possible ways you can place a n number of queens on a n x n chess board such that all of the queens are not in any other attack positions from other queens on the board. I came across the foll...
If I have a CFL, can I define a regular substitution to make it a RL? For example, if I have the language $\{a^nb^n \mid n\ge0\}:$ Define $h(a)=a$ , $h(b)=b$, then $h(L)={a^*}$ , am I right? Thanks!
Recently, I had to implement the following algorithm (similarly). Code in Kotlin: fun solution(keyword: String, lyric: String): Boolean { val lyricWords = music.split(" ") var index = 0 for (word in lyricWords) { for (c in word) { if (c == keyword[index]) { i...
How can i derive this Hoare Tripel? {false} x := x + 1; {x = 0} I do not know which rule should i use on this. I am confused on this wrong precondition.
I'm trying to solve the following exercise: Given this is true: \begin{align} \neg \forall x \space \ \exists y \ ( x\neq y \rightarrow LeftOf(x,y) )\end{align} Demonstrate : \begin{align} \exists y \ \forall x (x = y \ \ \lor \ \ RightOf(y,x) ) \end{align} With LeftOf and RightOf defined as: \begin{align}I(LeftOf) = ...
I work in the Computer Graphics field, and I have a problem where I need to find the optimal solution for, but I'm not sure how to best formulate the problem mathematically, how to define the objective function, and finally - how best to find that optimal solution. My problem is as follows: I have a 3D scene, and in it...
Let me cross post my question from math.stackexchange, since I feel this community is more related to the field. Title is self explanatory. I want to know is the language $L = \{xcy \,| \,x,y\in \{a,b,c\}^\star, |x|_a = |y|_b \}$ is context-free. I tried to prove that is not context-free using a proof by contradiction....
Say I want to solve a set of problems. I know that I can map my problem as a problem that is known to be hard in the general case (say, inference in Bayesian networks). But my set only contains instances which will map to easy instances - (say, having a tree-structure when cast to a BN inference problem) I know BNs wit...
I saw this image only, and it got me thinking: is this the maximum area difference between a contiguous region and Los Angeles County, such that the population of that region is smaller? Formally, given a graph with nodes $i$ from $0$ to $n$, where $i = (p_i, a_i)$, with $p_i$ represent its population and $a_i$ its are...
Does there exist a general approach in mainstream academia for representing a deterministic infinite automata? Unlike the finite kind, this one with infinite number of states. Although there is infinite state. There is a finite number of types of states. E.g. state $inBrackets_k$ goes to state has an edge leading to $i...
This started with me trying to make a regex to accept Bitcoin addresses. However, I couldn't do it. That led me to think: "is the set of all possible Bitcoin addresses even a regular language"? For simplicity, consider only "legacy" P2PKH Bitcoin addresses: a valid address consists of the character "1" followed by 25 t...
I understand the basics of the 0-1 problem and its solution. I have a variant of it that I'm trying to solve in a decent way and I'm struggling on it, mostly because of the 0-weighted items. These are the rules: I have k finite sets of items. Each item has a weight and a value. I must take exactly one item from each s...
The IEEE 754 standard for floating point numbers defines a flag that is set when a result from floating point calculation isn't exact, i.e. has to be rounded. What algorithms are there that utilize that information?
I'm following an online course about Complexity and I'm learning a lot of stuff. I came across a particular exercise and I'm unable to find it out by myself, this is why I'm writing this message here. The exercise is to prove the following is true: $4\ \sqrt{n} + 2\ n\log_2(n) + 3 = \mathcal{O}(n\log(n))$ So basically ...
I want to prove that, $$ \log n! \in O(n \log n) \land \log n! \in \Omega(n \log n)$$ The straightforward approach is to apply Stirling's formula but I am looking for a different path to follow. Can somebody please guide me towards it?
relatively new to Computer Vision. Lets say for example, I have a sequence of images of a car driving away from a static camera into the horizon, and I want to use this image set for some bog standard computer vision experimentation (e.g to train a CNN to recognize a car). I label the car in each frame with a rectangul...
I'm working my way through parts of Russell and Norvig's AIMA book for a class, and there's something I've never quite managed to wrap my head around. Chapters 3 and 4 contrast 'search' methods with 'local search' optimization methods, suggesting to me that there is some kind of fundamental difference between the two. ...
Can you help me find the theta complexity for lg(n^(1/2))?
Let $L$ be a regular language. Define: $half(L)=\{x|xy\in L,|x|=|y|\}$ Prove that $half(L)$ is regular as well. I have seen a hard proof by using the DFA A of L, building a NFA B (such that every transition from the stating state to the next one with the word $x$ will exist iff $\exists y$ s.t $|x|=|y| , \delta_A(q,y)\...
I saw a question on an old exam in my university course of DSA and I am not sure if the question is far too easy or if I am missing something. The question is : Given an array A that consists of N integers such that for any $1 < i \leq N$ the following properties holds : $| A[i] - A[i-1] | \leq 1$ $ A[N] > A[1] $ G...
What is the difference between time complexity of SLR(k) and SLR(1)? and also what about LALR(k) and LALR(1)? How can I calculate time complexity of parsers? I think time complexity of LR(k) is O(n) but I'm not sure there is a relation between LR(k) and SLR(k) or LALR(k)!
Prove/disprove the following claim: If $L\in RL$ then $\{x~|~\exists y ~~s.t~~ xyx^R \in L\} \in RL$ I think that this is true, and my intuition is by using $L_{pq}$ s.t: For every $(p,q)\in Q\times Q$ define $L_{pq}=\{w|\delta'(p,w)=q\}$. Then by using $L_{pq}○L_{q,q'}○(L_{pq})^R$ and taking the union of all possible ...
I have to find a CFG for the given expression: $L = \{a^wb^xc^yd^z | w + x = y + z\}$ This is what I've tried so far: S -> aSd | B | ϵ B -> bBc | ϵ It works for expressions like: aabcdd, abbbcccd However, using my grammar I wouldn'd be able to generate strings like: aaaacddd, abbddd, which, I assume, the language L sh...
The question is: There are 219 matches on a table and 2 players , each player can take 1,3 or 4 matches off the table , winner is who takes the last match. is there a winning strategy that guarantees for the second player to always win? . I can't think of a way to calculate without having to do the recursion myself , n...
I am solving basic questions about Recursive and Recursively-Enumerable languages. I know that base on the below theorem, to prove that a language is RE we should define an Enumeration Procedure for it. A language is recursively enumerable if and only if there is an enumeration procedure for it. And for the below que...
Suppose o is a map on strings to strings. For every language R, we let $o(R) := \{o(x) : x \in R\}$. If o(R) is a regular language for every regular language R, then prove or disprove that the language $\{xc o(x) :x \in A\}$ is context-free, where A is a regular language and c is a symbol not in the alphabet of A, $\S...
Suppose $x$ is Godel's number of some formula. Predicate $\operatorname{P}(\operatorname{f}(x))$ is true only when the number of functions is equal to the number of predicates in that formula. Prove that $\operatorname{P}(\operatorname{f}(x))$ is primitive recursive. My Godel Numbering system is $$G(\forall)=1$$ $$G(()...
Consider a DFA $A$ and $k\geq 0$. For states $q$ and $p$ of $A$, we say that $p\equiv_k q$ when $p$ and $q$ agree on all words of length at most $k$; that is, $p\equiv_k q$ when for all words $w$ of length at most $k$, it holds that $p$ has an accepting run on $w$ iff $q$ has an accepting run on $w$. Then, we say that ...
Let $w$ and $x$ be two binary strings. Show that the Hamming distance of $wx$ and $xw$ cannot be 1. I think one approach is a proof by contradiction. I was thinking of explicitly writing out $w = w_1\cdots w_k$ and $x = x_1\cdots x_n$, and proceeding with a case-based argument. Let $i$ be the unique index where the s...
For two equal-length binary strings $x$ and $y$, let $d(x,y)$ denote the Hamming distance. Prove or disprove: there exists a positive integer $k$ such that the language $\{x2y : |x| = |y|, x\in A, y\in\{0,1\}^*,d(x,y) = k\}$ is context-free for some infinite regular language $A$ over the alphabet $\{0,1\}$.   I think...
Is there a non-context free language A over the alphabet $\{0,1\}$ such that $A1 := \{a1 : a\in A\}$ is context free? I was thinking of the language $A = \{0^n 1^{n-1} : n > 0\}.$ Unfortunately, this language is context-free. I’m not sure if one might be able to show that context-free languages are closed under the o...
I am studying the book "Parametrized Algorithms" and it suggests a bounded search tree algorithm for k-Vertex Cover. Basically we look at a vertex v and say : Either v will cover it's incident edges or it has to be it's neighbors $N(V)$ so either $v$ or $N(v)$ will end up in the cover. That's 2 choices , we build a tre...