instruction stringlengths 35 29.1k |
|---|
I found a solution of exercise C-8.28 from Data Structures and Algorithms in Java (6th Edition), but I'm having trouble understanding how the for loop condition works here.
for(Position<E> c : T.children(p))
I'm having trouble understanding what the condition in the for loop means. From what I've learned so far the fo... |
A complete $k$-CNF formula on $n$ variables $(k\le n)$ is a $k$-CNF formula which contains all clauses of width $k$ or lower it implies.
Let us define the (Complete/Assign) 3-SAT problem: Given $F$, a complete 3-CNF formula on $n$ variables and $I$, a partial assignment of $l$ literals among $n$ (where $l\le n$). Let $... |
We have a Turing Machine that cannot write the same symbol it has read in a transition, meaning it should always alter the symbol when passing it. How can we prove that such machines have equal processing power compared with the standard Turing Machines?
|
Say you have the finite alphabet $\{a,b,c,d,e,f,g\}$ and an enumeration of finite strings over it by the shortlex order (length-lexicographic ordering), starting with the empty string, i.e.,
$\epsilon, a, b, c, d, e, f, g,$ $aa, ab, ac, \cdots,$ $gg, \cdots, aaa, aab, aac,$ $\cdots, ggg, \cdots$.
What's the most effici... |
I have a question about the use of calibration in neural networks and its relation to accuracy. In Guo et al. it says: "Because the parameter T does not change the maximum of the softmax function, the class prediction remains unchanged. In other words, temperature scaling does not affect the model’s accuracy."
This mak... |
I have a coding problem I'm running into that feels like it's solved:
Given a (directed) graph, and an equivalence relation on nodes, merge the equivalent nodes in a way that preserves the graph structure to create a "factor" graph, in the sense that every edge connected to one of the equivalent nodes is connected to t... |
I am trying to do some runtime analysis on a problem, but get stuck on some details.
I have a string $P$ of length $n$, where I am allowed to halve substrings inside of it and keep the right-hand side of it to form new strings. We can now halve substrings in the new string. The length of the substrings that are halved ... |
According to my syllabus, this is a dynamic programming problem yet the explanation to the problem I’m supplied with is really confusing and not close to being understandable.
The problem is such:
You are required to give change equal to n (n is a positive nonzero integer, not necessarily bigger than biggest coin) with... |
Motivation & Question
So I can theoretically build a "computer" to calculate the exact anti-derivative of a particular function.
Using classical calculations and the Robin boundary condition I show
that one calculate the anti-derivative of a function within time $2X$
(I can compute an integral below)
$$\frac{2 \alpha... |
Pipelined processors suffer from stalls due to different kind of hazards and one way of dealing with it is to implement forwarding of different types. For example ALU-ALU forwarding or full forwarding (MEM stage -> EX stage). A result of implementing forwarding in a pipelined processor is that we get an increased throu... |
Given a Min-Heap with $n$ elements.
Assume that we choose $\lceil \log_2n \rceil$ elements from the heap (not in any specific order/index's), and we subtract a value $k>0$ from all of their keys.
Suggest an algorithm to fix the min-heap that runs in $O((\log_2n)^2)$.
My thoughts:
In a min heap the key value of chi... |
I've been assigned to find the loop invariant for the following code:
i=0;
j=n-1;
while(i < n/2){
l = A[i];
r = A[j];
A[j] = l;
A[i] = r;
j = j-1;
i = i+1;
}
I understand the code function (reverses array), the guard (i < n/2), and I can find different invariants (e.g. i+j = n-1), but I'm stuck... |
$L=\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j
;\ j \text{ is even, then } k =i+j\}$
I tried writing $L$ as the union of the language created with $j$ odd and the one with $j$ even.
When $j$ is odd, I can prove using the pumping lemma that it is not a cfl.
When $j$ is even, I can prove that it is a cfl by writing ... |
What is being summed and why?
$s'$ is the next state. Don't we just want the next state with the max value?
There is an $s'$ under the summation, so are all the possible $s'$ in $P$ and the $s'$ in $V(s')$ being summed? Or is everything to the right of the summation being summed? The $s$, the $a$, the $s'$ and the $V(s... |
I heard a few times that if we allow computations with infinite precision, we could have unrealistic powers of computation up to the point of solving NP problems efficiently.
Is it true? If yes:
what is the model of computations used to define infinitely precise arithmetic? Like do we need to assume that accessing to ... |
I would love to learn visual AI and what better way than creating a bot to play offline games. The problem is with no experience in AI other than Azure through my college, I have no experience.
Does anyone have resources that could aid in my learning or any tips for getting started? All will be appreciated.
|
Let $L$ be a context-free language. Prove that there exists integer $p>0$ such that
$ \forall z\in L $ such that $ |z|\ge p $, there exists a partition $ z=uvwxy $ such that
$|vwx|\le p$
$|vx|\geq2$
$\forall i\geq 0 : uv^iwx^iy\in L$
HINT: $p$ needs to be bounded $ p\leq 2^{2k}$ which gives you more power. What is th... |
I'm wondering if a language (A) is a decidable language and language (B) is a regular language, is the intersection between A and B regular?
|
I'm looking for a book that contains the formal definition of sigma protocol (something like: A sigma protocol for a relation $R$ and a challenge space $C$ is... that satisfies the properties of soundness..., completeness..., honest verifier zero-knowledge...)
I keep finding books that gives an example of sigma protoco... |
Suppose there is an integer array $a_1,a_2,...,a_n$. Calculate the sum of average of all subarrays. For example, the sum of average of all subarrays of array $[1,3,5]$ is $1+3+5+\frac{1+3}{2}+\frac{3+5}{2}+\frac{1+3+5}{3} = 18$
I'm wondering does it exist an $O(n)$ algorithm?
|
Is it better to think about tokens from right to left and perform right factoring on grammar for an LR(1) parser? As apposed to thinking about tokens left to right and doing left factoring on grammar for an LL(1) parser.
Example java import statement.
S1 -> S2 ;
S2 -> S5
S2 -> S3 id
S2 -> S4 *
S3 -> S5 as
S4 -> S5 .
S5... |
I'm trying to prove that $\mathrm{HALF}\text-\mathrm{FALSE}$ is NP-hard, where $\mathrm{HALF}\text-\mathrm{FALSE}$ is the following problem:
given a boolean formula $\phi(x_1,\dots,x_n)$, is there a satisfying assignament in which exactly $n/2$ variables have value false?
Now, i got the problem down if it was like th... |
$L = \{{a^{2n+1}b^{m+2}a^n | m \neq 2n}\}$
I tried to split $L$ in 2: when $m > 2n$ and $m<2n$, however both resulting languages are not context-free, so I did not find out anything about $L$.
The pumping lemma did not give any results either, because the string $a^{2p+1}b^pa^p$ for example can be pumped when $vwx$ is ... |
Let $(X_1,Y_1)$ and $(X_2,Y_2)$ be identically and independently distributed. Also consider $Z=X_1+X_2$. I am trying to prove the following inequality:
$$ H(X_2 \vert Y_1 Y_2 Z) \leq H (X_1 \vert Y_1)\leq H(Z \vert Y_1 Y_2).$$
I think I can show that middle term is the average of the other two. So now if I can show
$$... |
Suppose we have a directed, weighted graph, $G = (V, E, w)$, with non-negative weights. We define the weight of the shortest path different from the original definition.
The weight of a path with at most 5 edges (including 5) will be defined as usual, meaning the sum of the edges weights. The weight of a path with at l... |
An instance of the Dominating Set problem is given by an undirected graph
$G = (V, E)$ and an integer $k$; it is a ‘yes’-instance if there is a subset of vertices $S ⊆ V$
with $|S| ≤ k$ such that for each $v ∈ V$ we have $v ∈ S$ or $u ∈ S$ for some ${u, v} ∈ E$.
I'm trying to show that if the degree of each vertex of $... |
The problem that I'm trying to solve goes like this:
A project is split into tasks. Each task takes a known number of days. Some tasks can be done at any time(lets call these simple tasks), others depend on other tasks that must first be done. Design an algorithm that can find the minimum number of days necessary to fi... |
A standalone statement of my question
Given a program that takes no argument, we are interested in whether the program will eventually terminate. My question is this:
Theoretically speaking, can we always find a proof of the termination/non-termination of a program?
Clarification
Unlike the general halting problem, thi... |
Lets say a system has 1TB of memory and 4kB blocks. How many MB of memory do we need if we want to store a bitvector to represent the current memory allocation situation with a bitvector?
Bitvector: a string of concatenated 0s and 1s, where 0 means a block is free, 1 means it is already allocated.
The solution is given... |
I'm trying to train some linear logistic regression models and I need regularization. My models contain around 4000 features.
I know that without regularization, a good rule of thumb is to have 10x the number of data points as the number of features.
Unfortunately I have on the order of 1000 examples. With high regular... |
Is it possible to solve the maximum flow problem in the real world, ie. using water running through physical pipes? So you would have a tap at the source node, pipes of various diameter (depending on their capacity) connecting nodes and a sink at the target node. You would turn on the tap on full and then try to measur... |
I wonder if there's Digital Logic Circuit (using combinatorial logic gates) that check if number is prime or not.
For example given input fixed 8-bit that will produce 1-bit output.
00000101 will produce output 1 (1 means prime)
00000110 will produce output 0 (0 means composite).
I know it's possible if using Sequentia... |
if UTC is universal, what drawbacks does it have in using it in a distributed system to coordinate events or use it as a global objective reference clock?
isn't it right to just use UTC to timestamp every message to order messages without using lamport logical clocks!
|
I've been solving a lot of questions lately about determining the type of a given language, by type I mean whether it's regular, CFL, in P, Turing-decidable, Turing-acceptable, or all the languages. and I have this language here:
$$L=\{w:|w|\text{ is even, and it has }\frac{|w|}2\text{ consecutive 0's}\}$$
So my main p... |
In the book "Fundamentos de sistemas operativos" (Gunnar Wolf, Esteban Ruiz, Federico Bergero, Erwin Meza p.254) it says:
Al cargar un programa el sistema operativo calcula cuánta memoria va a
requerir a lo largo de su vida prevista. Esto incluye el espacio
requerido para la asignación dinámica de memoria con la famil... |
I recently started learning context free grammars and was working on a couple of exercise problems and couldn't really figure out how would this exactly look like.
I started with:
$$\begin{align}S&\to S_1S_2\\
S_1&\to aS_1\mid\epsilon\\
S_2&\to bS_2\mid\epsilon\\
\end{align}$$
But I'm not sure how to create transitions... |
I see this occasionally when solving Dynamic programming questions. I like to solve dp questions using recursion, then Memoize it based on the number of parameters I pass to the recursive function.
The question is, in my code below, even though I passed three parameters to my recursive function, the solution still work... |
Looking for an example of a LR(1) grammar that can not be turned into an LL(1) grammar that parsers the same language.
|
prove this language verifies the conclusion of the pumping lemma
show that $L=\{a^*\}\cup\{b^ja^{n^2}|0<j,1\leq n \}$
Holds the pumping lemma for context-free languages
the problem is that I know how to refute with pumping lemma that a language is not context-free.
but I don't know how to prove Language holds the p... |
What are some equations/ inequalities and properties of bitwise X-OR that can be used in competitive programming.
|
I have to show that given $f:\mathbb{N}\rightarrow\mathbb{N}$ the function that returns the number of times $6$ appears in the input (for example $f(436546)=2$) is primitive recursive.
The exercise says to assume that the functions $rem(m,n)$ and $div(m,n)$, which returns the remainder and the quotient, are recursive p... |
Definitions:
1.
$$\mathsf{NP} = \{S \: \mid \: \text{Exists a polynomial, non-deterministic algorithm $A$ s.t. $A$ decides $S$} \}$$ Where a polynomial non-deterministic algorithm, is an algorithm that it's runtime is bounded by $p$ some polynomial, and may behave differently from run to run.
$$\mathsf{P/poly} = \bigc... |
Printing an array using recursion is much slower as compared to printing an array using iteration. Why? Is iteration always faster than recursion?
|
Given a graph $G = (V, E)$ where
G is directed: $ \forall \ e \in E$ : $e$ has a direction.
G is acyclic (no cycles): $ \forall$ path $v_1, \dots , v_n : (v_n, v_1) \not\in E $.
If indegree $\gt0$, indegree $\ge$ outdegree: $ \forall \ v \in V : d^{-1}(v) \gt0\implies d^{-1}(v) \ge d^{+1}(v) $.
If indegree $=$ $0$, ou... |
Suppose i have a CNF formula. If i negate the CNF formula, then i obtain DNF formula. However, i can't find anywhere on internet that mention the time complexity. What is the time complexity of negating a CNF formula and converting it to DNF formula?
|
Generating numbers with $k$ bits set for a poker simulation
Context
I'm trying to generate all possible Texas Hold'em games for $p$ players, which means there will be at most $2 \cdot p + 5$ cards at play.
To make things a little bit easier, I figured that I could use a 64-bit number to represent each of the cards in a... |
I've learned some basics about P and NP. Please excuse if the following is not very precise.
I've read that NP-complete problems are the hardest problems in NP. (Is that correct?)
But now I'm wondering if P problems have polynomial runtime, and assuming P=NP for a moment, how can polynomial runtime problems ever have s... |
I'm struggling with this question. I would appreciate a detailed solution as it would help me better understand the subject.
Convert the following Context Free grammar into a Regular Grammar:
S -> aSb | A
A -> bA | a
|
I believe this is true and I have given a simple proof of this:
If A is Turing-reducible to B then there exists a Turing machine with oracle for B that decides A, because B is Turing-recognizable then by using the oracle for B we can decide A and therefore A is Turing recognizable.
|
I have implemented an indexed linked list that runs (under mild assumptions) all single-element operations in $\mathcal{O}(\sqrt{n})$ time. The description is here and Java implementation is here.
It’s clear to me that the running time is linear in $n$ in the worst case, but I would love to see something smarter than t... |
Assume in a distributed network, where the nodes are not trusted and are identified by their public keys, we intend to select one of them in a random process. In such a situation, all of the nodes have the same chances to be elected.
Since the system is not centralized and there is no trusted server performing the elec... |
Consider an arbitrary sequence of $m$ MAKESET operations, followed by $u$ UNION operations, followed
by $f$ FIND operations, and let $n = m + u + f$ in a disjoint set union data structure. Prove that if we use union by rank and FIND with
path compression, all $n$ operations are executed in $O(n)$ time.
I'm not sure how... |
Normally, when working with dictionaries, we expect around O(1) complexity when we go to retrieve a value given the key (and when we insert). I work in Python, but this might apply to any dynamic typed language. I have been working with dictionaries where the keys are frozensets, which are just sets that are hashable ... |
Let WALKSAT be defined as follows:
Let $σ$ be a random truth assignment to the vars
For $t = 1, 2, . . . , 3n$:
◦ If $\phi$ is satisfied by $σ$, exit the loop
◦ Else, pick an unsatisfied clause $c$ and a var $x$ in $c$ uniformly at random
◦ Flip the value of $x$ in $σ$ (e.g., $x ← TRUE$ becomes $x ← FALSE$ )
Output $σ$... |
I built a recursion tree like this:
0
/ \
0 0
/\ /\
... ...
So the tree has height n, and width $2^n$.
But if the sum of all levels is $\sum_{i=0}^{n}0$, then is the function simply $O(1)$?
|
:)
Currently I am browsing through the internet on the hunt for a topic for my bachelors thesis. Whilst being on Reddit I discovered an interesting repo (https://github.com/mxgmn/MarkovJunior) for a probabilistic PL that uses markovs algorithm(https://en.wikipedia.org/wiki/Markov_algorithm?wprov=sfti1) for some awesome... |
I'm trying to figure out whether the following problem is R.E.?
Given a turing machine $M$ with alphabet $\Sigma$ is it the case that:
$L(M) = \{w \in \Sigma^* | |w| \space is \space prime\}$
I think I have a reduction from $HALT$ complement which is co - R.E. to the problem proving that it's not R.E. but I'm not entir... |
Note this question was originally asked on Theoretical CS Stack Exchange, but it is not a research level question so it is being closed, and I am asking here instead.
Suppose we simulated a Turing machine on a long string $s$, where $|s| = 10^{100}$ for example. Then if we wanted to learn the value of $s_i$, the $i$th... |
I do not know with which technique i can prove if a LTL forumula is valid.
Let's say we have for example this one: ¬q U(¬p ∧ ¬q) → ¬Gp. How can prove if this valid or not? (should be true in any state of any model).
|
I've been asked to list the frontier steps for greedy best-first search for the graph in the picture below.
I've attempted to recreate the algorithm in Golang, as shown below:
// Do takes a source (starting point), a target (endpoint)
func (g *GreedySearch[T]) Do(source, target *node.NodeWithCost[T]) []T {
path := ... |
Looking at the image above, thinking in terms of A* search. I don't fully understand the heuristic function. The cost makes sense, so thinking in terms of a traditional map or navigation scenario. I'd see the heuristic function here as the number of direct steps. Or the number of cities we pass through, for example. T... |
Could someone please help me check if my automaton is correctly designed?
$$L = \{ 0^i1^j2^{i+j} | i \ge 0, j \ge 0, i+j > 0 \}$$
This was an exercise from our workbook, but their solution is a bit different
|
I read two definitions of cluster graphs that seem in conflict to me. One is from Koller:
We begin by defining a cluster graph — a data structure that provides a graphical flowchart of
the factor-manipulation process. Each node in the cluster graph is a cluster, which is associated
with a subset of variables; the grap... |
We know that A read-only Turing machine or Two-way deterministic finite-state automaton (2DFA)is class of models of computability that behave like a standard Turing machine and can move in both directions across input, except cannot write to its input tape. The machine in its bare form is equivalent to a Deterministic ... |
The problem: in 2d, given a line and an unordered set of $N$ points with real coordinates, find the intersection between the line and the convex hull of the points.
Clearly, one can explicitly construct the convex hull and find the answer in $O(N \log N)$. Is there a faster approach? Is there a superlinear lower bound ... |
Imagine a machine that can only hold N-bit values (N-bit uint).
The machine can also calculate the 2N-bit result of two operations: mult, exp.
The 2N-bit result is stored across 2 N-bit values (high/low bits).
How could we then code the mult (or exp) of 2 2N-bit values that would result in a 4N-bit value?
The 2 2N-bit ... |
someone sent me a question lately and I wasn't able to solve it so I'm asking for help.
Question: Given the language
$$L=\{w\in\{0,1\}^*:|w| \text{ is even and the first half of it has a balanced string of length } 100\}$$
Balanced: A string $w\in\{0,1\}^*$ is said to balanced if it has the same number of $0$'s and $1$... |
I've found two slightly different Bellman Equations. Are they totally equivalent?
I see the one on the bottom has an s' in the reward. Does this or anything else about the groupings change anything fundamental about the equation?
I'm not totally math literate so I'm not sure which max a we are taking. Is it just the ac... |
In my understanding, if we could prove one of the NP-complete problems is a P problem, then all of the NP problems are P problems. Because P problems are NP problems and NP problems are P problems, P=NP.
I thought if P=NP, then all NP-complete problems are also P problems, but not all P problems are NP-complete.
But it... |
This algorithm solves the Two-Sum problem$^1$ assuming that the input array/list is sorted.
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
N = len(nums)
l, r = 0, N-1
while l < r:
comp = target - nums[l]
r = bisect_left(nums, comp, lo=l+1... |
Ok so I'm learning Finite Automata in my Theory of Computation course and understand the basic FSM but can't wrap my head around this question:
The AC should only turn on if a person is
detected in the room and the temperature is hot (80 degrees or higher). It turns off when no one is detected in the room, the window i... |
I'm looking for an algorithm that finds a simple path from S to T in a directed graph (which might have cycles) so that the product of edge weights in the path is maximum. All the edge weights of the graph are larger than zero. For any pair of nodes, there might be more than 1 edge.
I thought of the following approach.... |
$L = \{a^nb^m | n \le m \le 3n \} $
This is by far the hardest pushdown automaton I had to design. I literally have no idea where to start. Here's my thought process. Firstly, I thought that for each valid pair $(n,m)$ the differences between the number of $b$s abd $a$s will be the same. That wasn't true, as the number... |
A bipartite graph corresponds to a rectangle of ones in the adjacency matrix of this graph.
Having a sparse graph, I would like to find the largest approximated bipartite graph.
approximated means that some edges not in the sparse graph will be in the bipartite graph.
I think this problem can be reformulated in: Given ... |
I reached a subproblem where I have an array of numbers (0 to n) un-sorted and I want to retrieve, for each element, the index of the farthest value from it to the RIGHT of that element.
Like
0 1 2 3 4 5 6 7 8 (indexes)
0 3 7 5 4 2 8 1 6 (array)
so the answer would be
6 6 7 7 6 6 7 8 -1
Can anyone suggest some algori... |
Splaying trees are a heavily researched of theoretical computer science as they are conjectured to be optimal binary trees. They were first presented by Sleator & Tarjan in Self-Adjusting Binary Search Trees. In their paper, on pages 19-20, they propose to reduce the number of operations needed for a splay, by only doi... |
Is there an NFA with n states so that the DFA resulting from the standard conversion of the NFA to a DFA has at least $2^n - \alpha$ reachable states for some integer $\alpha \ge 1$?
Let $N= (Q, \Sigma, \mu, q_0, F)$ be the NFA. Construct a DFA $M = (Q',\Sigma, \delta, q, F')$ as follows: $Q' = \mathcal{P}(Q), F' = \... |
$L= \{ a^nb^m | n \le m \le 2n \}$
As you may recall, I posted a question a few hours ago about designing a PDA for a language similar to the one I have now. I have seen that the easiest way to construct it is to define a CFG for the language, and then transform it to non-deterministic PDA which accepts strings by empt... |
By "physical means", I mean, for example, using water pouring down tubes, or combining chemicals, etc. Basically, using some experiment in the physical world to perform some computation. I'll call this physical computation.
As the simplest example, if I want to add the numbers 3 and 5, I could just pour 3mL into a cup ... |
I am trying to find the Gesalt similarity of a string $S$ and all substrings of $T$ using Gestalt Pattern Matching (Ratcliff Obershelp Algorithm)
This algorithm requires me to find the matches of S and T
which is defined as follows
$$
matches(S,T) = \begin{cases}
matches(S1,T1) + [LCS(S,T)] + matches(S1,T2)&\text{if } ... |
The "classical" partition problem asks whether a given multiset $S$ of positive integers can be partitioned into two subsets $S_1$ and $S_2$ such that the sum of the numbers in $S_1$ equals the sum of the numbers in $S_2$.
The problem is known to be NP-hard.
I want to know if a similar problem is also NP-hard (I believ... |
Suppose that I have proof tree starting with some statement |- B in a sequent calculus, leading to two premises/leafs |- A.
Is it always possible to transform such a proof tree into another proof tree, which only contains one leaf |- A only using standard rules of natural deduction?
More schematically I want to perform... |
In "OpenGL superbible" 4th Edition by RICHARD S.WRIGHT JR page 60, there's this piece of code that confuses me:
// Reset coordinate system
glMatrixMode(GL_PROJECTION);
glLoadIdentity()
aspectRatio = (GLfloat)w / (GLfloat)h;
if (w <= h)
glOrtho (-100.0, 100.0, -100 / aspectRatio... |
I have a doubt on my solution of the following:
Formalize the language of a Turing machine that takes a Turing machine "M" and a character "a" as input, the language recognizes all and only the Turing machines that write "a" on the tape for every possible input w prove that this language is undecidable.
Formalization:
... |
To show that any formal language is NP Complete first it must be showed that this formal language is both in NP and NP Hard.
So to show that Horn Satisfiability is NP Complete first it must be showed that Horn Satisfiability is both in NP and NP Hard.
Horn Satisfiability is definitely in NP because Horn Satisfiability ... |
Are all np-complete problems also np-hard?
In other words, is np-complete a subset of np-hard?
I don't think it is entirely clear from the illsutration below, so I just wanted to quickly ask to ask to be completely sure. The np-hard area also includes the np-complete section right?
Just a quick "yes" or "no" is all I ... |
Suppose we have a dataframe with ~10M rows with ~9M duplicate records. What is the most time efficient way of selecting the unique records from this dataframe?
Some sort of sampling algorithm?
|
I'm reading the DFS section of CLRS-Introduction to Algorithms, and confuse on the $\Leftarrow$ direction of the proof of the white-path theorem of DFS algorithm in this book.
Note that each node u in the graph has 2 timestamps: $u.d$ records when u is discovered and $u.f$ records when the search finishes examining u’s... |
I was reading this paper, and the author (in private correspondence, though I'm sure it's also in the paper) explains that a bit string generated through Solomonoff induction will have growing (and unbounded) Kolmogorov complexity.
This sounds counterintuitive to me: Solomonoff induction tends to favor bit strings that... |
I need to calculate the LR(1) items of the following grammar:
S -> E
E -> E + T
E -> T
T -> ID
T -> ( E )
I can not even calculate the first group {[S -> .E, $]} correctly,
I read and tried to run the algorithm and did not understand why the correct answer for state 0 should be the group of items:
{[S -> .E, $];
[E -... |
I'm having trouble figuring out why using XOR for this problem works; I've done it a couple of times by-hand, and can't really seem to understand it. I know that XOR is commutative and associative, which is why it's good for finding (missing) duplicated numbers in a list. But applying that to the following problem does... |
I'm doing an implementation of the traveling salesman problem using genetic algorithms, but I can't get it: If we need to get the best route in a certain set of cities and then go back to the first city, how can we do that without going through cities we've already been through again? What would this route look like? I... |
I'm unsure as to the amount of operations in Dijkstra's shortest path in terms of $|V|$ and $|E|$.
My guess is that there are (worst case - complete graph):
$$|V| + \sum^{|V|}_{i=1}{(|V|-i)} = \frac{|V| \cdot (|V| + 1)}{2} \implies O(|V|^2)$$
operations for a graph $G = (V, E)$, assuming there are no negative cycles.
... |
Prove that if $C$ and $D$ are context-free languages, then so is $C\circ D := \cup_{n\ge 0} C^n D C^n $.
I know that $\{0^n 1 0^n : n\ge 0\}$ is context free, being the intersection of $L(0^* 10^*)$ and $L(G)$, where $G$ is the context free grammar with start symbol S given by $S\mapsto S1 S | 0S | \epsilon$. Also, I... |
It is a well known fact that the following 'subset-product' problem is $\mathsf{NP}$-complete when $n/\log M \in \Theta(1)$.
Consider a size-$n$ subset of a multiplicative group $\mathbb{G}\cong\mathbb{Z}^{*}_M$. Then an instance of the subset-product problem consists of $(a_1, a_2,\dots,a_n, t)$ with each $a_i, t\in ... |
I have a 2D array of some rows and columns which are having only 0's and 1's. I would want to know if there is a way to optimize the number of rows so that maximum number of columns have their column sum greater than a threshold (this is known). In the end, I should be able to get the rows which should be considered to... |
To prove PSAPCE = NP we will show following inclusions :
NP $\subseteq$ PSPACE : If every NP-hard language is PSPACE-hard then
SAT is also PSPACE-hard. Since every language in PSPACE can be
reduced polynomially to PSPACE-hard implies SAT $\in$ PSPACE.
SAT $\in$ PSPACE.
If L $\leq_{P}$ B and B $\in$ PSPACE $\implies$ ... |
I am not a Regular Experssion expert, but my request is simple: I need to match any string that has at least 3 characters of B and at most 2 characters of A
so for example:
"ABABBB" => Accepted
"ABBBBBB" => Accepted
"BBB" => Accepted
"ABB" => Rejected
"AABB" => Rejected
"AA" => Rejected
|
To those of you who saw my post from an hour ago - I deleted it because I came up with an idea.
To summarize, I have to design a PDA for this language, without using the usual method of firstly defining a CFG then transforming it to a PDA.
$ L = \{ a^{3n}b^{2n} | n \ge 0 \}$
Here is my proposed solution:
Since I didn'... |
In the Silberschatz's book "operating systems" the author talks about the allocation of memory via system buddy and slab.
My first question is: in the book, both memory allocation methods are described as allocation method that the kernel use to allocate memory only for kernel's process, not for user's process. Is it t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.