instruction stringlengths 35 29.1k |
|---|
Given $m$ constraints for 2 variables $x_1,x_2$ :
$d_ix_1 + e_ix_2 \leq b_i$ for $i = 1,...m$
need to create a linear program that finds the maximal radius of a circle such that all the points inside the circle are in the feasible range of the above constraints. The circle can be located anywhere -- not necessarily ce... |
Let X be a problem for which pseudo-polynomial algorithm time for verification of solution exists. What can be said about complexity of problem X? Can X belong to NP-hard class?
|
I'm trying to analyse the time and space complexity of the following algorithm, which is essentially a hybrid of a merge and selection sort. The algorithm is defined as follows:
def hybrid_merge_selection(L, k = 0):
N = len(L)
if N == 1:
return L
elif N <= k:
return selection_sort(L)
els... |
Say there are some intervals $\{1, \ldots ,n\}$ with starting times and ending times, and they're sorted in order of starting time from first to last in an array intervals$[]$. Now I want create an array next$[]$ such that next$[i]$ is the interval after interval $i$ whose starting time is as close to $i$'s ending time... |
I am trying to understand the example given here of an EXP-SPACE time decision problem.
They write :
An example of an EXPSPACE-complete problem is the problem of
recognizing whether two regular expressions represent different
languages, where the expressions are limited to four operators: union,
concatenation, t... |
I am trying to figure out a formal grammar for the above language. This language describes palindromes, so it is context-free, if I am not wrong. I came up with a context-sensitive grammar, but I can not find a context-free one. Any ideas?
|
We are given an array of length N with exactly 2 peaks (a peak is an element which is no less than the left and right neighbors). Is there an algorithm to compute those peaks faster than O(N), maybe similar with the single peak finding in O(log N)?
|
Im interested in this so that I can name a type parameter in a program I'm writing.
There is function that that has three parameters.
D, Domain
C, Codomain
X, where D is a subset of X and C is a subset of X
What is the special name for X, if there is one at all?
This is interesting from a program security prespective a... |
The shortest common cyclic superstring problem is closely related to the shortest common superstring problem. The difference is that each of the strings in the input set may have an arbitrary rotation of the algorithm's choosing applied to them. By rotation I mean that for example abcde -> deabc would be a rotation by ... |
Nies, in Computability and Randomness, p. 6, defines "uniformly computably enumerable":
A sequence of sets $(S_e)_{e\in\mathbb{N}}$ such that $\{\langle e,x \rangle : x \in S_e \}$ is c.e. is called uniformly computably
enumerable.
I think this means that both the sequence of sets and the members of the sets are jo... |
Why it is so hard to make a nondeterministic computer? If such a device is physically realizable then would that be a counterexample to the extended Church-Turing thesis?
|
Prove that if $ L \subseteq \Sigma^\star$ is regular, $L'$ is also regular where
$$ L' = \{w\mid{uw \in L \mbox{ for some string }u \in \Sigma^\star}\}$$
I'm new learning formal language and haven't proved stuff like this. But I'm sharing my thoughts here to make sure I'm on the right track. The first idea came to my ... |
The question came to my mind while studying the NP definition. Do we know any such languages?
|
I didn‘t find a DPDA for the language L = {$a^{m}$ $b^{n}$ : m $\neq$ n}, so I guess an NPDA is the only option.
NPDA are not very intuitive to me. The only solution I found online is:
I don‘t really understand how it works and also I‘m not allowed to use final states. The only way an input is accepted is by emptying... |
I was reading a book on Operating System by Galvin and came across this :
In the latest version of Solaris, scheduling is controlled by loadable tables. Depending on the table currently loaded, the system can be time-sharing, batch processing, real-time, fair share, or any combination. Making the scheduling mechanism g... |
Let $L = \{\lt M\gt | M$ is a $TM, L(M) = \{1^n0^n | n\ge0\}\}$.
Create a reduction from $A_{TM}$ (acceptance problem) to $L$. Is $L$ not decidable?
But isn't $L$ decidable since it is possible to make a CFG (or PDA) of that language. And if I can make a reduction, $L$ would become not decidable because of $A_{TM}$.
|
In an effort to better-grok monads I have reviewed many "Everything you need to know about Monads" tutorials out in the wild, but I feel like my understanding is still coming up a bit short.
While every one of the above faithfully recites the 3 laws of monads: right identity, left identity, and associativity along wit... |
This is part of a bigger problem, which is to find out if point XYZ exists in any of n (XYZ -> XYZ) "boxes".
I'm currently splitting up the problem into a smaller one, by focusing on one dimension first and "filtering" till either a range is found, or it's not;
How can I find out if my number X is in any of n ranges wi... |
Say I have a primal program P with n variables and c constraints.
Let's say that I have an optimal solution for the dual program D, in which the y1, the variable related to the first constraint in P, is zero.
Does that imply that I could run Simplex on P without the first constraint and get the same optimal solution a... |
I was wondering if there is a name for this construction:
Take a graph $G$ and construct a new graph $G'$ in which the edges of $G$ now become vertices, and "vertices become edges" in the sense that vertices are joined by edge in $G'$ if they as edges in $G$ shared a common vertex.
More precisely:
Given a graph $G=(V=\... |
I'm reading an article about indexing in Redis. There is a link to so-called Hexastore, it's referred to as a data structure. The link doesn't work, which makes me feel I'm missing something.
I understand from the article that
the hexastore provides a representation for relations between objects,
formed by a subjec... |
This is the problem statement I came across today.
Given a binary tree, find the lowest common ancestor of all deepest leaves.
I came up with a correct algorithm, but I would like to confirm the running time of this approach.
The algorithm is as follows:
Traverse the tree and find the deepest level of the tree, dmax.
... |
The HW question, on page 362 of Data Structures and Algorithms in C++: Fourth Editionby Mark Allen Weiss, reads as follows:
Prove that merging two sorted arrays of N items requires at least 2 * N - 1 comparisons. You must show that if two elements in the merged lists are consecutive and from different lists, then they... |
i have a question - how i can prove that:
$\log((n^2)!) =\theta (log((n!)^2))$
i try something like that:
$\log((n^2)!) = 2*(log(n)!)=\theta(2*(log(n)!)=\theta(n\ log(n)) $
$\ \theta(log(n!)^2)=\theta(log(n!)*log(n!)) = \theta(n\ log(n)) $
then we can see that is equal --> there are $\theta(n\ log(n))$
this is true... |
I'm trying to solve this problem where I have to cover all the squares in a N x N grid with rectangles with a tradeoff between cost and computation. These are the constraints:
Fields are rectangular, but may be of any width or height
Rectangles may cover any cell whether marked or not
Must be rectangular
Must be axis-... |
Query A and Query C seem to be the same.But given answer is query A.
Can someone help me to find the difference between queries A and C ?
|
Question
I am wondering what is the minimum time complexity of get the unique value of a array in two conditions: keep the order or not.
For example, suppose we have a original array [3,6,1,1,2]. I want to get [3,6,1,2], this result keeps the original order and drops duplicates. If there is no need to keep the original... |
It can be proved that randomly built binary search trees of size $n$ are of depth $O(\log n)$ and it is clear that level $k$ has at most $2^{k}$ nodes (root's level is 0).
I have an algorithm that traverses every path in the tree (beginning at the root) but stops after traversing $k$ nodes (the parameter $k$ is a confi... |
I stumbled across this question in HackerRank:
Karl loves playing games on social networking sites. His current favorite is CandyMaker, where the goal is to make candies.
Karl just started a level in which he must accumulate $n$ candies starting with $m$ machines and $w$ workers. In a single pass, he can make $m \ti... |
I am trying to develop a CFG for the language $L$ defined by:
$L = \{a^{n+2}bba^{n-2} | n > 1\}$
The problem I am having is that I cannot develop the CFG for this language no matter what I try. The closest I can get is:
$S \rightarrow aaaaXbbX$ (Production 1)
$X \rightarrow aX | \Lambda $ (Production 2)
This would ... |
Bartosz Milewski's Category Theory for Programmers says the following:
A parametrically polymorphic function between two functors (including the edge case of the Const functor) is always a natural transformation.
Why is this true?
Something along the lines of an informal proof would help me.
It would also help to hav... |
I am reading about B-Tree through CLRS. One of the exercise problem is to express maximum number of keys in a BTree of height $h$ and minimum degree $t$.
Properties of BTree of $t$:
$t\ge 2$
Min. no of keys in a node is $t-1$ and max. number of keys in a node is $2t-1$
Max number of children a node can have is $2t$
T... |
I was given this exercise and I think I have to use a variation of Gauss repeated squaring, but I can not figure out how to produce $\log\log k$ in steps, like when you divide $k$ by $2$ to compute $\log k$ in steps. Any ideas?
|
I have a problem with an exercise, I have to analyze the following
For-Loops
Then I have to write down the explicit notation, my problem is that I don't know how to get the right m.
I tried this
but now I have no idea how to get the m, because I thought that m defines the diffrence between i and j and so I became m = n... |
I was able to prove that $size(t) \leq 2^{h(t)} - 1$ for any binary tree $t$, however I wasn't able to do anything reasonable with this statement.
I know it's a proof by induction and that the inductive hypothesis is the following:
$
size(l) < 2^{h(l)} \\
size(r) < 2^{h(r)}
$
where $l$ and $r$ are the left and right s... |
How could I normalize the 2nd order central difference method?
The original function is F(A,B,C,D) and only one variable is varied at a time. ie
$F'' = \frac{F(A+\Delta A,B,C,D) - 2\times F(A,B,C,D) + F(A-\Delta A,B,C,D)}{\Delta A^2}$
I want to compare the sensitivity of each variable. But I would like to do it with no... |
I came across the following question:
A source $X$ emits symbols from the alphabet $A_x$ with $|A_x| = 8$. We want to construct a prefix-free source code for this source.
We want to find a code with codeword lengths $(1,3,3,3,5,5,5,5)$. Can such a code exist? If yes, give such a code. If not, prove that.
I checked Kraft'... |
I was asked to prove that $ L = \{ 0^{{2n}\choose{n}} : n\in\mathbb{N} \}$ is not regular. I can't solve this, could anyone help me?
This was an exam question from previous year. I looked your answers, but I can't really understand Yuval's solution and Matt's solution would be too long for an exam question.
From lectur... |
For this I came up with a DFS recursion.
Do DFS from any node and keep doing it until all nodes are Exhausted. I.E. pick the next unvisited node once you cannot keep recursing.
The element with the highest post number or the last element you visit should be the first element in your topological ordering.
Now do anot... |
Measure words (aka classifiers) are used in Chinese to "measure" things, e.g.
三杯牛奶
Three glasses of milk
那个人
That person
一只乌鸦
One crow
一公斤豆腐
A kilo of tofu
We don't have an equivalent in English [they're not collective nouns (e.g. a murder of crows)]. It'd help reading Chinese text to be able to highlight measure wo... |
I came across some lecture notes of a professor about memory consistency and models. There is an example about memory overhead:
The cache line has 7 states (3 bits): unowned, shared, exclusive, modified, read, update and "uncached read".
For 64 processor with the cache line described above, the memory
overhead is 12.5... |
I am trying to understand the maximum cardinality problem in the context of stable matching algorithm. I am reading the following article at the link:
A Two-Sided Matching Decision Model Based on Uncertain Preference Sequences
The article says that:
In general, we can categorize two-sided matching problem into three
... |
So I'm looking for a bit of an abstract algorithm and I'd appreciate any references to read up on. This is a bit tough to explain but I'll try my best.
Suppose we have 2 arrays of RGB pixel tuples-
A -> {(56, 39, 75), (125, 222, 32), (156, 201, 102)}
B -> {(125, 195, 93), (53, 31, 67), (118, 219, 48)}
I'd like the sort... |
I'm really struggling with the following exercise and I would really appreciate your help:
I have to calculate the expected runtime of a sort Algorithm with the following variants:
Variant Runtime Behavior
1 n(n-1)
2 n
3 n log(n)
Given is, that the runtime for variant 1 is 1000 ele... |
I am currently working on ways to prove this and got stuck proving it with induction.
Any tips?
How could i prove that for every finite alphabet Σ, ∀ n ∈ ℕ. |Σⁿ| = |Σ|ⁿ?
|
I was reading an article about Binary Search on one of the websites on the internet that someone had linked, can't find the link anymore, but this really is bothering me, and I think I am missing something.
function binary_search_alternative(Array, k) is
L := 0
R := n − 1
while L < R do
m := floor(... |
I was wondering whether this program (I'm using a C syntax, hope it's not an issue) is to be considered $O(n^2 \log(n))$ or $O(n\log^2(n))$ or something else entirely.
for(int i=0;i<n;i++)
for(int j=i; j>0; j/=2)
for(int k=j; k>0; k--)
printf("Hello, World!\n");
I mean, the innermost loop is fo... |
I have been reading and searching and I still cannot understand if there exists a language as following:
Can a language be P-complete with respect to $\mathsf{Space}(\log \log n)$ reductions?
These reductions use some sort of transducer/transformer that is identical to a logarithmic transformer, except its working ta... |
Can somebody explain please why Ford-Fulkerson Algorithm has pseudo-polynomial complexity? I understand that the complexity in this case strongly depends on the capacities of the edges of the network, since we have $O(|E|*f_{max})$, but why is the algorithm still not polynomial?
|
Is there a polynomial-time reduction from Directed Hamiltonian Path Problem to 3SAT which is linear in the number of vertices? That is, it reduces every directed graph $G$ with $n$ vertices to a formula $\varphi$ with at most $O(n)$ clauses within time at most $p(n)$ for some polynomial $p(n)$?
Since Cook Levin Theorem... |
I have a dependency graph of tasks, which forms a DAG. I'm looking for an algorithm to calculate the optimal topological traverse to minimize the "working set". Specifically, I define the current working set as the set of nodes which have been visited, and which have at least one outgoing edge which is untraversed.
Eve... |
hello and thank you for helping me understand the following:
I really don't understand this, why if language $A \in BPP$ then $A≤_P\#SAT$?
language A is in BPP class, if for a probabilistic turing machine M, M outputs 1 for all $x \in A$ in a probability $\geq 2/3$, and for all $x \not \in A$ M outputs 1 in a probabil... |
Suppose as a computer programmer, you have been assigned a task to develop a program to store the sorted data in ascending order. Initially you have used linked list data structure to store the data but search operation was time consuming then you decided to use BST (Binary Search Tree) but retrieval efficiency is not ... |
I want a hueristic algorithm for the following problem. Here, $V(G)$, $E(G)$ respectively refer to the vertex set and edge set of a graph $G$.
Input: two planar bipartite graphs, $G,H$ and a map $\phi: A\to V(H)$, where $A$ is a subset of $V(G)$.
Task: determine if there is a (bijective) map $\phi': V(G) \to V(H)$, suc... |
This is an algo. programmed for displaying a letter pyramid if the buildPyramids() method is passed argument str, i.e. "12345":
1
121
12321
1234321
123454321
Code:
void buildPyramids(string str) {
size_t len = str.length();
size_t i, j, k, m;
for(m=0; m<len; m++) {
for(i=len-m-1; i > 0;... |
I'm trying to proof that the following language is not regular using pumping lemma.
$L=\{w\bar{w}|w\in \{0,1\}^* and\ \bar{w}\ is\ one's\ complement\ of\ w\}$
I started by stating that:
$|w\bar{w}| = 2p = |xyz|$
Because of Pumping Lemma the following has to be true:
$1 \leq |y| \leq |xy| \leq p$
Because $|xy| \leq p$ a... |
I have had the following problem at my last exam:
For how many permutations of set {1, 2, ..., n} where n > 2 will insertion sort (without guard element) perform exactly n comparisons.
My thinking was: there must be exactly one inversion of succeeding elements so any of the pairs (2, 3) or (3, 4) ... or (n-1, n) has to... |
I’m trying to find a way without just hard coding to create a categorical distribution over all characters given a character but with similar looking ones having higher probability. For example, if the input is ‘l’ then 1,j,!,/,I,t would be characters considered similar looking and should have a higher probability than... |
Complexities, such as time complexity, space complexity, communication complexity and sample complexity, are often used to analyze the performance of algorithms. As far as I know, time complexity and space complexity are collectively referred to as computational complexity.
Are there other common complexities in theore... |
My assignment asked to design a DFA that computes the language:
$L = \{ w \in \{a,b,c\}^\star | \#_a(w) $ is even, $\#_b(w)$ is odd, $\#_c(w)$ is even}
I have been stuck on this question for 2 hours, I draw approximately 20 sketches but still fail. The only thing that I observed so far is we need at least 8 states, or... |
I'd like to understand convolutional neural network.
Consider this quote from Stanford CS notes on Convolutional Neural Networks for Visual Recognition (CNNs/ConvNets):
Example Architecture: Overview. We will go into more details below, but a simple ConvNet for CIFAR-10 classification could have the architecture [INPU... |
In the textbook Arora-Barak, after presenting the Cook-Levin theorem's proof the authors say that the proof can be modified slightly to make the reduction parsimonious. The parsimonious reduction is one in which certificates of an NP language are mapped bijectively on the certificates of SAT. I am not sure why the redu... |
Consider a directed acyclic graph $G$ with vertex set $V$. Choose a vertex $v$, and let $H$ be the subgraph containing $v$ and all other vertices in $G$ that are reachable from $v$ (along with the associated directed edges).
(In other words, if we choose $v \in V$, then we are interested in the subset consisting of $v... |
As the title suggests, is this possible? Or does it halt execution when it hits the trap state? Thanks to anyone who can clear this up.
|
Currently I am experimenting with Kernighan-Lin algorithm to produce coarse representation of navigation mesh for hierarchical pathfinding.
Based on the use case, my requirement is that partitions produced are a connected graph on its own.
For example, a bisection of the below grid
x--x--x--x--x--x
| | | | | |
x--... |
I'm trying to find out time complexity of a recursive factorial algorithm which can be written as:
fact(n)
{
if(n == 1)
return 1;
else
return n*fact(n-1)
}
So I write the recurrence relation as
T(n) = n * T(n-1)
Which is correct according to this post: Recurrence relation of factorial
And I calculate... |
I'm going to solving many times this specific equations:
$$2^{x+y} \cdot c - a^{y} \cdot z = 1$$
in which $$a$$ can be equal to: $$-7,-5,-3,-1,1,3,5,7.$$ And $$x+y$$ will be equal to $$128.$$ It has to be done with euclidean algorithm, but how many step it requires in average in this specific case?
I know that euclidea... |
Previously, I tried convert a color image into a greyscale image by using pixel values of an image from a simple formula :-
Grey = 0.3*Red + 0.58*Green + 0.11*Blue
After that, I wanted to convert the greyscale image into a binary image & I used two different techniques :
NOTE : Red, Green & Blue are variables storing ... |
A question arising from a scheduling problem:
I have a finite set $X$ with elements $x_i$ and some preorder $\leq$.
I have pairs $p_j$ of $x_i$ (i.e. $p_j$ = $(x_k, x_l)$) with the property that $x_k \leq x_l$.
I say that for two pairs $p, p'$ : $p \leq p'$ when for all $x \in p, x' \in p': x\leq x'$.
I call two pairs ... |
Assume a Hotel reservation scenario, given $m$ ranked lists of attribute values such as distance, price, amenities (normalized between $0$ and $1$), and a unifying linear score function $F(\cdot)=\alpha_1*score_1+ \alpha_2*score_2+ \alpha_3*score_3$, the Threshold Algorithm (TA) is optimal in finding top-$k$ results th... |
I just finished reading about operators in relational algebra and tried to solve this problem. But I dont even understand what the first statement is doing. From what I know, $π$ (project) is a unary opeartor that takes a single relation and selects some attributes from all of the attributes (columns) of that relation.... |
Suppose you have a program one_factor(N) that, given an n-digit binary number, N, returns one of the prime factors of the number in Theta(n^2) time (note that I used a lowercase n in my theta notation.)
Using this algorithm, I want to find an efficient algorithm to factor an n-digit binary number into primes and print ... |
Imagine you are given a word samw and it is an invalid word (for the word same), and you need to find the correct word from the dictionary. The dictionary contains a list of words ordered by the frequency of the occurrence of the word with the most frequent word in the beginning.
There are the following rules on how to... |
I have a point cloud of size n (in the example on picture n = 5). The starting coordinates are in green, destination coordinates are in red. What I need is to move the points from the starting coordinates to the destination ones so that the total distance, traveled by all points is minimal.
There is one important restr... |
In a 32-bit byte addressable memory system, each "row" has 4 bytes and each byte has a 32-bit address.
My question is: can I read and/or write word of length 64 bits from/to memory?
In other terms, can my word length be 8 bytes long or is the maximum number of bytes/word 4?
|
How to reduce $L_c=\{\langle M_1 \rangle, \langle M_2 \rangle):L(M_1)\cap L(M_2)\neq \emptyset\}$ to $A_{TM} =\{\langle M,w \rangle: M$ is a Turing machine that accepts $w$}.
My try:
Construct a Turing machine $N$ using a Turing Machine $U$ that decides universal language as subroutine to decide $L_c$.
$N$, on any inpu... |
I know how to verify whether grammar is LR(0) or not. But this particular case is little tricky and hence the question.
Grammar:
$SL \rightarrow SL ; S \space | \space \epsilon$
$S \rightarrow s$
(Note: $SL$ is single non-terminal.)
Now, LR(0) automaton for this grammar is as follow:
Now my question is whether to co... |
I'm reading Introduction to Computational Theory by Michael Sipser. He provides the NFA below as one that recognizes the language of the regular expression $ab$.
What is the purpose of the middle two states and the $\varepsilon$ transition between them? Could this NFA be designed without them and still work as intended... |
I have a list of patterns with each pattern containing one or more wildcards. For example:
abc*
a*
*a*z*
*z
Wildcard (*) matches one or more characters. For example, any input string starting with 'a' would match a pattern a*.
How can I determine if there exists an input string that would match all of the provided pa... |
For instance when the question contains $\{a,b\}^*$ does this mean that the DFA must have at least one $a$ and one $b$ on top of whatever conditions it has?
For example a DFA that accepts $\{w \in \{a,b\}^* : w \text{ contains } bbb\}$ should it reject the actual string $bbb$ because it does not contain an $a$?
|
Is $\log_2(2n) \in O(\log_2(n))$ ?
I don't know how to prove whether this is true or false.
Any help is appreciated
|
Given a 3xN board. Find the number of ways to cover it using 2x2 or 3x1 or 1x3 tiles.
|
According to image 1, for two way communication, each person needs to generate a pair of keys. However, according to image 2, only one pair of keys is required for two way communication. Thanks to anyone who can settle my confusion.
Source 1
If a two-way communication is required between all five workers, then they al... |
How to write a pseudocode to split a number value to array of numbers? Let's say the number value is 12345. I need to convert it into [1,2,3,4,5].
|
Assume we know that the implementation for the multiplication operator for a language is known to be $O(n^2)$.
Given this pseudocode:
func wibble_wobble(List<Integer> input):
Integer constant = input.length;
return List<Integer> { item * constant foreach item in input };
Since the loop inside the new list init... |
Let $A$ be a randomised algorithm and $F$ be a function such that $A$ returns $F(x)$ on any input $x$. Furthermore suppose that, for input $x$ of size $n$, the $\textbf{expected}$ running time of $A$ is $O(n)$. Give an algorithm that is guaranteed to terminate in time $O(n)$ for every input, and which on input $x$ outp... |
I'm taking a data-structure class, and the lecturer made the following assertion:
the number of attempts needed to insert n keys in a hash table with linear probing is independent of their order.
No proof was given, so I tried to get one myself. However, I'm stuck.
My approach at the moment: I try to show that if I s... |
I had this idea of program tohelp me in my everyday life. We both work and don't live in the same city. I was wondering how to make a program that calculate, depending on the work scheduleand the number of travel required between both our house, the best way to spend our weekend, like at which house we have to be and w... |
Information theory to a large extent deals with how to efficiently encode messages given a probability distribution over messages.
Intuitively, it seems like we can think of machine instructions (or programs) as "messages to the CPU". Some messages are more probable than others. E.g. "add numbers x and y" is more proba... |
I want to calculate/estimate the energy consumption for the different convolutional neural networks. Is there any possibility to measure the energy consumed by AlexNet for example with a tool or with Keras or something else?
|
Lets say I have a list of many (10s of thousands - millions) objects, and each of these objects has a given number of 3-D vertices (my current implementation uses 8 vertices each, but this number can be reduced if it causes a very significant increase in performance). These vertices are currently stored as floats from ... |
Suppose, you are given an array of strings of different lengths, but the total number of characters over all the strings is n. Describe an algorithm using Counting Sort to sort the strings in alphabetic order (eg. algorithm < cs < hello) in O(n) time.
|
Convert CFG to CNF
The Grammar
E→E+T
E→T
T→T*F
T→F
F→(E)
F→x
Step 1
Assign variables to terminals
A→ +
B→ *
C→(
D→ )
F→x
Step 2
Remove epsilon which in this grammar is not available
Step 3
Remove useless symbols which there are none
Step 4
Remove unit rule
S→E
E→T
T→F
So we have
E→T*F|E+T
T→(E)|x
F→(E)|x
Step 5
A... |
I've been given a grammar definition of "Simple C language" in Backus-Naur to write a compiler for a class assignment. I've been trying to implement the parser for some time now and I just can't move forward due to some endless loops and I think the definition might be wrong.
This is the full definition of "Simple C La... |
I came across following problem:
Find number of binary trees possible with 2 as roots. Nodes={1,2,3,4,5}
There was no solution given. I knew number of binary trees for given preorder is given by Catalan number as $\frac{1}{n+1}\binom{2n}{n}$, where $n$ is number of nodes. So does the above question same as asking: ho... |
I want to space points evenly (i.e. maximizing minimal distance between two points) on some smooth surface $S\subseteq\mathbf{R}^n$ (usually $n=3$), where I have a projection operator $p:\mathbf{R}^n\to S$ which approximates the closest point on the surface. My idea is to place them randomly first and then let some re... |
Hello and thank you for helping me understand the following:
I am trying to understand why the following cannot exist: A P-Complete language in regards to a log-logarithmic space.
context: Defining a new kind of reduction: a reduction in log-logarithmic space. For this purpose, we define a log-logarithmic transformer t... |
I am currently struggling with a bin packing variant, where we have fuel and compartments of a tank truck. Some industry constraints apply, but the whole picture is that you must fit the total volume with the optimum way through the compartments.
I have created a model, which works almost perfectly, where I try to mini... |
I have no idea how to solve this one - I end up with $\sum_{i=0}^k (2^k * 5 * 3^i)$ but I have no clue how to get any further than that (e.g. resolve the sum even further, if it's even correct to begin with).
This is the task - masters theorem is not allowed:
T(n) = 2 * T(n/3) + 5n
T(1) = 5
and we know, that n = 3^k
Th... |
I'm looking for a way to cluster points in a given space, where clusters form around specific closed, allowed zones of that initial space. Each allowed zone should be surrounded by points of its cluster.
However, it is not only necessary to match the points to the closest allowed zone, but also to take into considerati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.