instruction
stringlengths
35
29.1k
Build a context-free grammar for the language: $L=\{\#x\#y\#\,\,;\,\,|x|=|y|\,\,\wedge\,\,x,y\in\{0,1\}^{*}\}$ over $\sum=\{0,1,\#\}$ How can I make sure that |x|=|y|?
Build a context-free grammar for the the complementary language of: $L=\{ww^{R}\,\,|\,\,w\in\{0,1\}^{*}\}$ I think $L^C$ is the set of all strings that are not palindromes, but I don't know how to start building the grammar. Attempt: S→ A | B A→ AAA | 0 | 1 B→ 0C1 | 1C0 | 0B0 | 1B1 C→ 00C | 01C | 10C | 11C | ε
Imagine that I have an algorithm written in C that is of, let's say, 10,000 characters in length. Such a program can be simulated on a turing machine (Wikipedia: Anything a real computer can compute, a Turing machine can also compute. For example: "A Turing machine can simulate any type of subroutine found in programmi...
There are several players at the end of the poker night with wins and losses, with zero sum. What is the optimal solution to settle the balance that minimize the total number of transactions (eg. if we consider a transaction as a venmo payment). name | balance (N means how much net win, negative means lost) A | -2...
Given 2 integer $M$ and $N$, a recursive modulo is $M \bmod (M \bmod (M \bmod ...(M \bmod N)$ until the result is 0. What is its time complexity? I guess that it's $O(log(M))$ but I can't prove it.
I have to prove whether a certain property is safety or liveliness. The property represents the absence of deadlock so I expected it to be a safety property from what I read online. The issue is that I seem to show that it is both, but this is impossible as the only property that is both safety and liveliness would be ...
In a database systems course, we have been presented with the following definition for third normal form (3NF): A relation $R$ is in 3NF means: a nontrivial dependency $A_1,\dots,A_n\to B_1,\dots B_m$ can hold in $R$ only if $\{A_1,\dots,A_n\}$ is a key (either minimal or super) in $R$ or for $1 \leq i \leq m$, each $...
The problem I am trying to solve is that there is an underlying undirected graph G = (V, E) with weights on the vertices, where the weight on vertex v is denoted by wv = d(v) (the degree of the vertex). My goal is to find a vertex cover set U (a set where for every e = (u, v), one of vertices u, v is in U) with the min...
In depth first search each vertex can be associated with a discovery time and a finish time. I am reading the following implementation of topological sort in terms of depth first search TOPOLOGICAL-SORT(G) 1 call DFS(G) to compute finish times for each vertex 2 as each vertex is finished, insert it to the front of a li...
I am working on a Sparse Autoencoder but Andrew NG's notes are hard to understand. My question is about the following equation: Loss Function. In sparse autoencoder, the goal is to inactive some nodes to obtain low-level features or more precise features. Now if you check Andrew NG's Notes on sparse autoencoder (avail...
Assume that I have designed an algorithm A, which runs two sub-methods: M1 and M2. M1 has a O($n$) expected time complexity. M2 has a O($n^2$) time complexity. Clearly A uses O($n + n^2$) = O($n^2$) time. Since $n^2$ > $n$, in terms of time complexity, should A be described as having an expected time complexity of O($n...
I am wondering, what is the top type, $\top$, in JavaScript? The diagrams at MDN make it look as if 'null' is a top type, but wikipedia's entry for top type indicate that it is Object in JS, which makes more sense. Am I misreading the MDN article?
i got this question in a theory of computation quiz "give pda for a^(n) b^(2n) c^(2n) d^(n)" i am arguing that there is no pda for that question but our ta says that we can push 5x to the stack then pop x each time we read a b or c or d. i am arguing that doesn't guarantee count because we might get only "d"s which one...
I'm currently studying virtualization and while looking at hypervisors I realized that bare metal hypervisors are quite similar to operating systems. So while from an application standpoint they are different, can an operating system theoretically be viewed as bare metal hypervisor?
The Kind programming language has a sufficiently powerful type system to support proving theorems like in Lean, Coq, Idris, or Agda. I've seen it said that Kind has an even more powerful type system that goes beyond what these other languages support. Since Kind is a work-in-progress, I've struggled to find documentat...
Problem statement We're given a directed simple acyclic graph with weighted vertices. Find an edge $e$ such that reversing it would create a strongly connected component (SCC) whose price is maximal. The price of an SCC is defined to be the sum of the weights of its vertices. In the example below, reversing an edge $(7...
What problems belong in NSPACE(n^2) and DSPACE(n^2) class? Examples?
As I understand, all modern CPUs perform register renaming: given a sequence of instructions to interpret, they check which registers these instructions use, detect patterns where a register's previous value is overwritten, and then map the instruction sequence so that each instruction's "architectural" register is map...
We have a set of people, and each person has a list of wished items (not unique, they could want multiple copies of each item). We have an inventory of items that we want to assign to the people. We want to maximize the number of people who receive all the items on their list. The inventory may not have enough items to...
In statistical computing, we often have linear models that involve computing multiple vector dot products, but there's a high amount of redundancy in the operations when you break them down. As an example, let X be the following 12x3 matrix: [[-1,-1,-1] ,[-1,-1,1] ,[-1,1,-1] ,[-1,1,1] ,[0,-1,-1] ,[0,-1,1] ,[0,1,-1] ,[0...
Knowing that $log(n!) = \theta(nlogn)$
Let $H=\left( E_0 ,E_1 ,E_2 , \ldots , E_d \right)$ be a $d$-dimensional full-hyper graph/complex. That is to say, if for some $i\in \left[d \right]$ the hyper-edge $e_j \in E_i$ than for any $i-1$-dimensional $e_k \subset e_j$: $e_k \in E_{i-1}$. The vertices are $E_0$, the hyper-edges between $2$ vertices are $E_1$, ...
(I haven't read any literature on this paradox nor am I good at formal proofs, so this is just my intuitive thoughts on the paradox.) If we assume the statement "This statement is false" as a function f() on a state machine M, where M has 2 states S0 and S1 representing false and true, we'd just be evaluating M.f() in ...
For any 2 strongly normalizing terms in the Simply Typed Lambda Calculus, s and t, is st also strongly normalizing? And why? I'm a bit confused as this is used in a proof regarding strong normalization and the typable lambda calculus, but I have not been able to show that this is the case. Any help would be much apprec...
I am interested in tight bounds for the Parallel Machine scheduling problem with a gang scheduling constraint. In the notation of Graham, Lawler, Lenstra and Rinnooy Kan, this might be called $Pm|\rm{gang}|C_{\rm{max}}$. There are $m$ identical machines, and $n$ jobs. Each job has both a processing time $p_j$, and a g...
Previously, I've asked a question about coinduction. That gave me a lot of useful high-level insights on what coinduction provides, and what are the usefulness of coinductive proofs. This question is about walking through an example in more detail. The example is based on this other question "What is coinduction?". I'l...
In a hypothetical scenario, where a precise and formal definition does not exist here, and thus expressed with analogies and verbal reasoning for the sake of simplifying the P, NP problem. A(lan) Turing Machine arrives to the "Universal-Algorithm-Island", and meets Christopher, an oracle with a True or False response. ...
I have a matrix of size NxM. Each coefficient can have either some fixed value or a joker denoted by * Let's take two random rows. We are going to loop through the columns. For each column, either we color it green or in red. We color using red when the two values in the same column have an intersection, i.e. either ...
There are two types of sets $\mathcal{X} = \{X_{1}, X_{2}, \ldots, X_{n_{1}} \}$ and $\mathcal{Y} = \{Y_{1}, Y_{2}, \ldots, Y_{n_{2}}\}$ such that $X_i, Y_j \subseteq [m]=[\mathrm{poly}(n)]$ and $n = n_{1} + n_{2}$. Given a sequence $\alpha$ over $\mathcal{X} \cup \mathcal{Y}$, the goal is to find the longest (increasi...
I am new to Linear Programming and Approximation algorithms. and I am trying to do this exercise for writing an IP and relax it to LP. What I am given: A digraph G = (V,E) with wv being the weight on vertex v for every v ∈ V. A multi-set S is a set such that it contains elements more than one time. Suppose from a dir...
I have read that 1NF, 2NF and 3NF decompositions are lossless and dependency-preserving. Consider this example on a relation $R(A,B,C,D)$ with functional dependencies set as $FD =${ $AB \rightarrow CD, A \rightarrow C, BC \rightarrow D$ } Here when we do 2NF decomposition we get $R_{1}(A,C)$ with $FD =${$A \rightarrow ...
So i'm defining the embarassingly parallel complexity class as the set of decision problems which can be solved in time $O(T(n))$ on a single computer and in time $O(T(n)/g(n))+O(\log(g(n))$ if you have access to $O(g(n))$ machines where $g(n)$ can be of a total size up to $T(n)$. So these are the types of problems, wh...
In my OS course, the instructor mentioned the following: In UNIX if a parent process creates a new child ("fork") then the child is an exact duplicate of the parent. This means its memory space is a copy of the parent's. Now if the child process immediately calls "exec", it replaces its own memory space with that of a ...
I am currently reading reading Chapter 11 of Operating Systems: Principles & Practice by Anderson and Dahlin, which speaks about file systems as abstractions for non-volatile storage. The distinction between files and directories is first made. Afterwards, in examining what files are, a distinction between file data (i...
Donald Knuth's The Art of Computer Programming, Volume 1 Fascicle 1 contains the following exercise: If $\alpha$ is any string of 0s and 1s, let $\operatorname{s}(\alpha)$ and $\operatorname{u}(\alpha)$ be the integers that it represents when regarded as a signed or unsinged binary number. Prove that, if $x$ is any in...
I understand that pumping lemma can only be used to prove that a certain language is "non-regular", it cannot be used for proving regularity But since, it's a property of regular language, we should be able to pick up a language that is regular, literally, and then see if this property exists in that language, which sh...
One popular algorithm to find the Voronoi diagram out of a collection of points (sites) in the plane is Fortune's algorithm. It is usually described in terms of a sweep line, whose interaction with sites give raise to parabolas, whose intersections eventually provide the Voronoi diagram. The Wikipedia page also include...
In a project of mine, I want to represent states as efficiently as possible. Initially, I went ahead with a BitBoard representation and some clever tricks to speed up the evaluation of the game tree. That works fine. Though when looking up any given state in the Look-Up table, I need to do some heavy calculations. Afte...
And I assume these new data structures are more context/field-specific?
This is a homework question. Let $G = (V, E)$ be an undirected graph. Let $u, v, w \in V$, find a path from $u$ to $w$ that passes through $v$. I know that I can solve this by running BFS on $u$ and then on $v$. If $v$ is a reachable from $u$, and $w$ is reachable from $v$, then I just output the shortest path from $u$...
This question relates to the 2nd edition of Probability and Computation by Mitzenmacher and Upfal. The authors then use the Law of Total Probability My question concerns the line that begins with $\leq$. Shouldn't that be replaced with $=$ because the authors proved that the event $\mathbf{AB} \bar{r} = \mathb...
This question isn't very technical, but I'm in desperate need of help and I thought this would be the best place to post this question. I'm in an computer science course, data structures and algorithms and we have dealt mainly with singly / doubly linked lists as our main data structure, skip lists and time complexity....
We all know that We estimate our running time by drawing a graph and Big O and Big Theta is our worst and average running time respectively and we graph our function like : $ O(g(n))= f(n)$ and create a range $0<f(n)<cg(n)$ and for $\Theta(g(n))$ $0<c_21g(n) <f(n)<c_2g(n)$ here What does g(n) means precisely and how do...
I would like some hint in this homework question. I have to write the max-flow problem (with souce $s$ and sink $t$) as a linear program. I have to do this by defining variables on each $s - t$ path, which is different than the typical approach of considering as variables the flow of each edge. So far, I thought on the...
Suppose $f_1(n)=n\log^*n$,$f_2(n)=n\log h$ that $h$ is number of vertices of convex hull. Can we conclude that $$f_1+f_2=O(f_2)?$$ Edited: Note that, $h$ is a function accroding to $n$ that $h\leq n$, and according to the input $n$ it can be less than $n$ such as constant. $n\log h$ is running time of an ouput senseti...
For a regular language $A$ with the alphabet $\{a, b\}$. Is $L$ a regular language, where $L$ contains strings of $A$ but sorted with $a$ and $b$? In other words, formula: $L = \{ a^{\#_a(x)}b^{\#_b(x)} \mid x\in A\}$, where $\#_a(x)$ is the number of $a$'s and $\#_b(x)$ is the number of $b$'s. $A$ is a regular languag...
I came across the following family of online problems: Given a sequence of values of length n, the maximum value and the minimum value of the sequence, our goal: Given min and max, we want to find a good/best element in an online that if an element of the sequence satisfies some criteria based on min and max accept it ...
My question is related to this one Minimize number of circles to cover set of points In a 2D space, I have a set of points. I can deploy up to $k$ circles with radius $r$ to the space, and my goal is to maximize the number of points that will be put inside these circles. There are two cases: a) Either the circles canno...
We are given an undirected weighted graph $G=(V,E)$ that contains at most $2n$ edges, as well as an MST of $G$. If we decrease the weight of exactly $n$ edges, is it possible to compute an MST of $G$ in $O(n)$? If it's not possible, are there any lower bound that show us, it can't be done in linear time?
I have a list of supported operators, my question is whether the lexer should just yield the token for the operator or raise a syntax error in case that particular operator (let's say "?") doesn't exist in the operators list? for example, the operators list [+, -]. for the expression "1 ? 2", should the output be [numb...
Are there any algorithm for finding MST of given graph $G$ in linear time? I found this paper at this link But I can't understand it running time is linear or not.
Is there a way to tell if ANY machine on ANY input will halt in fewer than n steps OTHER than running the machine for n steps? I've read the similar questions and answers such as here, but I wanted to make sure that they were talking about any machine on any input, not a particular machine or on a particular input. If ...
Given pixel values $r_1,r_2,\dots,r_n \in \{0,\ldots,255\}$ and $k$, find $$ \min_{v_1,\ldots,v_k} \sum_{i=1}^n \min_{1 \leq j \leq k} (r_i - v_j)^2. $$ My attempt: Let $F[L,c]$ be the minimum cost, where $L$ is the last color that was chosen, and $c$ is the remaining colors. Since the order of pixels don't matter, l...
For a CNF SAT instance in the DIMACS format what is the best algorithm to compress it? What is the best algorithm for 3-SAT instances in particular? In 2020 SAT competition used .xz which if I understand correctly relies on the LZMA algorithm. Brotli probably would not be optimal as it has a pre-defined dictionary of E...
This question kind of puzzled me, it was presented as a homework assignment for 2nd year undergrads and one of them approached me in case I could give him some pointers, but the problem is I couldn't even think of the answer myself. They start with an unsorted array of integers and they're to find an element (there cou...
My attempt at solution-: Solution by a teacher-: Both are giving same answer, is the one that I made correct?
A model of computation is currently defined on wikipedia as: a model which describes how an output of a mathematical function is computed given an input. Is it therefore correct, at least as a rough approximation, to conceive of a model of computation as "reverse engineering a function"?
I'm having some trouble understanding the regular expression $0^*10|01(01)^*$. The expression matches strings like $00010$. But for some reason, I wasn't able to find a string that matches the $(01)^*$ at the end. An equivalent expression with capturing groups to demonstrate the order of evaluation would be very much h...
I have a PDA A = ({q0, q1}, Σ = {a, b}, Γ = {a}, δ, F = {q1}), with these transition functions δ: ((q0,a,ε),(q0,a)); ((q0,b,ε),(q0,a)); ((q0,a,ε),(q1,ε)); ((q1,a,a),(q1,ε)); ((q1,b,a),(q1,ε)). The exercise asks me to explain the structure of the words accepted. I have designed the PDA but i'm having problems understand...
I was trying to understand pointers by watching YouTube videos. However, I could not understand How do they work? Why do we use them? When do we use them?
I have $n\times n$ matrix of non-negative integers $a_{ij}$. Let $S:\mathbb{R}^{n\times n}_+\mapsto\mathbb{R}_+$ be the following function: $$S(A)=\sum_{j=1}^n\sum_{k>i}\large\mathbb{1}_{\{a_{ij}=a_{kj}\}},$$ where $\mathbb{1}$ denotes the indicator function. I would like to find a permutation $\sigma$ of the rows of $...
Having the ability to see 2 or more colors can improve the sensitivity of nuances but greatly increases the complexity of image processing algorithms. I once thought that 3 colors are necessary for the most complex tasks (such as self driving cars) until I learned that colorblind people (who can see only 2 colors) can ...
this is very confusing question. I am having no idea to solve it, can you please guide me here?
I have a problem that looks like a 0-1 Knapsack problem, except that the value of each item is a vector of length about 5, $v=(v_1,\dots,v_5)$. I want to maximize the product of components of the sum of the value vectors that are selected. In other words, if $S$ is the set of value vectors for the selected items, I wa...
A friend and I did the Inorder-tree-walk with pen and paper. We both can't figure out how the algorithm would move 'up' the tree again upon hitting a leaf: We are using the algorithm as described by our professor and taken from "Introduction to Algorithms, Third Edition" Chapter 12 page 288: Inorder-tw(node) if node ...
I have a graph $G$ with $n$ nodes and $O(n)$ edges. Each of the nodes has a positive integral weight at least 2, such that sum of all weights is at most $O(n)$. We want to color the nodes and edges red or blue, where coloring a node of weight $C$ costs $C$ units, and coloring an edge costs 1 unit. Constraints: Any edg...
I am trying to understand the Boolean Hierarchy. the formal definition of the Boolean Hierarchy is as follows: $BH_1 = NP$ $BH_{2k}$ is the class of languages which are the intersection of a language in $BH_{2k-1}$ and a language in $coNP$. $BH_{2k+1}$ is the class of languages which are the intersection of a langua...
I am given $A$ and $B$, where $A$ is less than or equal to $B$, and they are in the range of $[1, 100000000]$. I want to calculate the number of pronic numbers in that interval $[A, B]$. These numbers are numbers $n$ such that $k \times (k + 1) = n$ for some $k$. The following algorithm works, but I am having a lot of ...
Design a DFA that accepts language $$L = \left\{ x \in \{ 0, 1, 2 \} : \text{ sum of digits in } x \text{ is } 2 \mod 3 \right\}$$ How to make a DFA for this? I have no idea how to solve this dfa problem. I have a solution by someone but I am not getting concept to start this solution.
I was assuming the following equivalence in one proof: $L \in NP^B \iff \overline{L} \in coNP^B$ here $NP^B$ is the class $NP$ with oracle acess to oracle $B$ and similarly $coNP^B$. Is this correct? Does it matter if I give oracle acess to $B$ or to $B^c$?
State machines are a fundamental computer science concept and in many senarios they are the simplest way to implement a process or program. However, most programming languages don't support them natively. Is there a technical limitation to do it? And if not, are there any programming languages that do support state mac...
In undergrad theory classes, the idea of decidability and recognizability is introduced. It's well known that $A_{TM}$, the set of words accepted by a TM $M$, is recognizable but not decidable. We also know that the complement problem $\overline{A}_{TM}$ is co-recognizable but not recognizable. I have a doubt about the...
Construct a PDA, which recognizes the following language $L$: $L = \{w\;|\; |w|_a > 2|w|_b\}$, so it is the language that consists of words which have more than twice as many $a$'s as $b$'s. I have constructed a PDA, which I believe to recognize $L$, however it is too complicated to prove its correctness. Is there an...
Suppose you have a machine that takes inputs a set of sets, $\{S_1,S_2,\dots S_n\}$, and an integer $k$. The machine then returns True if $S_1$ intersects every other set $S_2,\dots,S_n$ in at least one place and otherwise returns False. Call this problem the INTERSECT problem. Now call the K_ELEMENT problem the pro...
Given a $\Sigma$ I define a regular language as one of the folllows: $\emptyset$ $\left\{ \sigma \right\}$ for any $\sigma \in \Sigma$ $L_1 \cup L_2$ for regular $L_1, L_2$ $L_1 \cdot L_2 $ for regular $L_1,L_2$ $L^*$ for regular $L$ Now, I would like to show that for a given regular language $L$, its complement $\ov...
Pretty much just the title. Is it all possible combinations of a and b that have 2 letters ?
In our lecture, the Huffman coding was described as optimal. Optimal with regard to the minimum information content. When asked, the professor explained to me that the length of a fixed code word should be minimal. I have now looked up on the internet what the common information is, this characterises the code as minim...
My Monte Carlo algorithm starts by placing some circles in the plane with potential overlaps. I then place a large circle somewhere and compute the overlapping area of this larger circle with the other circles, through iteratively testing random points of the larger circle. On this site it is stated that Monte Carlo al...
Context-: A language over Σ need not include strings with all symbols of Σ Thus, a language over Σ is also a language over any alphabet that is a superset of Σ. https://www.univ-orleans.fr/lifo/Members/Mirian.Halfeld/Cours/TLComp/TLComp-introTL.pdf Page number 10 I am trying to understand what it is trying to say-: Σ={...
Most cryptographic protocols like pseudorandom number generators run only on "internal" information: that is you set a seed and the next state is a function of its previous state etc.. I am wondering if there are any examples of cryptographic protocols that make use of "external" randomness or information, which is as...
An Exact Cover problem is commonly denoted as a matrix of 0s and 1s. Columns denote requirements, rows denote possible choices. The problem is solved when a set of rows was found such that, using just this set, each column has exactly one 1 in it. In this question, assume that exactly one solution exists. A common way ...
I'm trying to solve following problem: Check, if the string contains substring, that can be obtained from pattern using one to one lower case symbols replacement (using bijection between original lower case letters and new letters). My strings only consist of upper case and lower case english alphabet letters (A–Z, a...
By definition are Nondeterministic Finite Automata not allowed a 'sink-state' (non-accepting state we don't get out of)? I can see us having them for NFA but not necessary but do not see how they are against the rules of a NFSA/NFA or should not be allowed. My teacher said they are not allowed in a NFA/NFSA, but even i...
You have an array of floats, for example: [74.45329758275943, 501.9063197679927, 172.59563201929095, 307.1739798358187, 362.042263381624, 940.1282277740091, 577.2604546481798, 63.201270419598224, 828.8081043649505, 31.1630295128974] For each float, you can either call floor() or ceiling() to convert it to the near...
Context-: https://math.stackexchange.com/questions/1600257/determining-if-a-binary-string-represents-a-prime-integer Confused text-: The problem of testing primality can be expressed by the language LP consisting of all binary strings whose values as a binary number is prime. That is, given a string of 0's and 1's, sa...
I got bombed in a interview because I was asked to write an algorithm which would count the leaves of a tree, I did this: class TreeNode{ TreeNode[] children; int value; ctor(){ children = new TreeNode[](); } } class CountingClass{ int count; ctor(){ count = 0; } void Count(TreeNode node) { if(node.Children.Count...
I have a problem which could be stated as follows: Given an unweighted undirected graph $G=(V, E)$ and positive integer $k \leq |V|$, I need to find a subset of vertices $R \subseteq V$ such that $|R| \geq k$ and no two vertices in $R$ are joined by an edge in $E$. As you can see, this is the definition of the independ...
Context-: Problems that can be solved by a computer using no more time than slowly growing function of size of input are called tractable. Polynomial functions are slowly growing functions. Functions that grow faster than any polynomial are deemed to grow too fast. I googled about input size-: For sorting arrays-: in...
Define the subset sum with interval integer target problem (SSIITP) as follows: SSIITP Input: A multiset $S = \{a_1, …, a_p\}$ of positive integers $a_i$. An integer $T$. SSIITP Output: True, if there is a subset $S’ \subseteq S$ such that $\sum_{x \in S'} x \in T .. 2T$. False, otherwise. Where $a .. b$, for two i...
I am reading CLRS 3rd Ed, chapter 17.1 (Aggregate analysis pg453) and I came across this statement. Let us analyze a sequence of n PUSH, POP, and MULTIPOP operations on an initially empty stack. I am confused as in: Do the push, pop, and multipop cumulatively add up to n operations. (there is a total of n operati...
Assume that P1, P2,..., Pn are all NP-class problems. PP1 and PP2 are unknown problems (i.e., we don't know whether they belong to the P or NP classes). If "P1, P2,...., Pn" problems can be reduced to PP1 in polynomial time, then PP1 can be reduced to PP2, and PP2 can be reduced to another NP problem in polynomial time...
Can we prove by induction that $A_k$ is computable for every choice of $k \in \mathbb{N}$? $A_k$ is the set of descriptions of a no-input Turing Machine which accepts in $k$ or fewer steps.
Text of the problem: Solve the following recurrence equation and prove it by applying the principle of induction: $T(n) = \begin{cases} 3, \ n \le 2 \\ T(\lfloor\frac{n}{2}\rfloor)+n^2, \ n \ge 3 \end{cases}$ after doing the recursion tree, I find that the complexity (if I'm not wrong) is $ \Theta (\log_2 n) $ But I ...
The first one is from unreputed youtuber whereas second one is from reputed university called adiuni course of theory of computation. Now I know what that second figure means, it means it also accepts $\in$ as initial state=final state, but how I don't know that. This dfa should accept all binary divisble by 4. But h...
Let $G = (V, E)$ be a directed acyclic graph, which is quite sparse (in the examples I have in mind, $|E| \approx 10|V|$ or so). For each vertex $v \in V$, let $f(v)$ be the number of vertices reachable from $v$. Is there a way of calculating the function $f$ for all vertices in time $|V| + |E|$? The obvious algorithm ...
It is known that: $\Sigma_2^P \subseteq \Delta_3^P$ i.e. $NP^{NP} \subseteq \Delta_3^P$. $BPP^{NP} \subseteq \Delta_3^P$ If $\Sigma_2^P = PSPACE => BPP^{NP} \subseteq NP^{NP}$ Doesn't that imply: $\Sigma_2^P = PSPACE => BPP \subseteq NP$? Am I missing something?
Let $G = (V,E)$ be a connected undirected graph. Let $s \in V$ be a vertex in the graph. True/False: If $v$ is a leaf in every spanning tree resulting from DFS(s), then $v$ is a leaf in every spanning tree resulting from BFS(s). I assume that this one is True, and I think that because if $v$ is a leaf in every DFS(s), ...
I was asked a question in my algorithms exam which had this as the core question after simplifying. I had written that it would be NP-Hard but I got it wrong my professor is saying that it would be NP-Complete. Kindly help me resolve my doubt.
I am trying to construct the DFA that accepts the following language $$ L_2 := \left\{ w \in \{a,b\}^* \mid \#a(w) \text{ is divisible by } 3 \text{ and } \texttt{babbab} \text{is a substring of } w \right\} $$ My solution is illustrated below. I feel like my current solution is incomplete/wrong.
I need to find a regular expression for the language over $\{a,b,c\}$ consisting of all words in which no two consecutive letters are the same. For example, $abacbabca$ is in the language, while $abbc$ isn't. How do I do that? Any help would be greatly appreciated!