instruction
stringlengths
35
29.1k
The kernel is $K(x,z) = \sum_{i=1}^D (x_i+z_i)$ My approach was trying to express $K = \phi(x)^T\phi(z) = (x_1 x_2 ... x_D \quad 1 1 ...1)(1 1 ...1\quad z_1 z_2 ... z_D )^T$ where $\phi$ is 2Dx1 and thus a Kernel. The solution says: K is not a kernel. Consider $x_1 = [1 \quad 0]^T \quad x_2 = [0 \quad 2]^T$. Their k...
$NP\cap coNP$ is low for itself: $NP^{NP\cap coNP}\cap coNP^{NP\cap coNP}=NP\cap coNP$. Going up to exponential realm, we are considering similarities of $NP\cap coNP$ to its exponential version $NEXP\cap coNEXP$. By padding, we already have $$NEXP^{NP\cap coNP}\cap coNEXP^{NP\cap coNP}=NEXP\cap coNEXP$$ Two questions:...
Consider the following C code: for(int i=0; i<100000; i++) { if (operation == 0) { a[i] *= 2; } else { a[i] += 1; } } Would a real compiler (GCC) be able to do this optimization? If so, what is it called/how is it found? if (operation == 0) { for(int i=0; i<100000; i++) { ...
In CLRS 3rd edition P. No 86, the relation $T(2^{n}) = 2T(2^{n/2}) + n$ is changed to $S(n) = 2S(n/2) + n$ My first question is, why we can change any recurrence relation like this? And, how will the following relation $T(2^{n}) = T(2^{n-1}) + 1$ be changed? Which change is correct? $S(n) = S(n/2) + 1$ or...
It's not completely incredible that electrons are accessible information storage units. So let's say there is a breakthrough and we suddenly have read/write access to every electron on the planet. They may each have a few GB of storage, and the "metadata" that keeps their integrity is negligible in size (and immutable,...
How do I change the design to accept the given language, because I think my DFA can accept $001$ as well. Is that correct?
I got a question regarding the decidability of equivalence of two context free grammars: Construct a Turing machine that decides whether $L(G) = L(H)$, where $G$ and $H$ are two context free grammars. This question is taken from Sipser's book on theory of computation. My current idea is given that $G$ and $H$ are CF...
I have a following problem: Given a set $S$ consisting $N$ triangles (possibly overlapping). Answer queries (online) of the form: given a point $P$ is there a triangle $T$ in $S$, such that $P$ lies inside $T$? I am interested in solution (data structure) which: $*$ Answer query faster than $O(N)$ (worst case) $*$ Prep...
In my searching, I've seen that if Church numerals are encoded in a dependently typed Lambda calculus, that we can't derive induction or that $0 \neq 1$. I know that LF and the dependently typed Lambda calculus (from the Lambda cube) are often used to model logic, but any actual systems I've seen based on this augment...
I came across this paper and attempting to go through the implementation of randomized selection algorithm on page 8. Step 1 of the algorithm suggest to compute $s = PrefixSum(n_i, p)$. Where $p$ is the number of processes and $n_i$ starts simply as a number of elements in each process. Page 4 has a definition of paral...
I've seen correctness proofs for other searching algorithms; however, for this particular algorithm: search in a row-wise and column wise sorted matrix, I'm not able to generate a proper proof. The algorithm is Let x = element we're trying to search for in the matrix, e = current element we're processing in the...
Admissions: Yes, this is a homework assignment. No, this is not me trying to outsource my homework to the internet. I am honestly fazed by my teacher's explanation of the "basic operation", and the internet is not helpful either. I get lists that say what a basic operation can be (e.g. assignment, multiplication, com...
Is it allowed to transit between two states $q$, $q'$ by more than one condition? Thank you in advance. e.g. coming from state $q$, the conditions $(0,0,L)$ and $(1,0,L)$ would lead to the same state $q'$. Is this formally allowed?
As we know, the time complexity of $\gcd(x,y)$ is $O(\log \min(x,y))$ by using Euclidean algorithm. Now we fix a constant $n$ and consider the average time complexity of $\gcd(x,n)$. Formally, let $f(x)$ be the number of divisions when calculating $\gcd(x,n)$. How to give a bound of $\frac 1 n \sum_{x=1}^n f(x)$? I don...
I wanted to ask if there is a way to use KMP (Knuth-Morris-Pratt) algorithm to find the longest palindromic prefix of a word. I've seen this algorithm used for determining if a word is rotation of the other for example. We can concatenate first word with itself and look for a pattern which would be the second word (and...
Let's say that an item is either a natural number or a list of items. Examples of items are: 1 [2] [4, [3, 1], 3, 4] A rule states that two items are equal. For example: 1 = 2 3 = [3, 1] [4, 3] = [1, 5] When using these example rules, we can transform [4, [3, 2]] into [4, [3, 1]] into [4, 3] into [1, 5] and we can ...
Knuth's original attribute grammar paper (title: Semantics of Context-Free Languages) introduced three types of circularity. More specifically section "Testing for circularity" page 134-5 figures 3.1-3. I am wondering if it's possible someone would explain in simple terms the three types of circularities. I am very con...
In Interactive Theorem Proving and Program Development the authors explain constraints on constructors of inductive types in Coq. For inductive type $T$, a constructor must have the form $t_1 \rightarrow t_2 \rightarrow ... \rightarrow t_l \rightarrow T a_1 ... a_k$ where $k$ is the number of arguments of the inductive...
The Problem: I am currently analyzing a simple program that takes a file of length $n$, splits it into its individual words (seperated by white space) and adds those words to a set: def file_word_set(name): with open(name) as f: res = set() words = f.read().split() res.update(words) ...
$L = \{ w : w \in \{a, b\}^* \land |w|_a = |w|_b\}$ where $|w|_a$ means number of $a$ in string $w$. I came up with this grammar: $S \rightarrow aSb \ |\ bSa \ | \ \epsilon .$ Can someone please tell me what is wrong with it?
I am working on the following homework exercise: Let $G = (V,E)$ be an undirected graph and $c: E \rightarrow \mathbb{R}$ it's cost function. Further let $T = (V,E')$ be a spanning tree in G. I need to show the equivalence of the following statements: $T$ is a MST. For all $e = \{x,y\} \in E \setminus E'$ holds: No ed...
So I know assembly is so big and it seems learning assembly is like learning high level programming, you don't need to learn them all, you can learn couple and this will be enough. The thing is with high-level language it is easier to grasp and implement in your life. But I am having hard time with assembly, I learned ...
When defining the query complexity of exact learning for a concept $c$ (considered as a function from $\{0,1\}^n \mapsto \{0,1\}$) in a concept class $\mathcal{C}$, we often come across the following definitions leading to query complexity theorems (see R.Servedio and S.Gortler, Equivalences and Separations between Qua...
I am looking for the right transducer which allows to translate a sequence of literals into a sequence of same literals (or a subset of them) in arbitrary order. For example: ABC => CAB, which, with simple production rules: A->a, B->b, C->c, results into output: cab. I am not sure if the pushdown automata is enough to...
Do we know any function which has same quantum and classical time complexity (bounded error), or at least same upper bound? Of course, let's rule out trivial functions like the constant function, and may be assume the time complexity of the desired function be at least polynomial in input size.
$$L = \{w\mid w\text{ contains a substring of form }yy\text{, where }y\text{ is any non-empty string}\}.$$ Is this language regular? We do not know what $y$ looks like in advance. And why is this language regular or not regular?
In Chapter 3 of Mining of Massive Datasets, the basis of locality sensitive hashing is explained. They notably mention simhash for the cosine distance, where random hyperplanes are generated, and for each hyperplane, the projection of the vector to be hashed onto the hyperplane's normal is used for hashing the vector. ...
Here is a GNFA I made from an NFA. I'm unsure how to treat the node of b(a∪b)* (the first node after the start node and the one below it). Since it doesn't lead to any goal state, do I disregard it in when I generate the regular expression?
Consider a simple algorithm to find the maximum element of an array containing integers. We just loop through the array, storing the maximum found so far and updating it whenever an element larger than the existing maximum is encountered. This algorithm is often considered to have $O(N)$ complexity. But doesn't accessi...
This is a homework question, I don't want an actual answer, but rather guidance on how to obtain the correct answer. The question is as follows: In class we saw universal hashing as the solution to processing N elements in the range {0,1,...u-1}, arriving one at a time. Using universal hashing we can get O(1) processi...
In the following image The author refers to an overall running time linear to |E|. But the author then says this is at most O(n^2). This seems contradictory because O(n^2) is quadratic time. Did the author mean to write something else? Or am I misunderstanding something? EDIT!: My question is: What does the author me...
I am reading about Boolean Satisfiability Problem and Nondeterministic Algorithms, in the latter defination it says : In computational complexity theory, nondeterministic algorithms are ones that, at every possible step, can allow for multiple continuations $...$ These algorithms do not arrive at a solution for every...
I am trying to simplify the following equation and I am getting stuck on a line and I can't cut it down any further. I'm not sure if certain 'moves' are legal or not. F(A,B,C,D) = A'B'C' +ACD + A’BCD + A’BC’ + ABC + AB’CD' After regrouping I got: A'(B'C' + BCD + BC') + A(CD + BC + B'CD') I thought right after this you'...
The question is the following: Construct a CFG for $L_2 = \{w \in \{0, 1\}^* \mid w = w^R\text{ and the number of 1’s in $w$ is divisible by 3}\}$. I can construct a CFG for $\{w \in \{0,1\}^* \mid w = w^R\}$ as follows $$S → 1S1\mid 0S0\mid 0\mid 1\mid \epsilon$$ I don't understand how to make $w$ divisible by 3 in ...
Claim: Let $G$ be a graph on $n$ nodes, where $n$ is an even number. If every node of $G$ has degree at least $n/2$, then $G$ is connected. Decide whether the above claim is true or false, and give a proof of either the claim or a counter example. I drew out a few examples and the claim seems to hold, and I cannot fi...
This question is found at: https://www.geeksforgeeks.org/given-sorted-dictionary-find-precedence-characters/ Given a sorted dictionary (array of words) of an alien language, find order of characters in the language. Examples: Input: words[] = {"baa", "abcd", "abca", "cab", "cad"} Output: Order of characters is 'b', 'd...
Given the ambiguous CFG : $ S \to 01S1\mid SS\mid\epsilon $ I came up with the following CFG which I think is unambiguous: $S \to 01X \mid 011X$ $X \to 01X1 \mid \epsilon$ Is my CFG unambiguous and does it represent the same language?
By definition: For a given function $g(n)$ we denote by $\Theta(g(n))$ the set functions $\Theta(g(n))$ = $\{f(n):$ there exists positive constants $c_1, c_2$ and $n_0$ such that $0 \leq c_1g(n) \leq f(n) \leq c_2g(n)$ for all $n \geq n_0$ .$\}$ We say $6n^3 \neq \Theta(n^2)$ becuase if it was, then there would be: \...
So, I was learning Data Structures in Java on my own. And there was a "challenge question" in the book. The question basically asked me to make a data structure that could store all the words in a novel, and then it would associate with the word, where it occurs (like line number and character count) and the frequency...
What are the strengths and limitations of arrays? What considerations go into choosing an array over another data structure, or vice-versa?
Can we compute the edit distance between two strings of length $n$ in strongly sub-quadratic time, i.e., in time $O(n^{2−\epsilon})$ for some $\epsilon>0$?
My apologies if this question makes no sense. I am trying to find an algorithm that can solve a linear system of equations. Unlike most problems like this, this algorithm does not need to find a solution set that solves the entire set of equations. It only needs to solve the MOST number of these equations. For example,...
Looking at the following tail recursive quicksort pseudocode QuickSort(A[1, ..., n], lo, hi) Input: An array A of n distinct integers, the lower index and the higher index // For the first call lo = 1 and hi = n Output: The array A in sorted order If lo = hi return // The array A is already sorted in...
Suppose that I have a tree where each node is either of type A or type B. Nodes of type A have outgoing edges only to nodes of type B and vice versa. Is there a name/term for this kind of a tree? A concrete example of such a tree would be the state tree of a 2 player game (like tic-tac-toe) which has alternating levels...
Consider the following definitions LIST: $\overline{nil} \ \ \ \ \ \frac{l}{a \ l}$ $a \in A$ $A^* = \mu \widehat{LIST}, \ A^{\infty} = v \widehat{LIST}$ NAT: $\overline{0} \ \ \ \ \ \frac{x}{s(x)}$ $ N = \mu \widehat{NAT}, \ N^{\infty} = v \widehat{NAT}$ Given those definitions I have to define a length function over...
I am familiar with k-d trees being used to find nearest neighbors (NN) in 3-D euclidean space however in my particular case I am given a huge array of spherical coordinates. Due to accuracy complications as well as loss of information I cannot convert them to Cartesian coordinates. Then given these points in their sphe...
I'm asked to find all equivalence classes of the language $$L = \{0^n1^n: n \in \mathbb{N}_0 \}$$ where $\mathbb N_0$ is the set of natural numbers including $0$, i.e., $0, 1, 2, \cdots.$ We have the following definition: $$(xR_Ly)\Leftrightarrow (\forall w\in \Sigma^* xw\in L \Leftrightarrow yw\in L)$$ As I understand...
So I was going through the idea behind dynamic programming (memoization), and thought of this question. Can a compiler convert any recursion into a table filling DP solution, of course given the hint(like some keyword or macro) from the programmer that the following recursive function can be solved with DP (so program...
Our problem is: Given a context-free grammar $G$ and a string $x$, decide whether $x\in L(G)$. Is this language itself context-free?
The setting: There's a cluster of $k$ computers (= nodes). For simplicity, assume their hardware is identical. The network topology can be complicated, but let's simplify and assume it's a clique with fixed bandwidth B bits/time unit between each pair of nodes. Each node has its own limited amount of memory, $M$. The...
Note: I have not studied theoretical computer science, so this may be a trivial question. I am interested in the general question: what restrictions are put on a machine $m$ (boolean circuit, TM, ...), by the assumption that $m$ solves a certain problem or class of problems? The question I'm asking in this post is: Wha...
When running a single-threaded application that is 'always busy', on a multi-core computer, modern operating systems will typically switch the process from one core to another from time to time. Even when the other cores are always idle. Typically you can see 1 of 4 cores on a quad core processor at 100% load while the...
I need to build a partial order tree of sets for analysis. Where the order is defined as A <= B <=> for all x in A, y in B, x <= y. I realized that if I pre-sort all the maximal and minimal elements of the sets, like this: // A [1,3] // B [2,4] // C [3,5] // D [6,7] // E [8,9] // F [10,11] const input = [['A', 1], ['B'...
I can compute this easily in the case that $xy < 2^{64}$. But I'm not sure how to do this if $xy \geq 2^{64}$. I know that $\lfloor \frac{xy}{z} \rfloor = \frac{xy - (xy\ \text{mod} \ z)}{z}$, but I'm not sure where to go from there.
Suppose the set of linear inequalities $Ax\le b$, in which $A\in\mathbb{R}^{m\times n},x,b\in\mathbb{R}^n$ is given. Is it possible to determine in polynomial time with regard to $m$ and $n$ if there is a feasible solution that is $k$-sparse, i.e. there are only $k$-nonzero elements in $x$? What about if we know an upp...
I was trying to solve the recurrence relation in order to get a some big-O bound $$ B(n) = B(n-4) + \frac{1}{n} + \frac{5}{n^{2} + 6} + \frac{7n^{2}}{3n^{3} + 8}$$ by following the accepted answer here. I expanded which resulted in $$ B(n) = B(n-8) + \frac{1}{n-1} + \frac{5}{(n-1)^{2} + 6} + \frac{7(n-1)^{2}}{3(n-1)^{...
A graph $G = (V,E)$ is called an almost tree if it is connected and has most $n + c$ edges where $n = |V|$ and $c$ is a small constant number. How would I go about designing an algorithm for a given almost tree graph $G$ with distinct edge weight costs that computes a minimum spanning tree of $G$ in time $O(n)$?
For which $c, d$ is $Gap2SAT[c, d]$ in $P$ (such that $0<c<d<1$)? (I know if d=1 then for each c it will be in P, however with which c,d such that $0<c<d<1$ can I simply return YES?)
All the references about Pure Type Systems I know consider only systems that allow to recover natural deduction systems with additive rules. Is there any variant that allows it to recover natural deduction systems with multiplicative rules? Otherwise, is it just by tradition or by inclination that such a Pure Type Syst...
I have the following two functions $f(n) = n\sqrt n + n \log n$ $\log_{100} n$ And I need to classify them into the followings: $O(n)$, and/or $O(n^2)$, and/or $O(n^3)$, and/or $O(n^{1.5})$, and/or $\omega(n)$, and/or $o(n\log n)$ (small o) $\theta(n^{1.5})$, Regarding the $\theta(n^{1.5})$, I am grasping it's ide...
I have a swarm ofN robots to place on a plane area. Each robot would control a sub part of the area (navigating in it). What algorithm could I use to deploy my robots so that they all control a comparable part of the area. I was looking at Voronoi diagrams but I cannot find how to determine the location of the points....
In lamport's paper[1], he define two concept The partial ordering and The totally ordering. What does partial mean in partial ordering? assumption: this ordering only handle two cases, one is to order events happening in single process, second is communication events between two process. It can't handle concurrent ev...
Given a permutation of $n$ element and for each pair of position $i$ and $j$, a non-negative integer $c_{ij}$ which is cost of swapping $i$-th element and $j$-th element of permutation. Is there any polynomial or pseudo-polynomial algorithm to sort the permutation with minimum cost?
In lamport's paper1, he define global local timestamp, which is composed of process id and local lamport timestamp. This timestamp is used to order all the events in a distributed system. The rule to compare two events is following. My Question Imagine we have two events, one happens in process 1 (P1), with local tim...
Persistent (aka immutable) data structures in functional programming sidestep issues of shared memory mutual exclusion, and thus also issues such as data races that arise and which may be difficult to debug. But persistence requires more memory resources. On the other hand, wait-free versions of data structures guarant...
Consider this language: $$L = \{w \in \{a,c\}^* \mid 3\nmid\#a(w)\land\#c(w)>0\}$$. Here is an automaton for the first part of language, but I do not know how to devise and attach the second part of the condition $\#c(w) > 0$. Because $C$ can come in any state.
First, we state here a theorem that is well-known in computability theory: $L=\{xx\mid x\in\Sigma^*\}\notin CFL$ for every fixed $|\Sigma|\geq2$ And, the standard proof is using pumping lemma. At first sight, we rarely face the language $L$ exactly as defined above in a broader theoretical research. Instead, what mig...
Given an array $A$, sum the number of unique elements for each sub-array of $A$. If $A = \{1, 2, 1, 3\}$ the desired sum is $18$. Subarrays: {1} - 1 unique element {2} - 1 {1} - 1 {3} - 1 {1, 2} - 2 {2, 1} - 2 {1, 3} - 2 {1, 2, 1} - 2 {2, 1, 3} - 3 {1, 2, 1, 3} - 3 I have a working solution which sums the unique elem...
I am solving this problem from here. The given relation is $$T(n) = 2 T(\frac{n}{2}) + n^2, \, T(1) = 1$$ The solution via recurrence tree method is given as: The zeroth level has a single node with cost $n^2$. The first level has two nodes, each with cost $(n/2)^2 = n^2/4$. The third level has four nodes, with cos...
I want to prove the NP-hardness of some problem P in scheduling theory. I was trying with Partition, 3-Partition and Subset product, But neither was successful. Now, I can reduce a problem, say PRODUCT-2-PARTITION to P, but I am not sure whether such problem is $NP$-complete or not? The problem PRODUCT-2-PARTITION is a...
So, I was tasked with creating an app that generates the schedule of a doubles tennis tournament (i.e., teams of two) in a way that, by the end of it, everyone would have played against the rest of the players. The trick is every team should change in each round so that not only everyone played against everyone but the...
Why is the $A_{ETM}$ for a variant of a Turing machine (an erasing Turing machine), where changing a tape symbol to a nonblank symbol is prohibited, decidable? Why does the following diagonalization argument not work: Assume $A_{ETM}$ is decidable, and $R$ decides $A_{ETM}$. Then, $R$ accepts $\langle M, w \rangle$ ...
Given an AVL tree,what are the possible inputs so that the same given tree is formed(please dont mention brute force technique)?
I have asked a similar question at stack-overflow, but then I found this question here, and figured it should go here instead.. So, my question is pretty much the same as the one in the question I linked: I know that in a byte-addressable cache, a byte-offset (usually the LSB of the address) is used to determine which ...
Is the complement of every semi-decidable language a semi-decidable language?
The grammar is $S \rightarrow AA|a$$A \rightarrow SA|ab$The actual question is to find an NPDA accepting the language generated by this grammar but for that i firstly need to convert it into Greibach form. I tried to substitute one rule in another but it didn't help. Any hints would be very helpful.
I've been looking at questions about the regular concatenation of two languages; one question said that the concatenation of $\{0^n1^n|n\geq 0\}$ and $\Sigma^*$ was regular (over the alphabet $\Sigma = \{0,1\}$). Another provided a counterexample by the concatenation of $\{a^{n^2}b|n\geq 0\}$ with $\Sigma^*$, which is ...
Let $G=(V,E)$ be directed graph, where the weights of the edges are non-negative. The graph might have cycles, but without parallel edges. Consider a $T \subset V$, and $u \notin V$. I'm trying to develop algorithm for following optimization problem: Adding minimal new edges (that have fixed costs that is greater th...
I have an array ($|A|\leq 10^6$) of numbers ($A_i\leq10^6$) and a set of prime numbers. I have to find the count of the elements in the array that are divisible by at least one of the numbers in the given set. For example: Array: {3,5,7,15,21,143} Set: {3,5,7} Output : 5 The numbers are 3(3), 5(5), 7(7), 15(3,5), 21...
Question: Prove the following: Every set is Turing reducible to itself. If anyone can provide a solution that would be great, I've just been introduced to computation theory so be as descriptive as you like for my sake if not strictly for the answer. Thanks!
I am trying to solve the following Recurrence relation using substitution method and I am stuck almost half way. I know the answer is 2^n but I can't reach it. At first, my question is: Who decicdes the base cases? when do we take T(n)=1 for n=1 or T(n)=1 for n=0? The work I have done till now is as follows: T(n) = T(n...
Question- Prove: Every decidable set is Turing reducible to the empty set. Can anyone help me with this please? All reductions tutorials I've seen use practical examples of reduction such as sipser's introduction to computation theory: "A reduction is a way of converting one problem to another problem in such a way th...
I'm writing a design document for a macro expansion language that is specifically intended for arithmetic operations on integers. I've already determined that not wrapping macros with parens can lead to unexpected behavior. Rather than expect users to practice impeccable code hygiene, implementing automatic parens will...
Huffman coding is already doing a great job at compressing ascii bytes for data with a distribution like the following byte freq freq% --------------------- 0 317116 26.1 , 151471 12.5 1 112952 9.3 F 60810 5 @ 60810 5 2 53642 4.4 8 49595 4.1 6 ...
I have seen two different Peterson’s Solution to mutual exclusion, one is from Modern Operating Systems: #define FALSE 0 #define TRUE 1 #define N 2 int turn; int interested[N]; void enter_region(int process) { int other; other = 1 - process; intersted[process] = TRUE; turn = process; while(turn ==...
I asked a question here about discrete event dynamic systems. They are systems whose state evolution depends on asynchronous events. It can be combined with flow to produce a hybrid system. There must be an event-based model of computation, since it is so applicable to user interactions. Could someone point me in the r...
During my preparation for an exam, I've come across an exercise that was focused on precision calculation with floating point numbers. It goes like this: Consider the expression : $$\frac{1}{1-x}-\frac{1}{1+x}, x\neq \pm1$$ For what range of values $x$ is it difficult to compute the expression accurately in foating-...
I have two lists say $A$ and $B$, each consisting of n positive integers. I make a list $C$ such that each element of $C$ i.e., $C_i=A_iB_i$ for each element $A_i \in A$ and $B_i \in B$. Now I have to update the value of the maximum element of $C$ say $C_j$ by decreasing $B_j$ such that $B_j \geq 0$ and $C_j$'s updated...
I know that the Set-cover problem with $n$ elements and a universe of size $N$ is NP complete. Also, the problem is has parameterized complexity regarding the number of sets $k$ that should cover the whole universe: There are only ${n \choose k}=\mathcal{O}(n^k)$ different combinations of $k$ subsets. My specific pro...
In this question, what exactly are they trying to ask? I.e. in the trivial case, just travel 200 miles regardless of how many miles posts there are. The penalty is always 0. What are my constraints? Am I missing something from this question that is giving me trouble about what the author means?? See 6.2.
If L has a regular grammar, is L always a regular language? A regular grammar is a formal grammar that is right-regular or left-regular. Every regular grammar describes a regular language. So would this answer be true?
Following this flow diagram for division hardware I made a program to "simulate" division on $N^+$. # 4 bit version def div(dividend, divisor) quotient = 0 remainder = dividend divisor <<= 4 for i in 1..5 remainder -= divisor if remainder >= 0 quotient <<= 1 quotient |= 1 else rem...
I am hoping someone can break something down for me in a way I can digest. I am trying to understand the running time for the median of three partitioning. What is the goal of median of three partitioning? Is it to eliminate the possibility of selecting the largest / smallest element as the pivot, thus resulting in O(...
At a conference, I heard a professor said that detecting error was only one aspect of testing (or purpose, I don't remember exactly). He said that testing is also used to: Understanding the system Refactoring ... I didn't have time to ask for references. I wonder if there are books or papers discussing about purpose...
Monochromatic problem is a classic NP-complete problem. Does the complexity stay NP-complete if we use directed graph? DIRECTED MONOCHROMATIC TRIANGLE problem: Input: A digraph $G(V,A)$ Output: YES if there exists a triangle-free bipartition of $A$, otherwise NO. A triangle-free bipartition of $A$ is a partition $A=A...
I'm attempting ch23 in CLRS on MSTs, here's a question: Given a graph G and a minimum spanning tree T , suppose that we decrease the weight of one of the edges not in T . Give an algorithm for finding the minimum spanning tree in the modified graph. A solution I found was to add this new changed edge in T, then exact...
I'm new to type theory, and recently read introductory materials where dependent type are discussed. One of my friend asked me, "Those dependent types are having recursors & 'inductors'(dependent eliminators), but how about those types that is co-inductive/co-recursive?" Some related example is much appreciated.
I was considering the following two natural questions about the relationship between unambiguity and complementation for the class of context-free languages: Is the complement of an unambiguous context-free language also a context-free language? If a language is context-free, and its complement is context-free as well...
In Compilers: Principles, Techniques, and Tools (2nd Edition) 2nd Edition by Alfred V. Aho (Author), Monica S. Lam (Author), Ravi Sethi (Author), Jeffrey D. Ullman (Author) , Figure 1.5 gives a language processing system, and Figure 1.6 shows the phases of a compiler. In Figure 1.6, if I am correct, a compiler has a fr...
I'm currently looking into Chapter 26 of Types and Programming Languages and am a bit confused by the "intuition" for Full F<: (p. 395): A type T = ∀X<:T1.T2 describes a collection of functions from types to values, each mapping subtypes of T1 to instances of T2. If T1 is a subtype of S1, then the domain of T is small...