instruction
stringlengths
35
29.1k
I am looking for the general problem class / computational complexity / algorithms for the following problem: N tasks must be accomplished by N persons. 1 task to be done by exactly 1 person and vice versa. There is a binary preferences matrix whose (i,j) entry is 0 if person i can not do task j, and 1 if it can. There...
I am curious if the following method would be called iterative or recursive: (define (deep-reverse items) (define (iter things answer) (cond ((null? things) answer) ((pair? (car things)) (iter (cdr things) (cons (deep-reverse (car things)) answer))) (else (iter (cdr things) (cons ...
recently, while watching a video about machine learning, I had an idea about creating an image compression algorithm, that works similar to JPEG, but is based on arbitrary bitmaps as blocks. I should mention that I would not call myself a computer scientist, so my understanding of the math and algorithms involved are s...
Hi I have a program which accesses memory words that are located X bytes apart in virtual address space. For instance, for (int i=0;<some stop condition>;i+=X){array[i]=4;}. I measure the execution time with a varying value of X. Interestingly, when X is the power of 2 and is about page size, e.g., X=1024,2048,4096,819...
I have a connected undirected graph whose edges are either enabled or disabled. I want to create a set of clauses that are SAT iff all enabled edges are part of a single loop. If I assert that each vertex has either 0 or 2 enabled edges, then graphs where all enabled edges are part of a single loop will satisfy the cla...
I have been given a number Y which is ($a$ xor $b$ xor $c$ xor $d$ xor $e$ ) of some numbers ($a$,$b$,$c$,$d$,$e$) and another no X. Now i have to determine if X is a xor combination of ($a$,$b$,$c$,$d$,$e$) e.g - ($a$ xor $d$) , ($b$ xor $c$ xor $e$) , ( $a$ xor $e$ ) What i know clearly is that lets say X= ($b$ xor ...
I really need help solving the following question: Given: $$f(n) = o(g(n))$$ Prove: $$3^{f(n)} = o(3^{g(n)})$$ My attempt: I know that $\frac{f(n)}{g(n)} \xrightarrow{} 0 $. I need to prove that $f(n) - g(n) \xrightarrow{} -\infty$ so that $3^{f(n)-g(n)} \xrightarrow{} 0$. How do I prove that? In general, I'm not sur...
Can someone provide me with some examples of languages which are recursively enumerable but are not recursive. I know that there exist some languages which are not Recursive but recursively enumerable but couldn't find such examples anywhere.. :(
I have N circles with different radius and position in the plane. The problem is finding k circles which have a common area.Obviously this can be solved using Brute-Force in $O(N^k)$. Is there a more efficient way to do such query?
Every actor can create a root node and delegate a right to add a child node. Every node contains name of its’ creator or who added it, and value S. Sum of all values S at the same level of the tree must be equal to the sum of all values of the parent level nodes which in turn is equal to the sum of S’s of their parent ...
I have a binary search tree of height $h$ with an integer in each leaf. I also have a range $[\ell,u]$. I want to find a set of nodes that span the range $[\ell,u]$, i.e., a set $S$ of nodes such that the leaves under $S$ form all (and only) those leaves containing integers in the range $[\ell,u]$. How large does $S...
I've found this example of constraint propagation using projection rule We have C = { x1 ≠ x2, x1 ≥ x2 } < C; x1 ∈ {1,2,3}, x2 ∈ {1,2,3} > They say that applying propagation rule, does not give any simplification. I'm not sure why this is the case. Shouldn't we get? < C; x1 ∈ {2,3}, x2 ∈ {1,2} > Other steps in the...
I am looking for an explicit (and simple) construction of a d regular bi bipartite graph which is an expander. I searched the web and didn't find any sufficient answer. The only explicit graph I did managed to find(and understand) was the margolis graph, but as far as I can understand this graph is not a bipartite (for...
https://en.wikipedia.org/wiki/Subtyping says In programming language theory, subtyping (also subtype polymorphism or inclusion polymorphism) is a form of type polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program eleme...
As far as I know, Integer Linear Programming(ILP) problem is NP-complete. According to the following paper, Binary Linear Programming problem(BLP) can be solved in Polynomial time. http://dx.doi.org/10.4236/ajor.2016.61001 I'm not familiar with the convex Quadratic Problem mentioned in the paper. However, I know that I...
From what I gathered from Wikipedia, CYC is based on set membership logic. So it would take symbols and create set membership predicates. But how is this different from IBM Watson?
I have two random variables $X$ and $Y$ and I want to bound the value of one in terms of the other (for now, I don't care about the actual distribution of their values). Suppose that the two variables can have different distributions with values chosen from $[1, n]$. But $X$ is always upper bounded by $Y \cdot c\log{n...
I found this question What is the usage of CYK algorithm in the real world considering we have algorithms with a much better Time complexity? saying CYK Parsing algorithm can compute any Context Free Grammar in $O(n^3)$. But this does not make sense because I cannot see how NonDeterministic Context Free grammar can be...
I have hard time understanding the proof by contradiction for the claim "$L=\{x : K(x) \ge |x| \}$" is undecidable ". The proof is as follows : M' = " On input $n$ Enumerate over all $n$-bit strings $x$ in lexicographical order Simulate M on each $x$, where $M$ is the Turing machine that decides $L$. Output first $...
I'm finding myself needing to encode a "not-k-out-of-n" constraint in a SAT solver. The "at-most-k-out-of-n" constraint for SAT solvers is something I can find research about -- this paper by Frisch and Giannaros, for example. Given an "at-most-k-out-of-n" tool, I can get an "at-least-k-out-of-n" tool by inverting all ...
Accordingly, to the question Chomsky Hierarchy and P vs NP, Context-Sensitive Grammars are on Linear Space. Assuming a Deterministic Parser is the one which can parse unambiguous grammars in something like linear time complexity, while a NonDeterministic Parser can parse any grammar in some worst time complexity like $...
Given the Hasse Diagram of a Partially Ordered Relation, is it the case that both the POSET itself and its dual POSET have the same number of topological orderings? I have tried a few examples, and although it does seem to be the case, I need a formal way of proving the same. So please help me with this.
Can we store a struct in place of vertex. struct { int v, update_count; } run dijkstra's algorithm and whenever a node is updated we will increase update_count value. If update_count value is greater than V(no of nodes) we will know that there is negative weight cycle. Is this a viable solution.
Let's say we have a Matrix M and a column vector v like below multiply equals Assume we can only perform multiplication, addition and substraction operation. With normal approach we need 3 multipliction and 3 addition to calculate row1 row1 = v_1 + 2v_2 + 2v_3 + 4v_4. However we can do it smartly by t1 = v_1 + 2*v...
From Agile Principles, Patterns, and Practices in C# by Robert Martin, Listing 10-1. A violation of LSP causing a violation of OCP struct Point {double x, y;} public enum ShapeType {square, circle}; public class Shape { private ShapeType type; public Shape(ShapeType ...
I'm creating a simple row buffer simulator to go along with a simple cache simulator in order to count hits and misses in the row buffer. Whenever a cache block isn't in the cache I want to go look for it in the row buffers of the main memory and record whether it is present of not. How accurate would it be to have ju...
Imagine a complicated blackbox-esque system that has 20 inputs and 5 outputs. I have a set of criteria I am able to use to construct a fitness function. I run a genetic algorithm to deduce values which maximize my fitness function, and I keep iterating until a solution emerges which passes a threshold. Once this thresh...
I don't know whether it is RAM or cache; I can say that isn't the registers since their memory capacity is very small.
I'm studing the Clean functional programming language, and like other functional PL it uses Lazy Evaluation. The thing that I can't get is when a PL that using that kind of evaluation evaluates the needed parameters. Does the compiler recognize which parameters are used and generate the code for evaluating them? or ma...
I want to write the following constraint: If A=1 and B <= m then C=1 ( where A and C are binary, m is a constant and B is continuous).
I'd like to know if this data compression scheme would work or not, and why: Suppose we have a file. If we treat the bits that make up the file as the binary representation of a number n, we have n (of course, if the first bit is zero we flip every bit so that n is unique). Now we have the number n, and a boolean that ...
I was reading this very good summary of Cuckoo hashing. It includes a result (page 5) that: A stash of constant sizes reduces the probability of any failure to fall from $\Theta(1/n)$ to $\Theta(1/n^{s+1})$ for the case of $d= 2$ choices It references the paper KMW08. But KMW08 only has the result (Theorem 2.1) t...
Given a modified type of turning machine where $\delta = Q\times \Gamma^* \implies Q\times \Gamma \times \{L,R\}$ where the next step of the machine is determined by the current state and whatever written on the tape up to the current point. For example: if the tape content is $a\_ab\_\$\$a$, and the head is on the lef...
A deterministic $(2−2/(k+1))^n$ algorithm for $k$-SAT based on local search  I have read this paper and I couldn't understand how to culculate the $covering$ $radius$ of a code in the Hamming space. It is defined as follows in the paper.  We identify assignments with binary words. The set of these words of length $n$ ...
There's an exercise in Arora-Barak on sensitivity and block sensitivity. The statement of the problem is: Let $f$ be a function on $n = k^2$ variables that is an OR of $k$ applications of $g: \{0, 1\}^n \rightarrow \{0,1\}$, all $k$ blocks of variables are disjoint. $g(x_1, \ldots, x_k) = 1$ if there exists $i \in [k-...
For UCT (Upper Confidence bounds applied to Trees), why If given infinite time and memory, UCT theoretically converges to Minimax. ? Besides, I do not quite understand how UCT deals with the flaw of Monte-Carlo Tree Search, when a program may favor a losing move with only one or a few forced refutations, but due to the...
In the Dubins TSP (DTSP for short), one needs to visit a set of given points in the plane, and return to the starting point, minimizing the distance of such a trajectory. The difference with the Euclidean TSP (ETSP for short) however is that the visiting entity is curvature constrained by some $r$, meaning the vehicle ...
I have to multiply three matrices of floats: A (100x8000), B (8000x27) and C (27x1). Is there any difference in accuracy between A(BC) and (AB)C? If yes - how may I determine the more accurate multiplication order? Speed is not a factor here. Matrices A and B contain 8000 samples of (respectively) 100 and 27 features.
Induction on Church-encoded natural numbers (which I will call indNat) can not be defined within the Calculus of Constructions. If we assumed indNat as an axiom, is there an untyped term that would have the semantics of the induction function? What if we had Scott-encoded natural numbers and fix? Can induction be inhab...
can you tell me how i can use a bloom-filter by a joining operation with two tables? let's assume that: Table A ={A_id,B_id,age}, Table B = {B_id, color}. now i want to use a bloom-filter so i can do the join operation faster, but i do not know how i can use this in this case. I would first take from A the PK A_id and...
I guess it copies, since it is a temporary memory, it will erase if power is not supplied, so, that will lead to data loss right, but still, I need clarification.
Learning about Voronoi Diagrams, one quickly finds out that Delaunay Triangulations are clearly the easiest way to generate them from a set of points. How about the other way around? Given a subdivision of (2D) space, how to determine unknown generators? Are there any common ways to do this? Things I could think of wer...
I know that P = PSPACE is a famous open problem, and that EXPTIME = NEXPTIME is also unknown. By the time heirarchy theorem we know that NP is a strict subset of NEXPTIME. Is anything known about the relationship between PSPACE and NEXPTIME? What about under the assumption that P = NP or that P != NP? Are the containm...
The problem requires us to find the substring within a string which happens to be a palindrome. Multiple palindromes are also allowed. For example, in "LODHIHDAK" "DHIHD" is a palindrome. Comparing the reversed string with the original string to identify the common substring is one way but it isn't fool-proof. For exa...
Given a natural number $n \geq 1$, I am looking for a Boolean circuit over $2n$ variables, $\varphi(x_1, y_1, \dots, x_n, y_n)$, such that the output is true if and only if the assignment that makes it true verifies $$\sum_{i = 1}^{i = n} (x_i + y_i) \not\equiv n \bmod 3$$ I should specify that this I am looking for a ...
Suppose I need exactly $X$ flowerpots. I have $Y$ flowerpots to choose from, and $Y > X$. Each of the $Y$ flowerpots has a cost and a capacity. I have a fixed budget to buy flowerpots. The budget, and costs and capacity of each flowerpot are all strictly positive integers. Assume that the total cost of the cheapest $X...
In these slides describing Fortune's algorithm for constructing a Voronoi diagram, it is noted on page 7 that break points of the beach line can move upward. How is this so? In most of the cases I can think of, break points always move downward. I couldn't easily think of a case where a break point would move upward. ...
If I want to do research in computer science and machine learning, is it important to have a well-rounded understanding of lambda calculus?
I readed the proof of Dijkstra's algorithm in "CLRS",and the code in Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. Figure 24.7 in CLRS proofs the correctness of Dijkstra's algorithm. The proof said that we should add the minimum path vertex in set V - S, But the code add the minimum path vertex in prio...
I'm wondering what are the most common/recognized methods to assess the quality of a clustering. That is because I have developed a tool that can cluster/partition a network (in this case, a public transport network represented by a GTFS feed) in several different manners (graph partitioning, hierarchical clustering, e...
I need to draw the derivation tree for $1-2-(3-4)*5*6$ from the grammar below. I want to know how many possible derivation trees are there from this grammar. $$\begin{align}V_n&=\{expr,term,factor,number\}\\ V_t&= \{(,),-,*,0...9\}\\ P&=\left \{ \begin{aligned} expr&\to expr-expr\;\mid\;term\\ term&\to term*factor\;\m...
$A_{TM} = \{\langle M,w\rangle\mid w\in L(M)\}$ $L$ = complexity class containing decision problems that can be solved by a deterministic Turing machine using logarithmic space Given the language $L \cup \{A_{TM}\}$, we will say that $A$ is complete in $L \cup \{A_{TM}\}$ if: $A \in L\cup\{A_{TM}\}$ For every $B\in L...
So, an exam's exercise asks me to find an alghoritm that can determine if counting sort is the best solution, otherwise use another optimal sorting algorithm. Now i find that solutions for that question given by my professors are wrong because they do gave this as answer:( pseudocode) Sorting(A,k) //where k is a value ...
Given a binary heap of size $n$ and a number $k\le n$. How can I return an array with size $k$, which contains the $k$ lowest elements in the binary heap, so that it will be sorted in the end? The problem is that the time-complexity needs to be $\Theta(k \log(k))$.
Given $L=\lbrace w\in \lbrace 0,1 \rbrace^\ast : N_0(w)=N_1(w) \rbrace$, where $N_0(\cdot)$ and $N_1(\cdot)$ mean the number of zeroes and ones respectively, I need to characterize the classes induced by the relation on $\{0,1\}^\ast$ $$x \thicksim_{L} y \iff \forall z\in \{0,1\}^\ast \left(xz \in L \iff yz \in L\righ...
I'm studying for a computing exam and came past the following question on a past paper and need help with it. When would algorithm A be slower than algorithm B? Demonstrate your answer with the help of an example. Also what will the value of SUM be at the end of each algorithm if the size is set to $10'000$? Algorithm ...
Consider the load balancing problem on two machines. Thus we want to distribute a set of $n$ jobs with processing times $t_1,...,t_n$ over two machines such that the makespan (maximum of the processing times of the two machines) is minimized. Professor Smart has designed an approximation algorithm Alg for this problem,...
I have a simple theoretical question in very basic algorithms, as the title mentions, is it always true that the depth of BFS is $\leq$ DFS? From what I understand, the tricky part here is the possible cycles in the graph. Even though that I believe that the depth of BFS will always be less or equal to the depth of DFS...
I am looking for a numerically efficient algorithm to get a triangular surface mesh of the convex hull given by 8 points in three-dimensional space. For context, the use case is the following: I have a numerical Simulation calculating the time evolution of a field with three components on a lattice. Say we have lattice...
Subset sum Input: A multi set $S$ of numbers and a natural number $t$ Question: Does $S$ contain a subset $A$ such that $\sum_{x \in A} x = t$? (e.g., $\{1,1,2,3,4,5\}$, by multiset it means duplicates are allowed) Vertex cover Input: An undirected graph $G$ and a number $k$. Question: Does $G$ have a vertex cov...
I am using the module networkx to operate on graphs made from OpenStreetMap. I wanted to compare the shortest path algorithm to find which one is faster, and I compared Dijkstra and A*. The problem is : A* is most of the time faster than Dijkstra even though I didn't defined any heuristic function. I understood that A*...
How to do it? I'm not asking the solution for the proof of why subset sum is NPC, but rather the opposite reduction
I tried to prove in negative way that there is computability reduction HP $\le$ $\Sigma$* and accept contradiction because of HP $\in$ RE and $\Sigma$* $\in$ R but it feels that is not strong argument. There is a more solid way to prove it?
I want to randomly generate a pair of invertible matrices $A,B$ that are inverses of each other. In other words, I want to sample uniformly at random from the set of pairs $A,B$ of matrices such that $AB=BA=\text{Id}$. Is there an efficient way to do this? Can we do it with expected running time approaching $O(n^2)$?...
So $NP$ stands for problems where we have small verifiable witnesses for $YES$ instances and $coNP$ for small verifiable witnesses for $NO$ instances. How does this work for $P^{NP}$ $NP^{NP}$ $coNP^{NP}$ and so on?
I have a discrete distribution of reference. For the example let's say: P(X=1)=0.2 P(X=2)=0.7 P(X=3)=0.1 Now I am given n numbers, and I want to group (sum) those numbers into 3 bins and approximate as close as possible the above distribution in the sense of minimizing the sum of squared error. So let's say I have ...
WEIGHTED-CLIQUE input: a undirected graph G that has weighted edges and 2 natural numbers a, b question: does G have a clique of size a with total weight of b? I want to prove that this is NP-hard (assuming weighted-clique $\in NP$) So I would have to prove $VertexCover \leq_P WeightedClique$ Need to show the trans...
I'm stuck in this problem and I would need some help: Given an array arr, in each step, 1, 2 or 5 units have to be incremented to all but one item of the array. The goal is to find the minimum number of steps to all items to be equal. First example arr = [1, 1, 5] 1) [1 (+2), 1 (+2), 5] = [3, 3, 5] 2) [3 (+2), 3 (+2), ...
I been thinking about an improvement to a garbage collector (details not important for this question) and wished to know how often does a object have no reference to other objects. Clearly this will depend on the language. Many people must have research this and published the data, yet I can't come up with the correct...
I have been interested in Seth Lloyd's cosmological model (which proposes that the universe is a computer: https://en.wikipedia.org/wiki/Programming_the_Universe, https://arxiv.org/abs/quant-ph/0501135) since long ago. While I was "researching" about this topic, I found an interesting article that hungarian author Zolt...
There have been some nice papers about simple type inference for System F: "HMF: Simple Type Inference for First-Class Polymorphism", "Practical type inference for arbitrary-rank types", and "Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorphism". These algorithms require varying amounts of annotati...
I'm curious to know the computational complexity class of each step in this method of converting a CNF formula into simple elementary algebra. An example: $$\phi=\left(x_1 \vee x_2 \right) \wedge \left(\neg x_1 \vee x_3 \right) \wedge \left(\neg x_2 \vee \neg x_3 \right) \tag{CNF} $$ Let $\neg a = 1-a$ Let $a \vee b= a...
My problem statement is that my agent has to visit multiple pickup points once to collect orders, say Item A, Item B, Item C...... etc. We are using TSP for that. Now say Item A are stored in 3 places and each place has stocks which are 20,30 and 40 respectively. If my total quantity of pickup for Item A is 45 then ho...
According to this problem: Unique Stable Solution in Stable Marriage Problem: Is it Pareto-efficient and a Nash Equilibrium? Is the both sided stable matching strongly pareto optimal for both sides? And is there a rule that in a m- and w-optimal stable matching at least one person gets his first choice like in the exam...
This is a repost from https://stackoverflow.com/questions/56990710/encoding-any-turing-machine-to-one-with-2-symbols since it was brought to my attention that the question would be better suited to this SE than SO. I am interested in understanding how a Universal Turing Machine would work on a practical level. I read R...
I am writing code to evaluate the following expression: $$ \frac{(a+b+c)!}{a! b! c!} $$ where $a$, $b$ and $c$ are on the range of $10$ to $500$. The result is going to be a floating point number. I could use a big number package, but the code will run slowly. I am using 64-bit floating point numbers. I claim by do...
My understanding of how a GPU works is kinda solid I think. This is what I understood searching on the Internet: VRAM (or framebuffer) stores what you see on screen. Most of what the GPU does is encoding/decoding and processing data(mainly for 3D). The GPU also sends (depending on the type of connection, HDMI, VGA etc....
The halting problem relies on the fluidity of Turing machines. That is, a string can represent a machine. Can you do the same for C++ on a modern computer? Let's see my first attempt. Let bool h(string x, string y) be the purported function that decides haltingness and always halts. You can easily turn it into a full p...
We are learning about the travelling salesperson problem in my high school class and we are discussing how computers could solve for the problem, even though the problem is intractable, using a brute force algorithm. I was wondering if the brute force algorithm calculates ALL possibilities for a number, n, or only UN...
Say i have code snippet like --> m -= n; is minus and assignment considered as a single token or they will be considered as different token? So the total token count will be 4 or 5?
Suppose that data are transmitted in blocks of sizes 1000 bits. What is the maximum error rate under which error detection and retransmission mechanism (1 parity bit per block) is better than using Hamming code? Assume that bit errors are independent of one another and no bit error occurs during retransmission. This is...
I am reading Mark Newman's Computational Physics and at chapter 4 page 133 in Exercise 4.2 he asks a) Write a program that takes as input three numbers, a, b, and c, and prints out the two solutions to the quadratic equation $ax^2 + bx + c = 0$ using the standard formula $x = −b± (b^2 − 4ac)^{1/2}/2a$ . Use your progra...
Is it possible to convert all logical formulae into a form such that each variable ends up in exactly 1 "factor" of the and operation? ($\wedge$). Any combination of operations is allowed, though the fewer operations used the better. $$ \left((a \rightarrow b ) \downarrow b \right) \wedge \left(c \vee d\right) \wedge \...
Say we have two problems $\Pi_1\in NP$ and $\Pi_2\in coNP$. Where does $\Pi_1\cap\Pi_2$ live?
I want to extract sub-sequences from a sequence of float values. The "scale" and range of these values is arbitrary (as I can manipulate it at will) but the "shape" is consistent. For a visual example: I want to extract the above five stacks as five "chunks". I want them in the order they occur (left-to-right). Do not...
Why can't a TM simulate a PDA? Then we can easily construct a PDA P which is made from grammar G. And contruct a TM that simulates P to prove that this problem is decidable.
Is there any literature on approximate maximum-weight perfect matchings where the approximation criterion is not the factor between the approximate and exact weight sum achieved by each solution, but instead the cardinality of the intersection of the edge sets in the approximate and an optimal solution? The relevant cl...
Let there be a dictionary of M words with average length N. We want to compute an M×M matrix of edit distances between all word pairs. Since there are M² word pairs, and the pairwise edit distance has O(N²) average time complexity, the upper bound on the average time complexity for our problem is O(M²N²). Is there an u...
Kleene Star with 'sed' is behaving as expected for me, with exception of a case where the input pattern is "ab" and the regex is "b*". Does anyone know why this regex is not being matched against the pattern space? This is the failure case: $ printf "ab\n" | sed -En 's/b*// p' | od -t c 0000000 a b \n 0000003 SO...
What is the best way to avoid using goto statements when writing the pseudocode for an algorithm? I want to avoid it and use another way to replace it.
We are studying the Travelling Salesman problem in my high school class, and I am wondering what the Big O complexity of the TSP is when you MUST start and end at the same city. For example, given 4 cities labelled A,B,C,D and you MUST start and end at A, what is the big O notation for this? Is ((n-1)!)/2 for both symm...
In Le Ny et al.'s paper On the Dubins Traveling Salesman Problem (https://tinyurl.com/y59f7d8x) the authors prove, among other works, that the Dubins Traveling Salesman Problem (DTSP) is NP-hard. I will give here the basics of the proof, after which I will ask my question regarding this proof. The authors reduce Exact ...
I am writing a thesis about automatic GUI testing. In order to find the fittest strategy I am using GP. I am using tournament selection to select chromosomes for the next generation and elitism to make sure the strongest elite(s) will proceed to the next round. Basically, I have 2 questions: a) Many papers use 7 as tou...
I came across following problem: Barrier is a synchronization construct where a set of processes synchronizes globally i.e., each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary sema...
I've been trying to understand the pumping lemma, and how to apply it to a language such as a^nb^mc^m where n >= 0 and m >= 0. The pumping lemma states that: For any regular language L, there exists an integer n, such that for all x ∈ L with |x| ≥ n, there exists u, v, w ∈ Σ∗, such that x = uvw, and (1) |uv| ≤ n (2) |v...
In Introduction to Algorithms (CLRS) 3rd Edition, page 299, the section attempts to prove: The expected height of a randomly built binary search tree on $n$ distinct keys is $O(\lg n)$. We define "randomly built binary search tree on $n$ keys" as: a binary search tree that arises from inserting the keys in random or...
My task is to develop an algorithm for the optimal arrangement of cylindrical objects in cartons. The algorithm is to have the task of placing as many products as possible into cartons, at the same time not exceeding the capacity of the carton and the permissible weight specified for the carton. Initially, I accept one...
I have two random variables, X and Y, and Y is a positive real number. I can sample from $p(y|x)$, but I need to sample from $p(x)$, which I know to be proportional to $\frac 1 {E[y|x]}$. I could estimate $p(x)$ from the mean of a lot of samples from $p(y|x)$ and then use a Metropolis algorithm, but sampling from y i...
I am trying to calculate the First and Follow of the following grammar S->ABC A->Aa A->aB B->Bb B-> epsilon C-> Cc C-> Epsilon I have calculated the firsts and it is all good Follow(A) = {a,b,c,$} What is confusing me is the follow of B, I get Follow(B) = Follow(A) But on the other hand, I have a solution for the gra...
In the parsing tables of SLR(0), LALR(1) and LR(1) I have seen that shift moves and reduce moves have separate columns from Go-to Moves. What is the logic behind this?