instruction
stringlengths
35
29.1k
I cannot figure out how to go about proving this statement in regular expression. $$ L(R_1) \subseteq L(R_2) \subseteq L(R_3) \implies L(R_1^*+R_3)^* \subseteq L(R_2^*+R_3^*) $$ Here's what I have so far: Since $L_1 \subseteq L_2 \implies L_1^* \subseteq L_2^*$ then $L(R_1) \subseteq L(R_2) \subseteq L(R_3) \implies ...
I have a system of linear equations over a finite field $\mathbb F_p \cong \mathbb Z_p$, and I'm interested in the decision problem of whether there exists a solution where all of the variables $x_i$ are in the set $\{0, 1\} \subset \mathbb F$. In particular, I'm trying to determine whether this problem is $\mathcal{NP...
There are many excellent step-by-step courses (free and paid) teaching you how a specific programming language works and how to use it to create applications. I've benefited a lot from these courses. Now, I'm looking to go a layer deep and learn how to create a programming language from scratch (such as javascript or p...
I have read Why is the dynamic programming algorithm of the knapsack problem not polynomial? and other related questions, so this is not a duplicate but just a related pair of questions to clear some doubts. A question that frequently arises when discussing the complexity of the dynamic programming solution for the KS ...
Is there a reduction from SUBSET-SUM to SAT? Just general SAT, not 3-SAT. Also the given multiset S only has positive integers. SUBSET-SUM is defined as follows: Input: a multiset S = { x1 , ... , xn } of positive integers and a positive integer t Output: accept if there exists a sub-multiset { y1, …, ym } ⊆ S such tha...
Consider a graph $G$ with minimum degree $d$, we know through sets cover, it's possible to find the one dominating set $S$ that covers $G$ such that $$S\leq O(\log n)\frac{n}{d} $$ with high probability, But is it possible to find a deterministic algorithm that achieves this bound in polynomial time?
I am trying to prove Theorem 6.2 on page 127 of the book Real-Time Systems by Jane W. S. Liu: http://www.cse.hcmut.edu.vn/~thai/books/2000%20_%20Liu-%20Real%20Time%20Systems.pdf It is based on Early Deadline First(EDF) scheduling. It says the proof is similar to the proof for Theorem 6.1 on page 124-126. However, I am ...
I would to optimally assign objects into slots. There are 2 lists of 2 different elements that have to be assigned. An element from list 1 must be grouped with an element from list 2 into one slot. The slots are linked (they have 1 or 2 adjacent slots). There are some constraints on an exact number of slots that an ele...
I want to visualize or calculate the compression bounds for hypothesis classes. I learnt how to figure out the VC dimension. Let's say I define two hypothesis class. For example: $$ H_k = \{h ∈ (0,1)_X \mid |h^{−1}(1)| ≤ k\} $$ and $$ H_{decst} = \{h^i_a \mid a ∈ R, i ∈ (1,2)\}, \text{ where } h^i_a((x1,x2)) = 1[x_i ≤ ...
I have a Context-Free Grammar (CFG) G which has a S for generating a language L. Now to produce a grammar for L*, another variable T (which is not present in the variable set of G) is taken and the grammar is produced in the following way: G' = (V, A, T, P) where, G'.V = G.V U {T} ...
What is the currently know fastest algorithms to convert each individual Java primitive and Number types to a Char Array/String number representation while considering their range, endianess and layout, sign and JVM specifics? The algorithm used for say byte may differ from int due to the range. char would be a special...
I am looking for a family of pairwise independent hash functions $\mathcal{H} = \{h \mid h:[n]\rightarrow [m]\}$ that is easily computable. As an example that doesn't seem to work, choose a prime $p > n$ and $a,b \in \{0,\dots, p-1\}$ independently and uniformly at random. Now let $h_{a,b}(x) = ax+b \bmod p \bmod m$. ...
I am working on a personal project and I am having some conceptual level questions on arithmetic encoding. Let's take a scenario where I have an array of sensors and the data collected is transmitted over the internet to Alice. Naturally to decrease transmission cost I would want to transmit data in compressed form. B...
1-OR-3-SAT: Input: 3-CNF formula $\varphi$ Question: whether there is an assignment $x$ such that in each clause there are one or three true literals. I need to show that this problem is in $P$. I tried to construct a reduction from this problem to 2-SAT that is in $P$. What can I try here?
Is there a name for the relationship between two DAGs A,B where B is one of the transitive reductions of the transitive closure C of A? For example the connectivity of nodes in both graphs would still be the same. For example, we can connect all nodes in A to their minimal elements (smallest subsets) in A and remove al...
I have the following the statement and I have to prove whether it is true or not. Given a planar and Hamiltonian graph $\mathbb{G} = (V, E)$, show that we can partition $E = E_1 \cup E_2 = E$ so that $G_1 = (V, E_1)$ and $G_2 = (V, E_2)$ are both connected and outerplanar graphs. I have tested the statement for few g...
I need ’n’ random numbers that: each one is bigger than ‘a’ their sum is smaller than ‘b’ How can I have that in Matlab?
I came across the algorithm question of detecting a cycle in a linked list, but the solution has to be constant space O(1). I have looked through various proofs proving that: If there is a cycle, at some point the tortoise and the hare will meet. I understand that at some point, both will be within the cycle, but how ...
Wikipedia: In computing, a compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language). This implies that the compiler can also convert from a low-level language to a high-level language. But this has also got a spe...
The well-known Church encoding of natural numbers can be generalized to use an arbitrary (covariant) functor F. The result is the type, call it C, defined by data C = Cfix { run :: forall r. (F r -> r) -> r } Here and below, for simplicity, we will assume that F is a fixed, already defined functor. It is widely know...
I am learning distributed systems ( although I am an Electrical engineer ) using the book distributed systems concepts and design. The author says that "A web server is often a client of a local file server that manages the files in which the web pages are stored." I cant understand in the first place what is the relat...
I find very interesting the problem of existence of a machine $H$ which given as input any algorithm $P$ outputs whether $P$ halts or not. Alan Turing disproved the existence of such an $H$ machine in the following way: "Assume $H$ exists. The input of $H$ is any algorithm $P$. The output of $H$ is $YES$ if $P$ halts a...
In the context of variational autoencoders, we want to maximize the evidence lower bound and this is typically done using Stochastic Gradient Variational Bayes (SGVB). I was curious if there is any work out there or ways to determine the time complexity of SGVB.
An almost complete graph of n vertices is obtained from the removal of two edges of the complete graph of n vertices. For which values of n are there almost complete graphs that admit Eulerian paths? I'm having difficulty with this issue that I saw on an internet site, please help me.
I was wondering if there are any resources for a study/ranking of the most frequently used statements (by statements I mean assigning, invoking, instantiating etc, like in C#) in programming overall (or at least for one modern language). This is for a private research project where I am writing my own bytecode assemble...
It is known that there does not exists an oracle $H$ which given any pair $(M,I)$ where $M$ is a machine and $I$ is an input (possibly still a machine) to have $H(M(I)) = YES$ if $M(I)$ halts and $H(M(I)) = NO$ if $M(I)$ does not halt. This was proven by Turing. However, this can be shortly written as $$ \not\exists H ...
Let us consider the set of machines/algorithms with constant inputs (I would have preferred to say no inputs but I was told that every algorithm/machine has to have an input). We call $\mathcal{M}$ the set of all machines and define $C \in \mathcal{M}$ as follows: $$ C(I) = \begin{cases} LOOP, \hspace{0.5cm} I \neq C\\...
Prove that the following problem is undecidable using a reduction: Given a Turing machine $S$, does $S$ accept a word $w$ iff it accepts its reverse $w^R$? There is a solution here, which I don't understand. We reduce from the halting problem. Given a Turing machine $M$ and a word $w$, we construct a Turing machine $...
I am trying to apply the minimax algorithm to a game of Pokemon. This is a problem where the search tree is usually around 20 levels deep (number of turns) and each level has 9 or less branches (number of choices per turn). What I am wondering is if this is a computationally feasible problem using parallel computing? M...
How to show that for $\epsilon>0$, there exists a function $G:\{0,1\}^n->\{0,1\}^{2^{\epsilon n}}$ that is a $2^{\epsilon n}$-prg, without the condition that is is computable in $2^{O(n)}$ time. What I am trying to show is with high probability, if we take $\epsilon=1/10$, a random $G$ satisfies this condition. But in ...
Suppose I want to find a number that is divisible by all 3 digit numbers (100-999), how do I write a code for that. I know only "1" can divide all 3 digit numbers, but I just want to know the logic.
A distribution $P$ over $\mathbb{R}^{d} \times\{-1,+1\}$ being $(\gamma, R)$ -separable. We now let $\mathcal{P}_{\gamma}$ denote the set of all $(\gamma, 1)$ separable distributions. For a distribution $P \in \mathcal{P}_{\gamma},$ we let $\mathbf{w}_{P}$ denote the unit length (ie. $\left.\left\|\mathbf{w}_{P}\right\...
Which is the lowest level of code (human written instruction for computers) in computer architecture? After doing minor research, I have come to the conclusion that, as far as determining a hierarchy in terms of the level of computer code, the following is the general level of code hierarchy: High-Level->Low-level->Ass...
I try to find tree height such that first i define: $H(n,k)=H(\frac{n}{2},k)+H(n,\frac{k}{4})+1$ then find height of left branch of tree=logn & right branch of tree=logk,but now why height of tree is equal to logk+logn?i guess height of tree is Max(logn,logk)why my geuss is not true?
Just checking if this version of Max Cut is still NP-hard: Given a fully connected graph $G(V,E)$, where every vertex is connected to every other vertex, and where every edge has a weight associated with it. Find a cut in $G$ such that the average weight of the cut edges is maximal. See the example below, where other c...
The $\text{IEEE-754}$ uses $32$ bits to represent single precision floating point numbers. The partitions of the register are as follows: Biased sign Exponent Mantissa +-----+--------+---------+ |1 bit| 8 bits | 23 bits | +-----+--------+---------+ Now in general $8$ bits can represent $2's$ complement numb...
Let $L$ be an $\mathrm{NP}$ language. Then there exists a verifier $V$ of $L$ and a polynomial $p\colon \mathbb{N} \to \mathbb{N}$, such that for every $x \in \Sigma^{*}$, $x \in L$ if and only if there exists a certificate $u \in \Sigma^{p(|x|)}$ for $x$ satisfying $V(x, u) = 1$. Suppose that $\mathcal{V}_{q}$ be all ...
I have seen two observations from the paper by Har-Peled but I do not know how to prove them (i) If $C1$ and $C2$ are the $(k, ε)$-coresets for disjoint sets P1 and P2 respectively, then $C1 ∪ C2$ is a $(k, ε)$-coreset for $P1 ∪ P2$. (ii) If $C1$ is $(k, ε)$-coreset for $C2$, and $C2$ is a$(k, δ)$-coreset for $C3$, the...
I have seen two observations from the paper by Har-Peled but I do not know how to prove them (i) If $C1$ and $C2$ are the $(k, ε)$-coresets for disjoint sets P1 and P2 respectively, then $C1 ∪ C2$ is a $(k, ε)$-coreset for $P1 ∪ P2$. (ii) If $C1$ is $(k, ε)$-coreset for $C2$, and $C2$ is a$(k, δ)$-coreset for $C3$, the...
What is the difference between Hamming Distance and Manhattan Distance for non-binary data (specifically I am comparing points in $\mathbb{R}^2$)? I understand Manhattan sums the absolute difference in the and x and y directions but doesnt hammming distance do the same thing?
I have the following TRS $R$: $$ l_1 = f(g(x)) \to f(x) = r_1 \\ l_2 = g(f(y)) \to g(y) = r_2 $$ I want to know if $R$ is confluent, and whether $g(f(f(x))) \leftrightarrow_R^* g(g(g(x)))$. I have already proven termination. I use the fact that $t = f(y)$ is a subterm of $l_2$ and can find a substitution $\sigma$ ...
If $f(n)=n^a$ for a given $a>0$, I need to find a function $g(n)$ such that $f(n)\notin O(g(n))$ and $f(n)\notin \Omega (g(n))$. I am not sure how to find such function, which satisfies both of the conditions.
Are there any known techniques for "diffing" trees, such as phylogenetic trees?
We consider a set of sets $S = \{S_1, S_2, \dots, S_n\}$, and we want to find a subset $I$ of $S$ that maximises the size of the union of the set $S_i$ included with a penalty for each set included. We can represent this problem as the optimisation of the following quantity: $I = argmax_{I} |\cup_{S_i \in I} S_i| - |I|...
Is the decision version (i.e. does a solution exist) of this puzzle NP-hard (for an nxn puzzle)? It feels like it has very local strategies which allow easily solving the instances, but it's not obvious to me that these generalize to larger puzzles. The rules are as follows: Each tile has exits on some of its edges Ea...
If $L(R_1) \subseteq L(R_2) \subseteq L(R_3)$ then $L(R_1)^* \subseteq L(R_2)^* \subseteq L(R_3)^*$. Does this also imply that $L(R_1)^* \subseteq L(R_3)$?
I am having trouble with some homework regarding proving that DCONN is NL-Complete. As part of the exercise, the fact that RCH is NL-Complete can be assumed. Problem definitions: RCH: Given a directed graph G and nodes x, y , is there a path from x to y? DCONN: given a directed graph G, is it connected? To my under...
Given a string s and a hashset of strings words, what is the time complexity of the operation: s in words? Assume all strings have length M. My current guess is O(M) to compute the hash of s, O(1) to find that bucket in the hash table, and O(M*number of strings in the bucket) to compare the strings in the bucket and th...
Let $D_{1}$ and $D_{2}$ be two probability distributions over $n$-bit strings such that the total variation distance between them is $\mathcal{O}\left(1/{2^{n}}\right)$. Given as input a polynomial number of samples from any one of the distributions, the task is to output $1$ if the samples come from the first distribu...
This is my guess: -Use amortized because we want to know the "averaged" complexity over n operations assuming the operation is going to be used frequently -Use unamortized when you know the operation is going to be used rarely
Suppose we are given a language $\Sigma$ where, suppose, $|\Sigma| = O(1)$. Consider two fixed strings $A, B \in \Sigma^n$. Define the Hamming metric between these strings as $$d_{H}(A,B) = \sum_{i=1}^n \boldsymbol{1}\lbrace A(i) \neq B(i)\rbrace$$ If we define $B^{(k)}$ as the $k$-shift (to the right) cyclic permutati...
I was asked in an interview question, can a perceptron classifier ever reach 100% accuracy on some kind of non linearly seprabale training data in 2D. I said that no it can't because the data is not linearly seprabale. We then proceed to the next question, but maybe its just me, but from the look of the interviewr, I'm...
I'm now to problem solving, and I need some help and insight on the following problem from HackerRank: Given a sequence $p(1),\ldots,p(n)$ of distinct numbers from $1$ to $n$, find numbers $y_1,\ldots,y_n$ such that $p(p(y_1))=1,\ldots,p(p(y_n))=n$. My approach was to perform a double index lookup on each element in ...
I was thinking. Since any data can become linearly seprabale through kernel methods, meaning there is a dimension where this data is linearly seprable, so feed this processed data set into the perceptron algorithm and then it might get to 100 percent accuracy. Am I correct?
Here is the description for 3SAT satisfiability problem. I already know about the DPLL algorithm, but it's implementation is pretty complex. I would like some algorithm that is relatively simpler but improves the performance by some extent. I would prefer something that is not Tree/Graph based instead bit-mask or multi...
I am computing the count of the amount of intersections between disjoint horizontal line segments and disjoint vertical line segments. The algorithm I have come up with runs in $(2n+m)\log(2n+m)$ time. I was wondering if the Big-O for this is $O((n+m)\log(n+m))$? I don't know how constants in the interior of logs with ...
I want to know the speed of preorder traversal of an tree. I do not mean its order of magntude which we know is O(n). I want something like 27n operations where an operation is precisely defined. Thanks
These are the reduction rules associated with $\beta$ reduction and $let$: $$(\lambda x. e_2) e_1 \to_{\beta} e_2 [e_1 / x]$$ $$let \,x = e_1 \textit{ in }e_2 \to e_2 [e_1/x]$$ These reduction rules are very similar. What is the point of having $let$ as well as $\beta$-reduction? I can't see why it is of any use.
Proposition: The binary search algorithm runs in $O(\log n)$ time for a sorted sequence with $n$ elements. When justifying this claim, first we say that with each recursive call the number of candidate entries still to be searched is given by the value $$ high - low + 1 $$ The middle index, $mid$, is given by $$ mid = ...
In the simply typed lambda calculus if we have an addition operator, $+ : n \to n \to n$, its typing imposes that we can only combine it with something of a given type. So if $n$ is the type of natural numbers, we can only combine $+$ with things of type $n$. In the untyped lambda calculus can we invent a function whic...
Are there other encodings of the natural numbers in the untyped lambda calculus which are neither the Church encoding nor the Scott encoding?
I am searching for an algorithm with a time complexity of $\Theta(n2^n)$ time complexity. I am aware, that e.g. the Fibonacci sequence has a time complexity of $\Theta(2^n)$. My plan was to add a loop in the implementation, so that before you go into recursion, you are going to count from 1 to $n$. My question is, whet...
Sorry for the perhaps basic question, but my time at university is long ago and I need to brush up on Big-O stuff for interviews. My question is, what would the time complexity be when an algorithm does depend on the input but not on the size of the input? For example, assume I have this function: func doSomething(numb...
I am really new concerning loop invariants and I am currently trying to figure out a loop invariant of an algorithm for prime numbers. I tried a lot of ideas, but I still have problems since there are two nested loops. I am also really grateful if someone have any tips regarding finding a loop invariant. My idea is tha...
Two sorted arrays of positive integers, X[] and Y[] are given.But, the array sizes are unknown to us. We may assume that accessing any index beyond the last element of the array returns -1. The elements in each array are distinct but the two arrays may have common elements. An intersection point between the two arrays ...
It is not hard to show that $DSPACE(n+1)/2^n$ contains undecidability. But is it possible to make the advice string subexponentially long (while the machine is allowed to have any $poly(n)$ space) using some succinct representations? Or is this an open problem with potentially interesting results?
I have a question concerning the use of the Ford-Fulkerson algorithm. Since a minimum cost flow problem is a linear programming problem, it has a dual problem. That dual would be to maximize a certain function. Considering this, is it possible to apply the Ford-Fulkerson algorithm to that dual in order to solve the min...
Given a query instance $x_q$ to be classified Let $x_1,\ldots,x_k$ be $k$ instances which are nearest to $x_q$ $$ \hat{f}(x_q) \gets \operatorname*{argmax}_{v \in V} \sum_{i=1}^k \delta(v,f(x_i)), $$ where $\delta(a,b)=1$ if $a=b$, else $\delta(a,b)=0$ (Kronecker function). If $f$ is an objective function to be opt...
I was given the following recursive formula: L(m)=16L(m/2)+m and I want to find for which function f, L(m) is theta of f. In other words L(m) is big O of f and also small omega of f. What I did until now? Nearly 95% of the job but still not sure whether this is an omega or big O or theta...
Amdahl's Law generally divides a task into "things that can be parallelized" and "things that can't". Now, I know what "things that can be parallelized", and it's not too hard to imagine things whose parallelizations aren't obvious, but it's not clear to me what makes a task fundamentally non-parallelizable, whether s...
In his book "The Annotated Turing" in the first sentence on page 32 Charles Petzold wrote: These are binary numbers between 0 and 1, and (judging from the way we created these numbers) all the binary numbers between 0 and 1, and hence all the real numbers between 0 and 1. And then at the bottom of the page there is ...
$$\ T(n) = \sqrt{n} \cdot T(\sqrt{n}) + 1 $$ I've found so many similar questions but I couldn't understand any of the answers explanations. When I try to draw a recurrence tree, I see that each 'level' has as many operations as nodes (because of only $\ 1 $ operation in each node) so in the first level it has $\ 1 $ n...
We know that BPP is described as $\{L\mid \exists \text{ TM }M, \text{ s.t. }\Pr[M(x)=L(x)]\geq2/3\}$. I saw a proof which uses Chernoff bound to prove that any probability larger than $1/2$ can be turned to any probability in $(1/2,1)$. My question is what about probabilities below $1/2$. Do they fall on a different c...
Does free variables have some meaning in lambda calculus? If I follow this β-reduction (λx.λz.y x) y -> (λz.y x){x/y} (variable FV(y) captured) -> ((λz.y x){a/y}){x/y} (rename FV(y) -> FV(a)){ -> (λz.a x){x/y} -> (λz.a y) Here we have FV(y) captured during the β-reduction, so I rename it to FV(a...
I have the following question: We begin with a computer implemented in single-cycle implementation. When the stages are split by functionality, the stages do not require exactly the same amount of time. The original machine had a clock cycle time of 7 ns. After the stages were split, the measured times were IF, 1 ns; ...
I understand the concept that if there is no Hamiltonian path so there will be 2 smaller paths and with them I can build more then one topological sort but I am not sure how make it formal. Can you help me to structure the proof?
I know that this language is not regular L = {w | na(w) = nb(w)} where na(w) is the number of a's in w. But what if now the language changes to that the number of a's has to be greater than b's? I think not, because we do not have finite number of prefix equivalence class. And in that case, how can I prove it? Or if it...
I have the given regular language and i am suppose to check if it is regular and if it is, to provide a regular expression However, if the language is not regular i have to prove using the "Pumping Lemma" that it is not regular it is regular if, it can be represented by a finite state automata (FSA) or, if it can be ...
I was wondering which runtime is a tight upper bound for $f(n,m)= n^2 + 1/2^k$ with $k = n - m$ Intuitively I thought that $f(n,m)$ is in $O(n^2)$ but the longer I am thinking about this the more I tend to say that $f(n,m)$ is in $O(2^k)$. Can anyone help me?
In asymptotic notation the transivity holds, however what happens when we have small o such as if f(n)= o(h(n)) does that means that also g(n)=o(h(n)) holds? i take as granted that both of f(n)=o(h(n)) is true and f(n)= O(g(n)) (from THETA) then i need to show g(n) < c h(n) given that i have f(n) <= d g(n) and f(n) < c...
I'm trying to use the pumping lemma, to show that the language $$L = \{w \in \{a, b\}^+: na(w) = nb(w)\}$$ is not context free, where $na(w)$ is the number of $a$'s in $w$ and $nb(w)$ is the number of $b$'s in $w$. I have this: By contradiction, if $L$ is context free, we use the pumping lemma, then let $N$, and $w = a...
Euclidean division is an iterative process that has been made super-efficient at the CPU level, right? Its specification is that if I do (q, r) = f(n, d), I get super efficient result verifying that n = d * q + r with maximal q. I need to perform a similar decomposition of an integer number, into the highest inferior t...
I'm trying to grasp what does associative actually mean in n-way set-associative cache. I understand n-way set-associative cache as a concept; n is the degree of associativity, i.e., how many cache lines a set can hold. If I take associative to mean "having the tendency to connect", I get to the "sets tend to connect t...
Given a set of integers S (positive and negative, may contain duplicates) can S be divided into three disjoint subsets that all sum to the same value? Prove this problem is NP-complete. Is it possible to show directly that Subset Sum $\le_p$ 3-Partition, or would I have to do Subset Sum $\le_p$ Partition $\le_p$ 3-Par...
I have this language $L=\{a^nb^nc^n,n\geq0\}$, I know this language is not context free, but I don't know how to show that it is context sensitive, do I have to use a PDA?
As mentioned in several resources such as Wikipedia the optimal number of hash functions for a bloom filter is known to be $$k=\frac{m}{n} \ln 2$$ but how is this number derived? It seems that it's the number that minimizes the false positive rate which is equal to $$(1-(1-\frac{1}{m})^{kn})^k$$ Can anybody explain the...
Show that for every large enough $n$, there is a boolean function $f\colon \{0,1\}^n\longrightarrow\{0,1\}$, whose average case hardness is exponential. The question is taken from Arora Barak Computational Complexity textbook, Chapter-16, Ex-3. Average case hardness of a boolean function $f$ is defined as, the largest ...
I have the an algorithm for computing a matrix determinant: $$\ det(A) = \sum_{i=1}^n (-1)^{i-1} \cdot A_{i1} \cdot det(A_{-i,-1})$$ Where $\ A_{-i,-1} $ is the matrix $\ A $ without the row $\ 1 $ and column $\ i $ Drawing the recurrence tree, I see each level $\ k $ has $\ \frac{(n-1)!}{(n-k)!} $ nodes. So I think th...
I'm looking for suggestions on algorithms, data structures or at least problems (so that I look for solutions in that domain) to consider. I realize that exact solution probably doesn't exist. But the more similar problems/solutions I can find the more ideas they may inspire. We need to transfer reactants from source v...
Let $G=(V,E)$ be an undirected graph. I would like to maintain information about the connected components of this graph(I want to be able to tell in what component particular node is lying). The graph operations are the following (basically, everything except vertex deletion): Add vertex Add edge Delete edge What are...
I am unsure what it means for a grammar to be $X$. More specifically, what it means for a grammar to be LR(0). For part of an assignment I had to form the DFA for a grammar, which I had no issues with. And then I have been asked whether the grammar is LR(0). My guess is yes, but not because I understand exactly what it...
For a boolean function $f:\{0,1\}^n\longrightarrow\{0,1\}$ $H_{avg}(f)$ is defined as the largest $S(n)$ s.t. for all circuit $C_n$ of size $S(n)$, $\Pr_{x\in U_n}[C_n(x)=f(x)]<1/2+1/S(n)$. Here $U_n$ is uniform distribution over $\{0,1\}^n$. According to Nisan Wigderson 1988, I know that if there exists $f\in E$ with ...
Given an array of integers, how can we generate all the increasing subsequnces of length of 4 ? Example: given this list l = [1, 2, 4, 5, 3, 6] The answer should be : [1, 2, 3, 6] [1, 2, 4, 5] [1, 2, 4, 6] [1, 2, 5, 6] [1, 4, 5, 6] [2, 4, 5, 6] I generated this algorithm using python : def verif(x,temp): work=[...
I'm trying to find out what the data of a packet means. I'm a newbie to networking, and I try to find what's sent in this packet: https://pastebin.com/hZEqjmBx How can I do that? What does that data mean? How do you decode it, or is it crypted or something? I pasted the whole HEX + ASCII dump of the packet.
I need to proof, that both definitions of the Big 0 notation are equiavlent, but I am not sure if my proof works both ways of the equivalence. Definitions: Let f,g be functions. $f(n)\in \mathcal{O}(g)\Longleftrightarrow \exists c>0\exists n_0 \forall n\geq n_0 :f(n)\leq cg(n)$ $f(n)\in \mathcal{O}(g)\Longleftrightarr...
The exercise says "Show that the solution of $T(n) = T(\lceil{n/2}\rceil) + 1$ is $O(\lg(n))$." I came up with a solution for this exercise using the substitution method but I don't know if it is correct. My solution goes like this: I claim $T(n) \leq c\lg{n}$ and assume it holds for $\lceil{n/2}\rceil$, then $$ \begin...
I just read the chapter on locks in the book Operating Systems: Three Easy Pieces, and it discusses an implementation of locks (see in Figure 28.9) that involves a test-and-set hardware instruction. The textbook emphasizes that both hardware support and OS support are necessary to build an efficient locking mechanism. ...
An array of length K is called good if for each subarray of the array, the sum of the subarray is not divisible by K+1. You are given an array A of length N. Find the number of subsequences of length B of array A which are good. Since the answer can be large, return it modulo 10^9+7. Constraints: 1 <= N <= 1000 1 <= ...
I'm breaking my mind to find a good explanation to split two variables with the XOR operation. The operation is the following: x ^= y # => (x ^ y, y) y ^= x # => (x ^ y, y ^ x ^ y) = (x ^ y, x) x ^= y # => (x ^ y ^ x, x) = (y, x) and my doubt is about the second line, in particular (x ^ y, y ^...
I am trying to proof $f\in o(g)$ Let be $r,p\in \mathbb{R}$ with $p>0$ We have $f(n)=ln^r (n)$ and $g(n)=n^p$ I have already proofed that $ln(n)\in o(n)$ via l'Hospital $\lim\limits_{n\to \infty}\frac{\frac{1}{x}}{1}=0\Longrightarrow \lim\limits_{n\to \infty}\frac{ln(n)}{n}=0\Longleftrightarrow ln(n)\in o(n)$ I tried s...