instruction
stringlengths
35
29.1k
I am trying to understand this question from Prof. Onur Mutlu's assignment solution on virtual memory. I am reproducing the problem and solution followed by my question: Problem: A dedicated computer architecture student (like you) bought a 32-bit processor that implements paging-based virtual memory using a single-lev...
In the Bellman-Ford algorithm's relaxation part, I can't seem to understand why we need to use (d[v] = min{ d[v], d[u] + c(u, v) }), the (c(u,v)) part. This uses the original weight. Why can't it use the least cost(shortest) between (u,v) instead of c(u,v)?
Let $H(n)$ be the average height of a BST with nodes from ${1,...,n}$. I think that $$H(n) = \frac{1}{n}\sum_{i = 0}^{n-1}\left[\text{max}(H(i), H(n-1 -i)) + 1\right]$$ But I don't know how to prove this is correct. Can anyone help me or explain why this is incorrect? Note proving it directly seems hard because you end...
Consider this context-free grammar: $$G:\\\;\; S\to aSbb|aaSbbb|\lambda$$ Is the string $a^{2020} b^{4020}\in L(G)$? I try to derive such a string but I can't, how it possible?
I wrote code for the Regular Simplex (RSM) and the Irregular Simplex (Nelder-Mead Method (N-MM)) in Visual Studio in C++. For given functions (quadratic (QF), Rosenbrock with alpha = 1 (RF1), Rosenbrock with alpha = 12 (RF12)), starting points ({-1, -1}, {2, 2}), accuracies (1e- 2, 1e-5) received the number of iteratio...
How is the best way to go about proving that a greedy algorithm is optimal, inductive vs contradiction, are there parts in the proof that are key to include. I did not feel that the lesson I was given adequately covered how to start a greedy proof, any advise on a general way to go about proving greedy algorithms woul...
I've implemented a ranking system (based on a score), using a Map<Player,Score> and an improved BST<Score, Set<Player>>. So now I can compute "rank of a player" in O(log(n)) time, "top xxx players", insert/update/remove in O(log(n)) time. Now I want to improve my data structure to remember the "best rank" of each playe...
Suppose I have a function $f: \mathbb{R}^n\rightarrow\mathbb{R}$. All I know about the function is, I have a set of pairs of vectors ($\vec{v}_a$, $\vec{v}_b$) for which I know which one is greater (i.e. I know that $f(\vec{v}_a)>f(\vec{v}_b)$). I want to find the minimum of the function (or at least a good approximati...
I have a problem where I need to connect branches of multiple trees with edges such that every start node is connected to every other start node. Each tree can branch at a second node into 1-3 branches, with the count of branches always being even. I've implemented a solution, but it's not very readable or maintainable...
I'm studying heuristics for a course in my Master's. Our professor has told us that in order to point to a higher grade in the exam, we should check if our algorithm hits a stagnation points and that we have not seen any clear improvements to the optimum we have found. He asked it for some algorithms, especially the Si...
Suppose $L=\{ww^r:w\in\Sigma^*\}$. Already, we know that we can draw a PDA for $L$ such that accept each $w\in L$ with space complexity at least $|w|$. My question is how is it possible to draw a PDA that accepts or rejects $w$ with space complexity $\frac{w}{C}$ for some constant $C$? Any help or hint will be apprecia...
In most US universities, undergraduate students must satisfy the requirements of a degree program in order to graduate. The general rules are: The university has a minimum number of total credits needed, and a series of subject-based baskets (e.g. sciences, humanities, writing, etc) with their own minimum credit count...
While reading an article devoted to the sparse self-attention, I came across a notation that was not very clear: $$ Attend(X, S) = \Big( a(x_i, S_i) \Big)_{i∈{\{1,...,n}\}} $$ What means $\Big( \space \space \Big)_{i∈{\{1,...,n}\}}$ ? It would be great to describe this in more detail. Link to the article (page 4): ...
Suppose $L$ is regular and we define $L'=\{x:\exists y\in L \wedge \text{ y be a subsequence of x}\}$. Could we conclude that $L'$ is regular or not? I think it's not regular because if $L=a^*b^*c^*$ then $L'$ could be $a^nb^nc^n$ so it can't be regular.
public void m1(int n) { sum = 0; for (int i = n/2; i <= n; i++) { for (int j = 1; j <= n; j = 2 * j) { for (int k = 1; k <= n; k = k * 2) { sum++; } } } } So, I know that the innermost loop and second loop are $\log(n)$ and the outermost loop is essen...
I am implementing Earley parser and using algorithm from Elizabeth Scott's paper "SPPF-Style Parsing From Earley Recognisers" (section 4). Author says A family of children of u will consist of one or two nodes. However algorithm as described in paper fails at following grammar: <S> ::= <A> | <B> | <C> <A> ::= 'a' <B>...
i'm trying to make a game in which the player faces an infinite (finitely specified) series of enemies and has to specify a strategy that provably defeats all of them (ie defeats enemy n in finite time for all n). i'm intending to do it by having the player describe their strategy in a decidable language, which is then...
I have to analyze how every sorting algorithm's complexity would change if it had to sort a linked list and which of all of them is the most efficient. I find everywhere that merge sort is the most efficient one for linked lists, but I don't understand why counting sort isn't better. I think it would still be O(n). Am ...
In literature, Convolutional Neural Nets (CNNs) are presented as a special case of Deep Neural Nets (DNNs) (e.g., here). I do not understand how the convolutional layer can be implemented through a layer of neurons though. As far as I understand, a $n \times m$ kernel is used to calculate a single output feature over a...
An integer is $k$-smooth if its prime factors are at most $k$. In the case where $k$ is not tiny (say $10^8 < k < 10^{10}$), are there algorithms to test for $k$-smoothness, other than trying every prime up to $k$? Context: (1) The largest component $p^a$ of an odd perfect number is known to be greater than $10^{62}$. ...
I was reading the NeRF paper recently (https://arxiv.org/pdf/2003.08934.pdf), and under the positional encoding section, I see that the authors propose usage of the following function for transforming the input $$ \gamma (p) = (sin(2^0 \pi p), cos(2^0 \pi p), sin(2^1 \pi p), ..., sin(2^{L-1} \pi p), cos(2^{L-1} \pi p))...
This question is kind of a follow-up to a question asked a few days ago. Both of the non-linear complements of linear languages found were also not context free. So the question is this: Is there some linear $L$ such that $\overline{L}$ is non-linear but still context free? One attempt I've made was to look at the line...
I can't understand why do we have to use NFA to prove that concatenation operation is closed. According to sisper's book it says that we can't determine where to split the string, i.e. where to determine that we now have to transition from string of one language to another language. I still don't have a clear understan...
Crank disclaimer: I don't doubt the undecidability of the halting problem, but one proof confuses me. We have seen this folklore proof of the halting problem on several occasions. Assume a HALTING SOLVER ($HS$) exists with argument program $P$ and it returns true iff $P$ halts. Let SMART PROGRAM ($SP$) do the following...
I am interested in circuits that reduce $2^n-1$ input bits into their sum, represented as an $n$ bit integers. For $n=2$, this is a full adder, which can be implemented with 5 gates of 2 inputs in various ways. Alternatively, it can be directly implemented using 2 gates of 3 inputs (a parity gate and a majority gate)...
Given are n gene sequences (words over the alphabet {A, T, C, G}), each of length m. Find a gene sequence (of length m) that minimizes the maximum distance to all given gene sequences. Here, distance is measured as the number of positions at which the sequences differ. Show that the following problem is not efficiently...
Suppose I want to prove that $NP \cap coNP = P$. Since clearly $P\subseteq NP \cap coNP$, I need to prove the opposite direction, i.e., every problem in $NP \cap coNP$ has a polynomial-time algorithm. Is there a shorter way to prove this equality than arguing about all problems in $NP \cap coNP$? One obvious way would ...
We are all familiar with Bitonic Sort. The computations are predetermined and data-independent. Let's say we have a table A = [ 1,3,2,5,6,3,3,21 ]. The output after performing the sort is: A [ 1,2,3,3,3,5,6,21 ]. Observe that we have three entries with value 3 in indexes 1,5, and 6. My question is: After bitonic sort,...
I am trying the understand the following statement from the book of Grotschel, Lovasz and Schrijver: Here, $\delta(W)$ is the set of edges incident to a set of vertices $W$. They define an optimization problem whose solution is a nonnegative real vector. If we add a constraint that all elements of the vector must be i...
I am working on a problem that involves distributing a set of N supplements across a predefined number of meals (M) in a way that maximizes the total number of positive interactions and minimizes negative interactions between the supplements. Each interaction between the supplements is known beforehand (positive, neutr...
What theoretical concept lies behind the strong restriction of acquire semantics - to reads, and release semantics - to writes? (With papers titles and authors, if possible.) Is it related to provision of correctness of more complex approaches than lock-based synchronization (as lock-free, wait-free algorithms)? How th...
We know that $\widetilde{O}(f(n))$ — $O$ with a tilde above it — which means $O(f(n) \text {polylog}(f(n)))$, i.e., $O(f(n) (\log f(n))^k)$ for some $k$. Also I have seen in Wikipedia that $n2^n=\widetilde{O}(2^n).$ My question is that if $\text{poly}(n) \space 2^{xn}\leq2^{yn}$ then how it implies $x\leq y$? I have se...
As motivation, a Space Craft known as the Mars Climate Orbiter failed in the year 1999. The failure occurred because the distinction between pound-force seconds and newton-seconds was made as an comment, instead of being part of the code itself. Suppose that a student created a generic class (also known as a template ...
In this problem we consider two stacks $A$ and $B$ manipulated using the following operations ($n$ denotes the size of $A$ and $m$ the size of $B$):   PushA($x$): Push element $x$ on stack $A$.   PushB($x$): Push element $x$ on stack $B$.   MultiPopA($k$): Pop $min(k;n)$ elements from $A$.   MultiPopB($k$): Pop $min(k...
I came across this weird expression while learning about regular expressions. $R^+ \cup \varepsilon = R^*$ why does doing union with an empty string makes this regex go from 1 or more to 0 or more?
I am reading the example given in [1], section 4.2. It deals with applying weakest precondition (wp) rules to ensure that the velocity of a car doesn't exceed a certain limit. We have the following reinforcement learning equation and we want to constrain it across 2 timesteps - $v' = v + 0.1a + \epsilon$ Based on a pre...
I am planning to apply for master's degree at TU Berlin and have to take some courses on theoretical computer science since the university requires me to take some credits on theoretical computer science.Do these courses come under this category? 1-Graph theory:Basic definitions, trees, Cayley's formula, connectedness,...
I am planning to apply for master's degree at TU Berlin and have to take some courses on theoretical computer science since the university requires me to take some credits on theoretical computer science.Do these courses come under this category? 1-Graph theory:Basic definitions, trees, Cayley's formula, connectedness,...
I am planning to apply for master's degree at TU Berlin and have to take some courses on theoretical computer science since the university requires me to take some credits on theoretical computer science.Do these courses come under this category? 1-Graph theory:Basic definitions, trees, Cayley's formula, connectedness,...
I would like to find a target point in a 3-dimensional space. I do not know the exact location of the target, but I can measure to it from some of the points in the space with a metric that roughly approximates distance to the target (smaller metric values are closer to the target). The metric is noisy and it's safe to...
I have questions about how to put the grammar below in CNF - Chomsky Normal Form: S ->aAa | bBb | ВВ; A -> C; B -> S | A; C -> S | ε; I did it like this: I eliminated empty productions: S ->aAa | aa | bBb | bb| ВВ; A -> C; B -> S | A; C -> S; I eliminated unit productions: S ->aAa | aa | bBb | bb | ВВ; A -> aAa | a...
I am preparing for my algorithm and data structures exam. In the code below, I need to prove the correctness of tripSort for arrays of a size >=3. I am trying to do that by using loop invariants. The subarray A[n-2j+1,n] is the loop invariant I chose, where j refers to the iterations of the while loop. Is this the corr...
Can putting information systems through a "functional bottleneck" to approximate their Algorithmic Information reduce their attack and argument surfaces substantially? Software surface may be defined in terms of its complexity, both as attack surface and as argument surface. While cyber attack surface is well known in...
Is the language $$L = \{M | \exists M' \text{ that stops on the same input words but L(M)} \neq L(M')\}$$ in RE or R? I suspect that it's not in RE, since you'd have to first know for M all the inputs for which it halts, which you can't do in a finite time. I wanted to show that $\overline {HP} \leq L$, and so because ...
I have large cnf with thousands of variables, but with known compact backdoor set. I think this set can be used by CDCL solvers to choose assignment variables to simplify formula much faster, but I failed to find solver with such feature. Kissat and cadical (top performers of SAT competitions) can't do that. Is there a...
What is the algorithm behind this routine and is there documentation available for it?
Show that it is not possible to construct the toffoli gate using only CNOT gates, given we are allowed to choose any number of ancilla bits. My Attempt The action of a toffoli gate can be defined as, \begin{align} f_{toffoli}:(x,y,z)= &(x,y,z\oplus xy)\\ =&(x,y,z\overline{xy}\vee\bar{z}xy)\\ =&(x,y,z(\bar{x}\vee\bar{...
Let $\epsilon > 0$. For $P\subset \mathbb R^d$, a subset $Q\subset P$ is called an $\epsilon$-packing if: for every $p \in P$ there is a $q\in Q$ such that $d(p,q) \leq \epsilon$, and for every $q, q' \in Q$, we have $d(q,q') \geq \epsilon$. (See also the definitions here). Question. What algorithms exist for computi...
this code aims to determine whether there exists a contiguous subarray starting from index 0 in the given array A whose elements sum up to the target value S. can we apply Master theorem to find out its complexity public static boolean subsumFun(int[] A, int S, int i, int j) { if (i >= j) return S == 0; ...
I am reading C++ Concurrency in Action and it says that always locking mutexes in a certain order prevents deadlocks. However, this is not a computer science book and no proof is given for this claim. I would like to develop some (more) intuition for why this is, with ideally a proof to convince me.
I am studying the greedy algorithm for maximal weighted matching in arbitrary graphs. I have proven that this algorithm has approximation factor $\frac{1}{2}$. Assume now that the weights in the graph are such that if $W = ⟨w_1, w_2, \ldots , w_{|E|}⟩$ is the weights sorted in increasing order, then $w_i \leq cw_{i+1}$...
Recently, when I self-learnt Discrete Mathematics and Its Applications 8th by Kenneth Rosen, it says in 12.4 Minimization of Circuits which uses the Karnaugh Map or the Quine-McCluskey method: Minimizing a Boolean function makes it possible to construct a circuit for this function that uses the fewest gates and fewest...
Let $I$ be a set of items; $C \subseteq \mathcal{P}(I)$ be a set of subsets of $I$, where $\mathcal{P}(I)$ stands for the power set of $I$; And $C(i) = \{ c \in C \mid i \in c \}$ be the set of sets, in $C$, containing item $i \in I$. We state the following definitions. Definition 1: We say that $\mathcal{C} \subsete...
To show $\text{PSPACE-completeness}$ of $\text{SPACE-TMSAT}$, we perform a polynomial-time reduction of $\forall L \in \text{PSPACE}$ to $\text{SPACE-TMSAT}$. The language $L$ can be decided by a TM $M$ that takes at most $O(n^k)$ space for some constant $k > 0$. Does the reduction require the value of this constant $k...
I have a weighted undirected graph G=(V,E,W), I want to find an independent set S of V, such that if we sort the vertices of S in increasing order of their weights, the cumulative sum of the weights is maximized. In other words, if we suppose without loose of generality that $S={v_1,...,v_h}$ are the vertices of $S$ so...
I am reading some heavy hitter (HH) papers when I run into the following reduction theorem. The theorem attempts to reduce an HH problem with a very small tail frequency $\epsilon$ to multiple HH instances with higher tail frequencies. More precisely, the reduction utilizes a random hash function $h$ that throws an ite...
In the Question here it is said that $|xy^2z|<2^{p+1}$ Considering that $|x| = 0$ and $|z| = 0$, y consists of $2^{p}$. It's probably trivial, but how do I see, that $|xy^2z| < 2^{p+1}$?
I have this proof trying to show L={0}^* {1}^* is not a regular language, I know that L is regular but I don't know what in this proof is wrong. If y contains a 0 and 1 and is pumped wouldn't that make the any word not be in the proper form like going from 000111 to 0000101111? Let p≥0 . We construct w=0⌈p/2⌉1⌈p/2⌉ ; w...
I need to find a way to split an AVL tree based on the amount of nodes in the tree, lets assume you get a number $k$ and if the number of nodes in the tree is multiplication of $k$ you need to find the maximum of each tree in the $k$ trees. for example: for $k=3$ 3 / \ 2 9 / / \ 1 4 11 after...
Using the Pumping-Lemma for $ \{L = a^nb^n | n \in \mathbb{N}\} $. We define $p \in \mathbb{N}$ It exists a word $w = a^pb^p$ For every $|w| \ge p$: $w=xyz$, $y > 0$, $|xy| \le p$ Because of $|xy| \le p$, we can say that y only consists of a's or b's. For the language to be regular $|xy^iz| \in L$ Which means $|xy...
I cannot help but wonder: how to compute an inverse of a suffix array, preferably in linear time? For $ISA$, it holds that $ISA[SA[i]] = i$.
Let $G = (V, E)$ be a directed weighted graph such that all the weights on the edges are positive. In $G$, we have two nodes, $v$ and $u$, that have a path from $v$ to $u$. The question asks to find a set of edges $ E' \subseteq E $ with the minimum weight such that $G' = (V, E') $ has no path from $v$ to $u$. I tried ...
I'm taking an automata class and one of the examples is showing this is regular. My initial thought was to make a DFA to show it is but i'm a bit confused on what a DFA with a standard 5 tuple would look like for this. I know my alphabet is all the combinations of 0,1,2 for the columns and that my final state would be ...
Something I was asked to solve and tried to come up with a formula or some method to solve it after I did and couldn't. Given is a graph G=(V,E) that is undirected and weighted. Say we want to find the lightest paths tree (assume using Dijkstra's algorithm), we will call it K, and the Minimal Spanning Tree (assume usi...
I'm kinda confused on how to construct this DFA. I'm trying but keep running into the problem of reading an a after the b's or what to do if starting with a 'b'.
I'd like to count the number of left to right maxima in a permutation in Sage/Python, i.e. the number of times a number appears in the permutation that is greater than all of the previous numbers. The first number will always count as a maxima. I'm struggling with how to formulate the 'if' statement to include all prev...
The problem statement is the following: given a non-empty set P of (x, y) points with an associated reward, find the path through P that gives the maximum earning. The earning of a path is the sum of the rewards minus the total cost of visiting each point, measured as the distance between any pair points. I have to des...
I am reading about Datalog+- (e,g, https://ieeexplore.ieee.org/abstract/document/5571709), and I have a doubt about its semantics, and about the complexity of query answering. In Datalog+-, you write sets of TGDs whose chase is not guaranteed to terminate. However, Datalog+- guarantees that, for the problem of query an...
Lets take the Language $$L = \{ (ab)^na^k | n \ge k \}$$ Does it dictate, that the $(ab)^n$ comes before the $a^k$ ? Or is the order irrelevant as long as it matches the $n \ge k$ criterium? In simple terms: is the word $aaaababab \in L$ ? And if so, does this apply for every language?
Example $L = {(ab)^na^k|n\ge k}$ When searching for a word $w$, using $p \in \mathbb{N}$, for instance $(ab)^pa^p$, but wanting to pump $a$ (which is not possible because $|xy| \le p$ holds), how do I deal with that? I would need a variable $j \lt p$ for $(ab)^ja^j$ to have the possibility that $a \in y$, so I can pump...
Given the language $L = \{ a^n | \text{n is odd} \}$ I'm looking for a word $w$ using $p \in \mathbb(N)$. For example, if it would be even, instead of odd I'd choose $w = a^{2p}$. But with odd, I'm really struggling to find a word. What do I do? Define a variable $j$ and say $\text{j is odd}$ so $a^j \in L$ I know the...
On page 77 (section 6.1) of Types and Programming Languages by Benjamin C. Pierce (1st and only edition thus far), there is the following quote regarding naming contexts and de Bruijn indices: Γ = x ↦ 4, y ↦ 3, z ↦ 2, a ↦ 1, b ↦ 0 Then x (y z) would be represented as 4 (3 2), while λw. y w would be represented as...
Can someone please explain me how to solve this? In this post here was one user sketching the solution but I still don't understand how to construct a context-free language $L$ in such a way that the words in $L$ of the form $ww$ are $a^mb^mc^ma^mb^mc^m(m≥0)$. How does the grammar for L looks like? What equalities have...
The problem statement is: Given a search algorithm that finds and returns a k-colored graph for $k \ge 4$ if one exists, and otherwise returns false, show that there exists a search algorithm for 3-coloring. My idea is to connect each vertex $v \in V$ to another colored vertex(all new vertices are colored in the same...
Does someone know a proof for Camerinis Algorithm for finding a minimum bottleneck spanning tree? To my knowledge its the only algorithm that performs in linear time to solve this task but I cant find a correctness prove for that. https://stackoverflow.com/questions/22875799/how-to-compute-a-minimum-bottleneck-spanning...
I have a doubt regarding relation between MTTF (Mean Time to Failure) and FIT (Failure in time). Is it FIT = 1/(MTTF1 + MTTF2 + ...) or FIT = 1/MTTF1 + 1/MTTF2 + ... ?
Prove That the Language $L_1 = \{0^i1^j0^k | i < j\ or\ i > k\}$ is not regular using the pumping lemma. I am not sure how to begin with this I ended up using the string: $0^p1^{p+1}0^{p+1}$ S = 00001111100000 It holds for the conditions because the first set of 0s is less than the set of 1s, and the last set of zeros ...
The simplest Reduction for 3-SAT to 1-in-3-SAT reduction is as follows: For each 3SAT clause: $x+y+z=1$ Introduce 4 new variables $\{a, b, c, d\}$ and replace original clause with below 3 clauses: $R(x^-, a, b)=1$ $R(y, b, c) =1$ $R(z^-, c, d)=1$ In a similar vein is what is the generic way to convert N-SAT to 1-in-3...
I have an object mesh. This is loaded into a physics simulator, which does a convex decomposition. Now I want to perform operations outside the simulator that require a mesh representation. I could use the original object mesh but in many cases the convex decomposition is quite rough (the difference between object mesh...
Say we're back in the 1950s and our clunky computer has a $1$ kilobyte memory. $1$ kilobyte is $1024$ bytes, which is $8192$ bits. When we consider the entire available storage space, there are $2^{8192}$ states we can harness (each bit can be on or off), but in actuality we only utilize $1024$ size-$8$-bit states. In ...
I've been working on proving that this language L = {x ∈ {a, b}∗ | na(x) < nb(x) < 2na(x)} is not Context Free. "na(x)" stands for "number of a's in the string x". I however can't find a string where all possible divisions of the string can be pumped out of the language. For example, I tried a^(p+1) b^(2p+1), but I ca...
Let $G$ be a graph and let $v$ be a vertex. Is there a polynomial algorithm for the following operation? Operation. Find all the induced paths in $G$ with first vertex $v$. Background This problem is the confusion I encountered while reading the article Induced paths in graphs without anticomplete cycles. The authors ...
In the CSES problem Sliding Window Cost, given an array and an integer k, we are asked to compute the minimum cost for each sliding window of fixed size k. The minimum cost is defined as the cost of making all elements equal. Therefore, it can be expressed as the sum of differences between each value and the median (co...
I'm looking for an efficient algorithm to merge a list of overlapping intervals (each of which has data associated) into non-overlapping intervals. In case two or more intervals overlap, the latter one wins (e.g. the later intervals shadow the earlier ones). In my case, the intervals actually come pre-sorted (by starti...
I run the Python code below. x and y differ in their 4th and 5th number, and x has larger values. The program correctly shows that there is a difference between the two sums, and the difference is not that small. I therefore expect that the sum for y is smaller than the sum for 'x'. However, it shows that x has the sam...
The total number of Turing machines is the cardinality of the set of natural numbers. Now consider the following functions f1(x) = x + 1 f2(x) = x + 2 f3(x) = x + 3 and so on Since the total number of these functions is also the same as the cardinality of the set of natural numbers, each of these functions can be ass...
My understanding why distributed transaction need synchronized clock is the following Assume NTP max drift is 250ms true time = 100ms node A local time = 100ms node B local time = 0ms the following transaction will run into conflicted sequence transactionA arrive nodeA at (true time 100ms, A time 100ms, B time 0ms) tr...
I've only recently started learning about deterministic/nondeterministic finite automata and languages and I'd like some clarification on common notation used to describe languages. A 0 or 1 raised to an nth power just means that 0 or 1 occurs n times, correct? For example: the language $L = \{ 0^n \mid n ≥ 1 \} \cup \...
Are there existing SAT solver libraries that can count the number of solutions of a boolean formula? Can you give examples? I mean implementations more efficient than the naive approach, i.e. each time a solution is found, a new clause is added to prevent it to be found again.
I am having hard time creating regex for languages where symbols must be in certain length. I hope I am not ignorant about rules. we have to generate regex using $^*,|,+ \text{ and }\cdot$ right? I am expected to generate a regex for the language $\{ L = \{ w ∈ \{0,1\}^∗ : |w|_0 and |w|_1 \text{ is odd } \}$. both 0s a...
The problem: Given $k>1$ Turing machines decide if for every possible input exactly one of them halts. Is this variant of halting problem undecidable? Intuitively, it seems that it must be not only as hard as the standard halting problem, it actually is harder. Because even if you have a refutation input string, you'...
I've just read the Punycode spec in RFC 3492, as well as descriptions of it across some other articles. Punycode uses a numeral system the authors called "generalized variable-length integers" (is that term well-known in maths in general?) to encode a sequence of integers in a bijective way. My question is about why th...
I am studying about 2Q Cache Replacement Policy and i came across this post. They have worked out an example with the following page keys [1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5] and cache memory of 5 pages. A1in size is 2 and A1out size is 3. For the 10th page (i.e) 3, even though the page is available in A1out, why ...
can someone help me with this problem? Consider a hashing scheme that uses r hash tables T1, . . . , Tr of size m, where collisions in each table are resolved by chaining. When a key k arrives, it is hashed into each table Ti using hash function hi, and then stored in table Ti having the smallest chain in location hi(k...
Fagin's Theorem (see Wikipedia and these lecture notes) states that there is an equivalence between second-order logic (SOL) formulas with existential quantifiers, and problems in NP. I was wondering if we can also extend this result to other complexity classes in the polynomial hierarchy? For example, can we state tha...
Assume a variant of a one-tape deterministic Turing Machine that reads and writes on the portion of the tape that the input $w$ appears (like linear bounded automata). My question is, how we could bound the time complexity for membership in this type of Turing machine? I think the time complexity could be the worst as ...
So in an exam, this was the recurrence: $$ T(n) = 2T(n/2) + n log(n) -n + O(log(n))$$ $$T(1) = 1$$ Why does the master method not apply here? I think it is indeed int he form $$aT(n/b) + f(n)$$ You can say: $$a =2$$ $$b = 2$$ $$f(n) = n log(n) - n + O(log(n))$$ My guess: $O(log(n))$ is too broad and cannot work for the...
The programming language is C++, and the elements of the input vector are of type int and able to take all valid int values. So it’s not possible to store extra information in the input vector. Now, is it possible to sort the vector in linear time and constant extra space? Simple solutions are preferred. And to avoid r...
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f$ such that $\forall A:U(A)=T(f(A))$, where $A, f(A)$ are finite sequences of symbols (that are given as inputs) and $U$ is a universal Turing machine. Is there any connection between effectively universal Tur...
I was thinking about quicksort with multiple pivots and I came across this question. How can we efficiently implement a version of Quicksort where we choose $k−1$ pivots to partition an array of unique numbers into $k$ classes? My goal is to demonstrate that this multiary partitioning can be achieved in $O(n \log k)$ t...