instruction
stringlengths
35
29.1k
Can we determine in polynomial time if the language accepted by an NFA is infinite? The case of DFA is simple, but converting an NFA to a DFA may take exponential time. Also, I ran into this post, Determine if an NFA accepts infinite language in polynomial time. But there is no solution.
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,\cdots,x_n \\ U...
Suppose I have a variant of the knapsack problem: $$\max_{x} \sum_{i=1}^n v_ix_i$$ $$(\sum_{i=1}^n w_ix_i - W)^2 \leq k$$ for $v_i, w_i \in \mathbb{R}$, $x_i \in \{0,1\}$ and $k \in \mathbb{R}, k > 0$. Is it known if the decision problem $\sum_{i=1}^n v_ix_i > V$ for some $V$ is NP-Complete?
I've been going through some questions on old homework. Here was a question that confused me somehow. Question: Given a language $$L=\{\langle M\rangle\ |\ M \text{ is a Turing machine. } M \text{ goes through some configuration } (q,s,i) \text{ infinite times on input } \epsilon\}$$ determine whether it's decidable, i...
Consider a deterministic finite automaton $M(k) = (Q, Σ, \delta, 0, F)$, with $k ≥ 2$ and $Q = \{0,1,...,k-1\}$ $Σ = \{0,1\}$ $\delta(q,a) = (q+a) \space mod \space k$ $F = \{0\}$ If $L$ is the language recognised by $M(k)$, describe a deterministic finite automaton that recognises the concatenation $L ⋅ L ⋅ L ⋅ L ⋅ L ...
I came across the below question where the polynomial time solution to the "Set Cover Problem" is discussed when the subsets are of size EXACTLY 2. Set cover problem with sets of size 2 The solution described involves constructing an Edge Cover for a slightly different graph (Create a graph of keys and each edge links ...
I'm having a problem with an exercise, I'm supposed to calculate the exact worst case runtime and the worst case runtime in Big O Notation for a given algorithm. This is what I'm struggling to understand, I think I know how to recognize what's the runtime using the big O Notation as it's only a nested loop but what ...
From my understanding, a CPU register is a temporary storage or working location built into the CPU itself. The CPU includes some functional units such as the ALU (which is part of the chip, as far as I know). In a 64 bit architecture, we have 16 general purpose registers, that seem to be often used in ASM programs to ...
Background In the classic formulation of the knapsack problem with both weight and volume constraints, we are given a collection of $n$ items where item $i$ has weight $w_i\in\mathbb{N}$, volume $u_i\in \mathbb{N}$, and value $v_i\in\mathbb{N}$. We aim to fill a bag with weight capacity $W$ and volume capacity $U$ such...
In the MTD-f algorithm: function MTDF(root : node_type; f : integer; d : integer) : integer; g := f; upperbound := +INFINITY; lowerbound := -INFINITY; repeat if g == lowerbound then beta := g + 1 else beta := g; g := AlphaBetaWithMemory(root, beta - 1, beta, d); if g < beta then ...
Suppose I have a set of N*L elements. I wish to generate a sequence of k partitions of size L such that I maximize the number of pairs of elements that share membership of the same partition. What kind of algorithm would optimize this? To make it easier to understand, imagine an icebreaker situation: Suppose I have a n...
More out of curiosity than anything else. I know you can always generate a list of random numbers and then sort it, but I was wondering if there exists a (pseudo)random number generator whose output is already in sorted order? I found this, but it and everything else I found only generates integer lists. Is there an eq...
I want to prove that the language of all regular expressions is not a regular language. I'm having trouble to approach this problem. I thought maybe to show that the parenthesis language is a part of it, and then I can rule out the regularity.
In Michael Sipser's Introduction to the Theory of Computation, Example 1.56 shows how to convert $\left(\text{ab }\cup\text{ a}\right)^*$ to an NFA. It builds up from the smallest subexpression to larger subexpressions until the required NFA is obtained: My question is: why is the NFA to recognize $\text{ab}$ not a si...
Graph Homomorphism is a well-known NP-complete problem. Given graph $G$ and $H$, $G$ is said to be homomorphic to $H$ if there is a mapping $f: V(G) \mapsto V(H)$ such that $(u,v) \in E(G) \implies (f(u), f(v)) \in E(H)$. The mapping in above is unrestricted -- and hence, multiple nodes of $G$ can map to a single node ...
I'm trying to flip a triangle like this in the following image: there are two constraints in flipping it: 1- flip it with the minimum circles moves 2- the circles is sliding from a place to another and can't jump over another circle. 3- the circle can move vertically or horizontally 4- the circle can move any number ...
Let us be given a function $f(x_1,\dots,x_{10})$ of multiple variables $x_1,\dots,x_{10}$ given that $\sum_{i=1}^{10} x_i \leq 7$. How do we solve the following problem? $$ \begin{equation} \begin{aligned} \max_{\{x_i\}, i=1,\dots,10} \quad & f(x_1,\dots,x_{10})\\ \textrm{s.t.} \quad & \sum_{i=1}^{10} x_i \leq 7\\ & ...
I need to define a grammar for $L=\{a^ib^ic^jd^j| i \ge j \ge 0\}$ as I wasn't told about any restrictions for the grammar, e.g context-free or context-sensitive, I assume any derivation rules can be used here. Because the number of $a$s and $b$s is greater than, or equals to, the number of $c$s and $d$s I have this fi...
How would one count the amount of solutions to quantified formulas that have universal quantifiers? For example, for a boolean formula $\Phi(X)$ with a number of solutions $\#\Phi(X)$ let's construct a quantified boolean formula $\forall y \ \exists X: y \lor \Phi(X)$. In this case $X$ represents $n$ boolean variables....
I have been unable to find any literature on average-case complexity for coNP, other than a folklore conjecture that most tautologies are hard for any given propositional proof systems and some analysis of random k-SAT refutation. Am I missing something? Is the following not a simple characterization: no paddable coNP-...
You can refer the problem on later part of section 4.1 in "Algorithm Design Book by Jon Kleinberg and Éva Tardos" Problem: We have "n" lectures and we our job is to assign all of the lectures using least amount of classrooms Let d be the list of resources required, initially we would have resources equal to "n" cause a...
I am trying to figure out the time complexity for "Regular Expression Matching" problem. Problem statement is simple, only meta characters allowed are '.' and '*'. Actual problem statement can be found in Link The solution is in java and I have solved it using memoization, but having difficulty to compute the time comp...
Hello, Im new to learning epsilon nfas, and I have been wondering if we could leave certain epsilon transitions out, and if so would it still be a valid epsilon nfa? For example regarding the image, couldnt I just delete the marked epsilon transition and the state that it leads to, thus only having the unmarked epsilo...
I am a little confused when it comes to linear boolean functions. According to this post: What is a simple way of explaining what a linear boolean function means in boolean algebra and relating it to the standard definition of linearity? We have that a function is linear if: $$f(x \oplus y) = f(x) \oplus f(y)$$ which (...
For a language $\mathcal{L}$ over an alphabet $\Sigma$, define $$\mathcal{SW(L)} := \{ y ∈ Σ^∗ \mid \exists x \in Σ^* \text{ such that } xyx \in \mathcal{L}\}$$ How can I prove that if $\mathcal{L}$ is regular, then $\mathcal{SW(L)}$ is also regular?
If $R$ is an arbitrary decision problem that is reducible to $S$, which is an NP-complete problem, what can be said about $R$? I think we should be able to say that $R$ is in NP since an instance of $S$ can have a certificate verified in polynomial time and from the reduction $R \le S$, we could say the same about $R$....
Let $α \in [0, 1)$ be a constant. For a rooted binary tree $T$ and a node $x$ in $T$, we denote by $|x|$ the number of nodes in the subtree of $T$ rooted at $x$ (if $x$ = $NIL$ then $|x|$ = $0$). We say that $T$ is $α$-good if, for every node $x$ in the tree with children $y$ and $z$, it holds that $|y|$ − $|z|$ ≤ $α|x...
Summary. A data structure maintains in constant time a sorted list of counter values, for a dynamic set of counters. I am interested in references using this structure, and in possible improvements. Problem and motivation. Consider a set of counters that may be increased (by 1), decreased (by 1), deleted (when at 0), ...
I was recently reading about Fourier dimension of Boolean functions. What I understand is that if we take the Fourier expansion of $f: \{\pm1\}^n \to \{\pm1\}$ and consider the monomials with non zero Fourier coefficients as vectors in $\mathbb{F}_2^n$, then the Fourier dimension is the dimension of the span of these v...
Recently I studied a MIT open course. In lecture2, it is stated that Rectangle Packing is NP-hard. I can understand this because the problem can be reduced to 3-partition problem But I don't know why it's an open problem whether it's in NP. In lecture2 it is stated that: it is complicated to encode rotations efficient...
I have an interesting problem I need to solve. I have a list of about 200k two player matches containing about 22k unique players. I need to find the largest set of players that never played against each other. The first approach I did: pair each player with a set of players he played against sort them by number of pl...
Consider a rooted tree $T$. A matching in $T$ is said to be proper if for every unmatched vertex $v$ it holds that the parent of $v$ is matched to one of the siblings of $v$. It is known that every tree admits a maximum-size matching that is proper. Consider a rooted tree $T$ over a set of vertices $V$ and a proper mat...
The following problem is based on the section about dynamic table as part of the discussion about amortized analysis in CLRS Problem: We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that when the ar...
I am trying to understand the concept of synchronised DFAs. I have a question where all the states in the DFA after reading that particular word from the alphabet will reach a particular state with the alphabet (A to Z). And I should prove that a language which accepts any random number of alphabet combinations followe...
Set theory depends on a set membership function $\epsilon$ which is a class of ordered pairs. Is it possible to construct the ordered pair from an undirected graph of unordered pairs? Alternatively, is there a way to construct a undirected graph that represents a directed graph? The graph may be traversed from either...
In class we were talking about the decidability and acceptability of languages by Turing Machines but a doubt arose in my mind, "is any language containing a finite number of strings decidable by Turing Machines?" My first answer could be no, since there are finite languages that are undecidable.
Now, $\color{blue}{\text{Exponentiation}}$ is defined as Exponentiation is a mathematical operation, written as $b^n$, involving two numbers, the base $b$ and the exponent or power $n$, and pronounced as "$b$ raised to the power of $n$". $$b^n = \underbrace{b\times b\times\cdot \cdots \times b}_{n\text{ times}}$$ No...
i recently have been practicing constructing Turing Machines for languages. But i can't seem to figure this one out. I've seen a few videos on constructing 3 equal length strings (a^nb^nc^n) But i can't figure out this one. Can anyone help out how i can do this. Please don't give the answer outright, i want to actually...
Consider a variant of the TSP problem where the cost function $c$ is not only symmetric but also satisfies $c(u, v) ≤ 2c(u, w) + c(w, v)$ for arbitrary vertices $u, v, w ∈ V$ . Give a polynomial time algorithm that achieves a constant factor approximation ratio for this problem. I think the algorithm itself is the same...
Consider the following problem: Input: A Turing Machine M and a DFA D. Question: Is $L(D) \subseteq L(M)$? Of course, this problem is not decidable. Because it is known that judging whether a word belong to a Turing Machine is not decidable. If this problem is decidable, then we can write the word as regular expres...
How can the result of the execution of $ \rightarrow RL$ differ from that of $\rightarrow LR$? In turing machines
Are there other advantages to linked lists over arrays other than constant time removals of the first element?
For one dimensional, continuous binary search most effective algorithm would remember boundaries. For example if boundaries are 0.7 and 0.9, point to check would be 0.8. And if result is 'too small', then boundaries become 0.8 and 0.9, and point to check is 0.85. This algorithm is fast and simple. But it doesnt do well...
Suppose that we're given a connected, undirected graph $G = (V, E)$ with edge weights $w_e$ and a subset of vertices $U \subset V$. We want to find the lightest spanning tree in which the nodes of $U$ are leaves (they may be other leaves as well). We want to do so in $O(|E|\log(|V|))$ time. I was reading: Spanning tr...
I am creating a tool for validating, parsing, and interpreting flowchart diagrams on diagrams.net, and it is necessary to give users an opportunity to define a set of rules for the diagram. So, in the end, I want to achieve something like ANTLR for diagrams with the following features: Some kind of DSL for defining pa...
Given an array of characters, I need to delete all the characters that got repeated 3 or more times (consecutively) and add '0' at the end of the array for every deleted character, The restrictions: $O(n)$ time $O(1)$ memory Can't overwrite a cell in the array more than once Examples: "aacccbbddde" --> "aabbe000000" ...
Let $G=(U, V, E)$ be a biparite graph, with $U$ and $V$ being the two sets of nodes. I am trying to find the smallest set of nodes $\hat{V} \subseteq V$ such that, for every node $u \in U$, $\hat{V}_u$ contains at least one element and is different from $\hat{V}_{u'}$, $\forall u' \neq u \in U$, where $V_u \subseteq V$...
According to Exponential Time Hypothesis there does not exist a deterministic algorithm to solve SAT over $V$ variables in time $o(2^V)$. However, let's say the number of literals $n = \omega(poly(V))$. The real input size in the worst case is $\Theta(n)$, therefore for an asymptotic analysis one can assume $n$ to be t...
I have been struggling for a few hours in terms of finding the right solution for the following problem: Suppose we have a file that contains integers where each represents a user of a service. By reading that file we want to find how many times the service was accessed and by how many different users. My code should ...
I have two set of points in the plane or space, which could be for instance radar contacts over two successive scans. I'd like to pair them so that the sum of squared distances is minimal. One difficult case, if for instance there is a serie of aligned and equidistant points in the first set, can be found in the second...
Problem You are given two integer arrays nums and multipliers of size n and m respectively, where n≥m. The arrays are 1-indexed. You begin with a score of 0. You want to perform exactly m operations. On the iᵗʰ operation (1-indexed), you will: Choose one integer x from either the start or the end of the array nums. Ad...
I have a metric space $(V,d)$ described by a tree $T$. And I have $k$ pair of vertices $\{s_i,t_i\}$ ($i \in [k]$) s.t. each of the vertices $s_i$ and $t_i$ are leaves of $T$. There is a car at one of the leaf $s$ of $T$. The car has to deliver a package from $s_i$ to $t_i$ (for each $i$). But at any time the car can ...
I am a bit confused in the following definition: what does comma mean. I know I(X;Y) is the mutual information between X and Y but I am not sure how to interpret the I(X_1,X_2;Y)).
Bentley, J.L. [1977]: Solution to Klee's rectangle problems, unpublished manuscript, Dept. of Computer Science, Carnegie-Mellon University, 1977. Is it classified or not archived at all?
If $P = NP$ it's easy to show by induction that the $PH$ collapses to $P$. But would that have any other implications for the relation between $PSPACE$ and $PH$? We already know that $PH \subseteq PSPACE$ and this continues to hold true in the case of the $PH$ collapsing, but would $P = NP$ imply anything else for the ...
Let $QBF_k$ be the problem of determining the satisfiability of a formula of the form $Φ = Q_1x_1Q_2x_2 . . . Q_kx_k φ(x_1, . . . , x_n)$. where each $Q_i$ is one of the quantifiers $∀$ or $∃$. So, $Φ$ contains $k$ quantified variables $x_1, . . . , x_k$ and free variables $x_{k+1}, . . . , x_n$. The problem $QBF_k$ is...
Given the algorithm MYSTERY-ALG(n >= 0) 1 if n < 3 then 2 return 1 3 else 4 return MYSTERY-ALG(n/2) + MYSTERY-ALG((n/2) + 1) I defined a recurrence $ T(n) = \begin{cases} 1 & 0 \leq n < 3 \\ T(\frac{n}{2}) + T(\frac{n}{2} + 1) & \text{otherwise} \end{cases} $ which I guessed to be $O(n)$; I've ...
i figured out this is what i want to know: in Cook's theorem it is shown that SAT is NP-hard. he shows it by showing that sat is at least as difficult like the word problem for nondet. Polynomial Time Machines. I want to know how i would proof that 2-sat is P-hard while showing that 2-sat is at least as difficult like ...
in the cook-levin theorem a nondet. Turingmachine is translated into a formula of the form: $\phi$ = $\phi$$_{1}$ $\land$ $\phi$$_{2}$ $\land$ $\phi$$_{3}$ $\land$ $\phi$$_{4}$. I want to know what difference in the formula there is if i would do the same for a DET. Turingmachine and why these differences may occure. T...
I am trying to understand count-to-infinity avoidance techniques, and came across this topology. Now, suppose the interface eth1 on R1 has gone bad, and assuming that split horizon, triggered updates and poison reverse are all enabled, what is the effect of hold-­down timeout on convergence? Will it help to avoid the ...
word problem: given a language L through a deterministic turing machine, is the word w in the language L? the problem should be decidable, since if there is a deterministic turing machine i can simply turn that into a dfa take the word w go through the dfa step by step and see if i end in an accepting state? I now want...
In the universal relation $UR_n$ problem [1] of communication complexity, there are two players Alice and Bob. Alice gets a string $x \in \{0,1\}^n$, Bob gets a string $y \in \{0,1\}^n$ with the promise that $x \ne y$. The players exchange messages and the last player to receive a message must output an index $i \in [n...
I am wondering as to how to efficiently encode the following subcircuit for a binary satisfiability solver (cnf, and optionally xor clauses, if this helps): eq2 = sum(a, b, c, d, e, f, g, h) == 2 eq3 = sum(a, b, c, d, e, f, g, h) == 3 (All variables binary. That is, eq2 should be set if and only if exactly two...
I'm reading CLRS and there is something I don't understand regarding counting the number of parenthesization, in the Matrix-chain multiplication chapter, the book says: Denote the number of alternative parenthesizations of a sequence of $n$ matrices by $P(n)$. When $n$ = 1, we have just one matrix and therefore only o...
If we have a BST but want to keep it balanced, how much more expensive does adding an element to it become? Clearly adding an element (without maintaining balance) is of time complexity O(log(n)), as we traverse the tree down to the point where we should add the element, but if we want to maintain a balanced tree such ...
I'm trying to understand the implementation of the algoritm here. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for x <= 1 || x <= a. The authors use Kummer's confluent hypergeometric function M(1,a,x), because it converges under the specified conditions. But don't understand th...
I was learning about decidability when I thought of this question: If P is partially decidable, is ¬P decidable, partially decidable or undecidable? I think it is Undecidable since if ¬P holds then P doesn't hold, and the characteristic function of P is undefined when P doesn't hold so we can't come up with a character...
Complete graph with n vertices. Walk from vertex u to vertex v of length k. I don't understand how the number of walks between the two of length k is $n^{k-1}$ I've tried this formula on an example where n =5 and k = 2 and I can't even find 5 walks. Any help understanding this formula and example would be greatly appre...
I want to construct a context-free grammar for this language: \begin{align*} L = \{uc^nd^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*} I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &S\to aSb \...
Given that $\#\notin \Sigma$ and $L\subseteq \Sigma^*\#\Sigma^*$, prove that if $L$ is context-free language then $L' = \{w_2\#w_1 \mid w_1\#w_2\in L\}$ is context-free. I'm trying to prove this in this way: because $L$ is context-free then $G$ is context-free grammar for $L$, then $L(G)=L$. by showing that the revers...
I have a large list (around 200k) of element pairs (e.g. A-B, A-C, B-C, ...). How can I find the largest subset of elements amongst which none are paired? Example of pairs: A-B A-C A-F B-C C-D E-F F-G Here the largest subset would be of size 4, and one of the subsets with size 4 would be: {A,D,E,G}.
In static routing where the network parameters dont change, we can use Djikstra's or Bellman-Ford's algorithm to find the shortest path to send data from source to destination.However in dynamic routing how do we do that?
My lecture notes for complexity says that $\mathsf{ASPACE}(f (n)) = \mathsf{DTIME}(2^{O(f (n))})$ I can prove the forward direction ($\mathsf{ASPACE}(f (n)) \subseteq \mathsf{DTIME}(2^{O(f (n))})$) by building a computation tree of the alternating Turing machine and rejecting after $\ge 2^{f(n)}$ time steps and then me...
I am trying to create a PDA with at most 7 states that accepts the following language over the alphabet $\Sigma = \{a,b\}$: $$ \{a^{2k}b^{3k} \mid k \geq 0\} $$ The tricky part is that multiple push allowed but multiple pop is not allowed. I was able to find the easy solution when multi push/pop is allowed. I am looki...
If we can make memory infinite, why don't we just give Deterministic Finite Automata an infinite amount of states? Why is it useful to define Turing machines and pushdown automata? Bonus question: Can we think of the universe as a big ass DFA? (Standart Model, interaction of particles, etc.) Sorry for the long list of ...
Suppose $f$ is a $\mathbb N$-valued partial function over a subset of $\mathbb N$. If $f$ is computable by a universal register machine program, is the constant partial function $$ g:\text{image}(f)\to\mathbb N $$ defined by $g(x)=1$ for $x\in\text{image}(f)$ and undefined elsewhere also computable by a universal regis...
I want to know what will change if we keep on using {0,1} for our Fourier analysis of boolean functions? What are the things, which can not be performed with {0,1} and can be done with {+1, -1}?
We have this algorithm which is supposed to find max matchings. = ∅; //the matching is initialized to zero for ( = {, } ∈ ) { //for each edge in the graph if ( x and y vertices are free) //check if M U e is a matching = ∪ ; } Give an example where this algorithm does not calculate a max m...
I was curious to see whether or not there was a common algorithm for mapping two unrelated data sets. So for example let's say I wanted to give you a spirit animal based on your name, birthday, zodiac sign, height, and weight. How would someone go about creating an algorithm based on that? Another example is something ...
Assume that the probability that a woman is above 80 years old is 3 times that of a man. How much information (in bits) do you get if you are given that a 80 year old person is a male? How should I approach such a question? I have learned about entropy and how to measure it but do not see any way to apply this knowledg...
Let's start with the well-known minimum hitting set problem (known to be NP-hard): given some collection of sets: $U = \{S_1, S_2, S_3\} = \{\{1, 2, 5, 9\}, \{1,2,7\}, \{42, 13, 23, 1, 2\}\}$ for example, we wish to find some minimum cardinality set $H$ composed of elements from the union of all elements of $U$ of such...
$N$ towns are given, which we can get to by passing through the northern and southern gates. If you enter a town through a gate, you have to use another gate to leave the town. The merchant would like to plan his journey in such a way that starting from any town, he visits all towns exactly once and returns to the star...
I have a bipartite graph $G=(U=\{U_1, U_2,\cdots\}, V=\{V_1, V_2,\cdots\} , E)$ such that edges don't "skip" the $V$ vertices. Meaning, if edge $(U_i, V_j)$ doesn't exist, neither will edges $(U_i, V_k)$ for all $k>j$. All vertices connected to $U_1$ are at the "first" $V_i$s, and all vertices connected to the last $U_...
The following question was sent to me by a friend and I didn't really ask him about its source so I couldn't provide the source of it. I solved the question and I need to ensure my answer not just for him but also for myself since it's important to me too. Question: Prove or Disprove: if $L$ is a decidable language, so...
I was asked to show the equality $ RP(1 − 2^{-2^{n}}) = P $, which seems wrong to me (?). The $ \supseteq $ direction is obvious, and I want to show the other direction. My first intuition was to run the algorithm that gives a false negative with probability $ 1-2^{-2^{n}} $ for $ n $ iterations, which will get me real...
I've been stuck on the following assignment taken from Cognition and Intractability: A Guide to Classical and Parameterized Complexity Analysis: Imagine that the following big-O expressions correspond to the worst-case running times of different algorithms, where $n$ denotes the input size and $p$, $q$ and $r$ are pot...
Alternating Finite Automata is a superset of NFA while being equal in expressive power to NFAs. It is defined by 6-tuple (Q∃, Q∀, Σ, δ, Q0, F) where all outgoing transitions from Q∃ are 'or'ed and that from Q∀ are 'and'ed. Is there an algorithm for converting AFA to ε-NFA, NFA or DFA? I tried searching in Google, but a...
I am developing a system which performs automated room allotment. We have finite number of rooms, each with varying capacity. Each booking request is also of varying size. The goal here is to minimize number of rooms used and minimize room capacity wasted. The only reason why we want to minimize number of rooms used is...
If we some how transform a Binary Search Tree into a form where no node other than root may have both right and left child and the nodes the right sub-tree of the root may only have right child, and vice versa, such a configuration of BST is inherently sorted with its root being approximately in the middle (in case of ...
Imagine that we are designing a system in which we have the action to brake or not brake. How can we write an LTL specification that guarantees that we cannot switch between braking and not braking within three time steps?
Consider a Boolean circuit using (2-input) logical-and, (2-input) logical-or and logical-not as basic components. The depth of the Boolean circuit is the length of the longest path from the input to the output. I wonder if Boolean circuits with a depth Polylog in the number of inputs are sufficient to express any Boole...
As far as I understand pipelining is a way to excecute a instruction every clock cycle. It is a process performed on single cores. My question is how does the control unit handle this, at some point the control unit will have to store results from a completed instruction while simultaneously decode or fetch a new instr...
What is the definition for the length of a regular expression? This question might sound simple, yet I cannot find a definition. Do I only count letters from the alphabet? Do * and $\cup$ count? For example: let r = $(ab)^*\cup$ $a$. What is $|r|$?
Given a graph with $V$ vertices and $k$, find a set $K$ of $k$ vertices of $G$. Let $c(v)$ be the distance (in BFS-like) of the vertex $v \in V$ to the closest vertex $u \in K$. How to choose the set $K$ such that the maximum $c(v) \forall v \in V$ is minimized? This is like a dominating set, but each vertex covers a r...
The problem concerns finding shortest paths in graph from a single source to a single destination. So in a general non-degenerate case of a weighted graph, Dijkstra's algorithm runs in O(E+VlogV). A* runs in expected time O(E), because It uses additional information to find the path faster. Now let's simplify the probl...
Say I have a set of documents $D = \{d_1, d_2, \dots, d_n\}$ in some natural language. Each document $d_i$ consists of a subset of words from a word pool $W = \{w_1, w_2, \dots, w_k\}$. For example, $\text{words}(d_1) = \{w_1, w_5, w_{7}\}$. $\text{words}(d_1)$ is an ordered multiset, but that isn't too important to th...
I saw this question on a test-prep site Given a CFG and a string, what is the relation between the number of leftmost derivations, the number of rightmost derivations and the number of parse trees? and the accepted answer was this For any unambiguous grammar, LMD and RMD is same and we have only 1 parse tree. Ther...
I’ve had this question for several years now but have next to no programming experience, nor good connections to anybody who does. So I decided to see if stack exchange had an answer. The idea is to make a program that takes some linguistic, grammatically correct set of words (such as a sentence or phrase), substitutes...
I got an assignment to create a new data structure, with the following rules: Init - O(1). Insert x - O(log$_2$n). Delete x - O(log$_2$n). Search for x- O(log$_2$n). Find max difference between two values in the DS - O(1). Find min difference between two values in the DS - O(1). I've outlined the basics of the struct...
I have started to play around with HTTP3 which relies on QUIC for transport. I have noticed that I very often have a finite number of Web Transport sessions stream data continuously along side burst-y HTTP3 REST calls. At the QUIC level, all of these streams are going over the same connection and are demultiplexed via ...