instruction stringlengths 35 29.1k |
|---|
Consider the following algorithm and find the tightest Big-$O$:
Assume $\texttt{multiplyKS}$($A,B$) is $O(n^{1.58})$ and $\texttt{Add}($A,B$)$ is $O(n)$.
If my runtime is $T(n)$, I have:
Lines 1 through 2 is $T(0)=d$, where $d$ is some constant
Line 3 is $T(n/2)$
Line 4 is $cn^{1.58}$, where $c$ is some constant
I ig... |
I would appreciate some help in determining the complexity/hardness of an inclusion/exclusion problem described in Wikipedia: https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle#A_generalization
Namely, given a family of subsets $A_1$, $A_2$, ..., $A_n$ of a universal set $S$, I need to calculate the nu... |
During a computer coding exam, I have encountered such a problem.
Given a list of vertexes and edges between the vertexes,and a positive number, D, what is the minimum spanning tree between the vertexes such that the sum of the lengths of the edges is minimal, provided that you may subtract any one edge of your choice... |
Say I have 3 simple tasks, to find the min, the max, and the average of an array of numbers.
A modular approach would be to write one function for each, thus iterating over the array thrice. However, that seems wasteful when all the information can be collected in a single iteration.
I understand that both approaches t... |
I have a 2-D array which contain 3 types of elements:
C (Contaminant)
R (Rock)
W (Water)
The rule is that:
contaminant can seep through water but not through rocks.
Let's say I have the following input array:
WWWRW
CRRRR
RWWRW
WWWRR
WRRWC
So the cells which have 'C' as their value in the above array can conta... |
I am working with grammars that need to be in Greibach Normal Form. I want to check whether a grammar recognises a string. In order to perform CYK the grammar would have to be converted into CNF. Is there an established way of carrying out such conversion?
|
Consider a context-sensitive grammar $G$, such that all the productions of $G$ have the form $A\to \alpha$ or $Ab \to \alpha b$ (in other words, the left context is always empty and the right context is either empty or consists of just one terminal).
Is the language defined by such a grammar necessarily context-free ?
... |
I have recently encountered a coding problem, specifically, the CCC problem S4.
In the problem, it states that you are given a spanning tree, or otherwise a "valid plan of pipes", that connect each and every home to one another. However, the tree is not the minimum spanning tree. You may use an enhancer, in exact word... |
Counting sort is originally like below code.
for (int i = 0; i <= 5; i++) c[i] = 0;
for (int i = 1; i <= 8; i++) c[a[i]]++;
for (int i = 1; i <= 5; i++) c[i] = c[i] + c[i - 1];
for (int i = 8; i >= 1; i--) {
b[c[a[i]]] = a[i];
c[a[i]]--;
}
In the above, last for loop iterates from last index because of stabili... |
I am trying to infer the type and prove that this is well-typed:
let $f =\lambda x.x$ in $f f$
Obviously the $f$ is the identity function, so it's the same as
let $id =\lambda x.x$ in $id$ $id$
I am trying to use these rules to infer the type, going bottom-up:
First I am using (T-LET') and on the left-hand side it's e... |
I'm a bit confused about the definition of the Minimum Cost Flow problem, in terms of the edge cost (or weight) values.
I don't remember a integral requirement on the cost/weight values for the edges when first learning the problem. But when I start to look for implementations, most algorithmic code I found require th... |
I have a book from my university that claims:
There is an linear algorithm that can convert BDD to CNF in linear time, and generate CNF in linear length of the BDD size (number of nodes).
Then they wrote an exercise to find one...
Actually I tried to do so, I thought to find the paths that brings me to 0, and then ... |
$$L=\{uv\in\{0,1,2\}^*\mid u\in\{0,1\}^*,v\in\{1,2\}^*, \text{ and }u\text{ has the same number of 1s as }v\}.$$
Here is my attempt solution, but it is not completely correct, any hint is appreciated
(not sure how I can ensure that $u$ and $v$ to have the same number of 1).
\begin{align}
S &\rightarrow S_l \mid S \mid... |
Edit:
I've pinpointed that the difference between solutions occurs when I apply the $H$, up to there, the solutions match. So, perhaps it is better to phrase my question as: how to apply an $H$ gate to one qubit in a 2-qubit system?
End Edit
I have the following quantum circuit, and I need to calculate the values of th... |
I've been learning about the Halting Problem and the proof that it is undecidable in its general case. The proof that it cannot be solved generally goes something like this:
Assume that some machine $H$ exists that can solve the halting problem on a given machine $A$ with input $x$ ($H$ determines whether the machine ... |
To answer the question below,
4-SAT: Given a formula in Conjunctive Normal Form, where each clause contains exactly 4 literals, does it have a satisfying truth assignment?
I was going to prove that 4-SAT is in NP-complete. But I saw that the way to prove CNF-SAT is in NP-complete is a bit different to the way of provi... |
I've read some posts about counting the number of assignment inside code of finding the maximum value in array like this:
FindMax(L):
n = len(L)
max = L[1]
for i = 2..n:
if (max < L[i])
max = L[i] (**)
return max
According to this post and post, it's about the array that elements are stric... |
Solving $T(n) = \frac{1}{n}(T(0)+T(1)+...+T(n-1)) + cn$ for all $ n \geq 1$
Subbing few numbers in we get
$T(1) = T(0)/1 + c(1)$
$T(2) = \frac{T(0)+T(1)}{2} + c(2) $
Which is kind of going backwards as I am going back to finding T(n)
So I am kind of confused about it, any idea?
Are we even able to unroll this reccurenc... |
Show that the following language is NP-complete
$$ L = \{ \langle G,k \rangle \mid \text{$G$ is a graph with a set $S$ of $k$ vertices hitting every edge of $G$}\}. $$
I know I should reduce the problem to SAT. But how I can do it?
|
In the 2004 paper "A Read-Only Transaction Anomaly Under Snapshot Isolation" by Alan Fekete et al. (which can be found here and here) the authors state:
We also note that any execution of T1 and T2 (with arbitrary parameter values) without T3 present will always act serializably.
I have tested this claim inside Postg... |
Assuming (hypothetically) someone proves $P=NP$ by providing a polynomial time algorithm for a $NP-Complete$ problem the Polynomial Hierarchy collapses.
What are the other (important) questions that are still left in complexity theory in respect to the remaining complexity classes?
If possible can someone help with a l... |
I'm interested in the following variant of Travelling Salesman Problem sometimes called Partial TSP. I'm particulary interested in the euclidian version :
Input : A set $\{x_1,\dots,x_n\}\subset \mathbb{R}^2$ of $n$ points in the plane, and an integer $k\le n$.
Output : A tour of $k$ points $x_{i_1},\dots, x_{i_k}$
Min... |
$k$-Weight Independent Set
Input: A vertex weighted graph $G=(V,E,w)$ and an integer $k$.
Question: Is the a set $V'\subset V$ such that $V'$ is an independent set and $\sum_{v\in V'} w(v) \geq k$?
Showing that this problem is in NP is trivial, but I'm suck on showing that $X \Longleftrightarrow Y$. The forward d... |
Do you know where Can I find an algorithm to sort a set of binary strings in colex order?
Recall, that two k−element subsets A and B
of a set with strict linear ordering $<$ are said to be in co-lexicographical order (colex order) if, for the sequences, a and b of their elements sorted in ascending order, there exists ... |
I'm currently working on an algorithm that requires me to come up with unique matrices. Two matrices are considered equivalent if one's rows and columns can be swapped to make it match the other. For example, $\begin{bmatrix} 0 & 0 \\ 1 & 1 \end{bmatrix} \equiv \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \not\equiv \b... |
I have decent enough experience with programming to be able to tackle most things but I want to know how you recommend making the jump from just programming to computer science. I still have a couple years till college, I'm only a sophomore right now although I am taking Calc over this summer which should help with som... |
A tree is provided which has $n$ nodes and each edge of that tree has a certain length. There are $M$ persons on the tree, numbered 1 through $M$. For each valid $i$, person number $i$ starts at time $t_i$ from vertex number $u_i$ and runs straight to vertex number $v_i$ with constant velocity $s_i$. Before time $t_i$... |
I have a question about follow sets.
Suppose there's a rule,
A -> XBCD
B -> $\beta$ | $\epsilon$
C -> $\gamma$ | $\epsilon$
D -> $\delta$
What is Follow(X)?
Is it (First(B) - $\epsilon$) $\cup$ (First(C) - $\epsilon$) $\cup$ First(D) = {$\beta$ , $\gamma$, $\delta$ } ?
|
Let $A = (a_1, a_2, \dots, a_n)$ denote an array of distinct values with an order defined. Consider the following randomized sorting algorithm.
Let $m := 0$.
Select a pair $(i, j)$ with $1 \le i < j \le n$ uniformly at random.
If $a_i > a_j$, swap $a_i$ and $a_j$.
If $m < m_{max}$, let $m := m + 1$ and go to step 2.
... |
I was going through graph theory and came across the term Euler path or some people prefer Euler trail as vertices can repeat.
According to the definition from wiki (https://en.wikipedia.org/wiki/Eulerian_path), Euler path is defined as under
In graph theory, a Eulerian trail (or Eulerian path) is a trail in a graph w... |
Let $L$ be a regular language, and $Pre(L)$ be the set of all words that are prefix of some word in $L$. Prove that $Pre(L)$ is regular.
My proof:
Let $M = (\Sigma, Q, \delta, q_0, F)$ be an automata such that $\mathcal{L}(M) = L$ and $Q' = \{ q \in Q \ | \ (\exists q_f, w \ | \ q_f \in F \ \wedge \ w \in \Sigma^{*}: ... |
Can a neural network be used to find the genus of a 2-manifold given for instance as a CW complex?
|
I'm looking to design an algorithm for a problem I have, and was hoping there may be someone that could provide some insight on where to start.
In my picture above, the grid is the area they needs to be explored by the circles. Each cell is a unit of work, so currently I've got lat/lng coordinates for the exact center... |
I'm confused as to why we can't write formulas of infinite length in FO. For example, to express reachability, I understand the proof that there cannot be a single formula for it, but it is expressible with a set of formulas?
Since any formula has an equivalent formula in CNF, if we transform a formula of infinite leng... |
I'm a cs student and i've just started learning about binary arithmetic.I have to do this homework assignement to get prepared for exams..I'm having some trouble figuring out how to convert a negative floating point number in binary system....I was thiking about IEEE-754 representation but i must use only two's complem... |
Basically, I'm interested in doing 2 things. Let's say we have a mesh M.
1. Find the minimum number of points(inside M) required to see the whole M.
2. Decompose M into polyhedrons which can be seen by only one point inside of them.
There are many articles on 2, for example I've found algorithms on convex decompositi... |
I was looking at a tutorial for recurrent neural networks in Python, and I have a question in regards to multiplying matrices of different sizes. Specifically, why does S[t] have 100 elements in it?
s[t] = np.tanh(self.U[:,x[t]] + self.W.dot(s[t-1]))
Earlier in the tutorial, the author lists the dimensions for each v... |
Are pushdown automata without $\varepsilon$-transitions as powerful as those with them? Intuitively, if we need to make such a transition, we could just add the letters on the next transition we take, but I'm not convinced by that reasoning.
|
Let's say a person took an image like this
I have access to all image attributes (like for example image format, resolution and so on), and I know the location of the person - basically the place where he made the photo. Also I know all the data about the camera - model, resolution and others.
Is there an algorithm th... |
I have taken one basic class in complexity and understand the fundamentals. E.g. P, NP, NP-hardness. But I can't understand how to interpret $BPP^{NP}$. I believe it means "BPP with an NP oracle" but how should I interpret that?
Does this mean that members of this class are problems for which there exist randomized al... |
I know many algorithms that can be analyzed using master theorem, but the only algorithm I know where the time is dominated by the leaves is fast matrix multiplication.
Are there other recursive algorithms (not necessarily master-theorem-style -- can be akra bazzi/something similar) where the time is dominated by the l... |
The paper for BIRCH (a clustering algorithm) contains definitions of a Clustering Feature (CF) where the notation is unclear (cf. PDF page 3 / section 4).
A cluster contains N d-dimensional entries $ \{ \vec{X}_1, \vec{X}_2, \dots, \vec{X}_N \} $ and its CF is composed of three values.
N the number of elements (straig... |
Let $L$ be the set of strings of length $n$ (say $n=400$, for example). Let $N = \{0,1,\dots,|L|-1\}$. I am looking for a function $f : N \to L$ with the following properties:
$f$ is efficiently computable
$f$ is a bijection
$f$ is pseudorandom (not necessarily cryptographically)
Given some interval $[a,b]$ and a regu... |
In the following MIT open course, it is claimed that min-cost circulation reduces to min-cost max-flow:
...
The second part of the proof is showing that min-cost circulation
reduces to min-cost max-flow.
Consider a network G for which we want to find a min-cost circulation.
Add a source s and a sink t to the netwo... |
I've been recently dealing with a problem which, when worst case is considered, results in exploration of $B_{n}$ options, where $B_{n}$ is th $n^{th}$ Bell number. I am trying to rigorously prove, that dealing with $B_{n}$ possible solutions results in exponential (or worse?) computational complexity (in terms of $n$)... |
I am studying cache coherence MESI protocol with "intervention" (cache can send to other cache without use the Main Memory).
On my notes I wrote that in case of a processor has a block in M (modified state) and read on the bus a Write operation done by an other Cpu, the processor sends the block directly to the cache t... |
I am trying to solve a problem- Longest repeated substring in a string. Firstly, I built a suffix tree that takes O(n) time and then I traversed the suffix tree to find the deepest internal node. I am not sure whether traversing in a suffix tree would be O(n) or not?
These are the properties of a suffix tree-
A suffix... |
I am currently studying the Erdos-Reyni model, the $G(n,p)$ model to be specific.
Its easy to understand that all graphs with $m$ edges have generating probability of $p^{m}(1-p)^{n(n-1)/2 - m}$ where p is the probability that there is an edge between a pair of vertices.
What I am not able to understand is the followin... |
(Pre-note: I'm learning Theory of Computation on my own, so bear with me if I'm saying something wrong/stupid.)
Why is $L := \{b^2a^nb^ma^3\mid m,n \geq 0\}$ a regular language?
This question appeared in a problem set, whose answer is the following:
The language is regular. Indeed, it can be expressed by the regular... |
I have a graph consisting of about 5000 vertices, with density around 0.5. I'm trying to find two disjoint 6-cliques, which are not connected by an edge. I have tried bruteforcing this, by firstly looking for any 6-cliques, and then checking pairs for being non-adjacent. However, although it finds a lot of 6-cliques it... |
I have a set of source bins, each with some number of items, and a set of target bins. I want to move all of the items from the source bins to the target bins, using the minimum number of moves. Each move can move any number of items from one source bin to one target bin.
The bins do not have the same size, but the t... |
I came across this classic question and found may many solution to it. for loop and DP/ reclusive + memorization.
Also found a twisted version of the questions asking to print all possible path instead of counting. Wondering for the twisted version, if we have DP solution ?
Q: If there are n stairs, you can either tak... |
There's a list of (unknown) integers, in [0...20]. They are generated from a uniform distribution via a RNG.
The input is observations of the form:
in a subrange [i,j) of the list, and some given threshold T in [0...20], how many sextuples exist (not necessarily of consecutive numbers) consisting of numbers that are l... |
I have implemented a branch and bound algoritm for finding a Hamiltonian cycle in my software, but I actually need to find a shortest route from fixed vertex through all verticies ending at any of them.
As far as I understood, I can reduce closed-cycle TSP to open-cycle with fixed starting point by adding dummy vertex... |
Max weighted independent set returns a set of nodes that form the maximum weighted independent set. K-independent set returns yes/no if the graph has a independent set of size k. How would you go about proving this?
|
so I have a problem on one of my computational structures final reviews, and I cannot seem to figure it out. It's been driving me crazy, so I would like to post it here for some insight.
Prove that the following CFG is ambiguous.
S-> begin A end
A-> A;A / a / S
Terminals: begin, end, ;, a.
Variables: S, A.
I cannot see... |
I have no detailed questions actually. My question is about a (maybe possible) generalization for reductions.
We defined reduction as following (If I translate a term false please correct me.):
$ L_1, L_2 \in \{0,1\}^* $ two languages.
One may reduce the language $L_1$ to $L_2$, if there is a total function:
$f: \{0,1\... |
In the Rabin Karp algorithm the rolling hash is calculated as follows:
H1= c1*a^k-1 + c2*a^k-2+c3*a^k-3+…+ck*a^0
where a is a constant. On what basis is this a selected? In Cormen they have used a value 10 and at some other places it is 26. By observation, when the string is of digits they have taken a = 10 and when t... |
The term abstraction as I understand it, is used in many different contexts, but has one essential meaning, namely that it refers to the “general properties of some class of objects that doesn’t rely on their details”. For example, abstraction in programming is e.g. interfaces that allow you to constrain a set of objec... |
Let G be a graph that forms a cycle on $n$ vertices, with non-negative weights on the edges.
Can you give each vertex v a vector $\mathbb{R}^m$ (for some $m\in \mathbb N^+$) such that the L1 distance (taxicab distance) between two vectors is the same as the distance between them in $G$?
Prove for a general circular g... |
The definition for SUTO and WUTO is the following:
Suto
If some process TODelivers some message m before message mʹ, then a process TODelivers mʹonly after it has TODelivered m.
And for WUTO
If process p and process q both TODdeliver messages m and mʹ, then p TODelivers m before mʹ if and only if q TODdelivers m bef... |
$n$ : length of text T
$m$ : length of pattern P
When I study Rabin-Karp algorithm, I learned the best case of this algorithm is $\theta(n-m+1)$. Because if a hashed number is too small to modulo by some other number.
But when I'm talking with my friends about this best complexity, I was very curios that does above ... |
I'm reading A Rendezvous of Logic, Complexity and Algebra, my first introduction to the world of CSP. Let $\Gamma$ be a finite constraint language. It says in Pg. 9 that
$Pol(\Gamma)$ is used to denote the set of all polymorphisms of $\Gamma$, that is,
$$Pol(Γ) = \{f : \forall R \in \Gamma, \textrm{ f is a polymorph... |
There is a problem that as much as I am trying to understand it, I fail. There are theoretically three cache manufacturers that each make 16 byte cache. The first has 16 blocks, 8 blocks the second, and 4 blocks the last. Then we are provided with 12 memory addresses, and we are asked the hit ratio of each cache. How d... |
We learned about the WISARD neural network in my machine learning course. We said that for an $n\times k$ image, we would use discriminators having $n$ RAM neurons each of $2^k$ bits. The examples we covered were always simplistic and involved small images, something like $3\times 4$.
I am looking at some past papers i... |
I’m trying to find an efficient algorithm for the following optimization problem:
Given a matrix $A$ with elements $a_{ij}$ and dimension $k$, select exactly $n$ elements from $A$ ($n<k$) such that the sum of the elements is maximized, subject to the constraint that any index of $a_{ij}$ is only used once. In other wor... |
I have a list of board members of all companies in the city. In the city lives three gangsters. Every company needs to have at least two gangsters among the friends of board members but every board member can know at most one gangster. Member can be a board member in multiple companies.
What is the name of this problem... |
The human brain as studied by neuroscientists, or neurobiologists, generally focus on what I would call
implementation details (how specifically does information transport between synaptic channels, i.e. what are the chemical processes)
vague generalities (e.g. about "memory" as a psychological concept and in very va... |
Is there any particular reason for picking a left-leaning red-black tree over a regular red-black tree when trying to do a purely functional implementation?
I've not researched very deeply into this subject matter but I see that Okasaki's implementation is left-leaning, and just as Yamamoto's.
Left-leaning red-black t... |
Recently i have found a problem stating:
There is a network of roads G=(V,E)(it is not directed) connecting a set of cities V. The length of each road e ∈ E is le. There is a proposal to add one new road to this network, and there is a list E′ of pairs of cities between which the new road can be built. Each such potent... |
I have some issue with how to simplify regular expression. I cannot find any suitable method to approach these types of problems.
How would one approach simplifying the following regular expression:
(01(11)* (10+0)+00+1)* 0(11)*
Thanks in advance,
Erik
|
The OpenAPI specification aims at standardizing the representation of REST based systems in json and yaml formats. A short version of the petstore is below:
{
"swagger": "2.0",
"info": {},
"host": "petstore.swagger.io",
"basePath": "/v2",
"tags": [],
"schemes": [
"http"
],
"paths": {},
"securityDefinitions"... |
Are thre any efficient algorithms for checking if a list of integers is pairwise coprime, or would a more general algorithm be the best option available?
|
Let $T$ be a Splay Tree. For a given permutation $\sigma$ on a set $S = \{1,2,3,...n \}$ we defined the following function:
Splay-Insert-Permutation(σ)
{
FOR i := 1 TO n DO
T.Tree-Insert(σ(i))
T.Splay(σ(i))
ENDFOR
}
We basically insert the elements of some permutation on $S$ one by one and perform splay after ... |
How to calculate the rate of growth of the below function $f(x)$?
$$
\begin{align*}
f(x) &= \begin{cases} f(x-1) + g(x) & \text{if } x > 1, \\ 1 & \text{if } x \leq 1. \end{cases} \\
g(x) &= \begin{cases} f(x-1) + g(x/2) & \text{if } x > 1, \\ 1 & \text{if } x \leq 1. \end{cases}
\end{align*}
$$
|
You are given an array with $N$ elements. The values of the elements may be any number in the interval $[0,10^9]$. Define $f(a,b)$ as the bitwise or of all the values in the subarray $[a,b]$. Find a bound on the number of distinct values of $f(a,b)$.
Attempts: I have tried to brute force cases to find a pattern but w... |
In the paper Deep Networks with Large Output Spaces, Vijayanarasimhan et al. describe their approach to approximating the dot product between a neural network's output layer's parameter vector and input activations with winner-take-all hashing. I'm trying to grasp the main idea described in the following paragraph:
Ou... |
I find a formula on my book to estimate cpu utilization under multi-processing.
$ U = 1 - P^n $
U: cpu utilization
P: cpu idle
I want to know why or how to proof.
Edit:
The book is about operating system, not in english.
This may be like https://stackoverflow.com/questions/20328619/calculate-cpu-utilization/20328695?no... |
One candidate key is (report_no, author_id).
What are the other candidate keys?
|
Given a graph $G = (V, E)$ with $V = U \uplus T$ (let's say the vertices are
labelled $U$ or $T$), I am looking for the smallest set $U' \subseteq U$ such
that $G[U' \cup T]$ is connected.
If we eleminate all the type-U nodes from the graph, the type-T nodes (terminals) might form several disconnected subgraphs.
That ... |
Topological sorting on a graph seems like an immensely powerful operation:
No matter whether the algorithm ends in success or failure, we obtain an important information about the topology of the graph, i.e. whether it is cyclic or not.
If it ends in failure, we can trivially find the cycle that let the algorithm end ... |
I have a matrix which represents the distances between every two relevant items. For example, M[i][j] holds the distance between items i and j. My next aim is to cluster items by these distances.
I can provide some parameters: maximal number of clusters, maximal distance between two items in a cluster and minimal numb... |
This question is doable if you can calculate the number by multiplying f(n-1) and f(n-2).
Is it possible to do this question if we entirely want to skip multiplying these 2 numbers and still be able to calculate say the number of trailing zeros in f(20).
Why do I want to skip multiplying these two numbers?
Because as... |
Given: A Square Matrix where each entry is an integer (either positive or negative). The magnitude of each integer entry is at most $m$ bits. The size of the Square matrix is $nXn$.
Objective: Reduce the Square Matrix to a Diagonal Matrix form using Gaussian Row Elimination.
Query: What is the most efficient algorithm ... |
I'm struggling with this problem: you are given an array $A$ of $n$ integers and a number $k \in \mathbb{N} : k \neq 0$. The problem asks to find an algorithm that runs in $\Theta(n)$ that returns the length of the longest subarray $A'$ in $A$ s. t. $\max(A')-\min(A') \leq k$.
For example, in the array $A = \{6, 5, 9, ... |
I'm looking for an online algorithm/datastructure that is able to maintain a pareto frontier for two dimensional elements in an online scenario where elements can be added and deleted.
For example:
insert((3,7))
since the pareto front is empty it has to be added to it
set of elements E={(3,7)}
pareto frontier P={(3,... |
given:
$$m_1+m_2+...+m_k=m$$
How can I find $\Theta(log(m_1)+...+log(m_k))$ as related to $m$?
I know that i can doing that: $O(log(m_1)+...log(m_k))=O(log(m)+...+log(m))=O(k \cdot log(m))$ , but can I find something without $k$ ?
|
Given a directed a-cyclic graph G (unweighted), give algorithm which count all the paths from node s to node t, and calculate the run time complexity.
so I thought about the naive way to do this :
1)hold a counter (counter=0 at beginning) and start from vertex 's', loop through all 's' neighbors.
2) if one of the ne... |
Let $L$ be the language generated by a context-free grammar whose start variable is $S$. Does adding $S \rightarrow SS$ in this grammar creating language $L^*$, why? What about grammars in Chomsky normal form?
|
Many important (non-deterministic) complexity classes like NP are believed not to be closed under complement. But have any of them been proven not to be?
I'm sure one could construct some contrived example, but is there any "natural" complexity class that has this property, by which I mean one that has been studied by ... |
This answer on another SE community discusses the concept of a "counting complexity class". As far as I can tell, the author is using that term in a slightly nonstandard way: most sources (PS format) use that term to refer to complexity class like #P of counting problems that count the accepting branches of a polynomia... |
I want to build a cellular automata that simulates a behaviour that looks like clouds, that is: infinite and random cycles, pieces can gather or break apart, just like the image below:
My question is: Is there any algorithm whose result looks like this cycle (or anything that can help me)?
I've been searching for a lon... |
I was reading an article on Water Jug Problem. The problem is -You are given a m litre jug and a n litre jug where 0 < m < n. Both the jugs are initially empty. The jugs don’t have markings to allow measuring smaller quantities. You have to use the jugs to measure d litres of water where d < n.
I solved the problem usi... |
I am interested in all know classes of Computatinal problems. The Wikipedia article on computational problems types is incomplete. Some of the known classes are:
1- Decision problem such as 3SAT
2- Search problem such Factoring search problem
3- Function problem such as finding a second Hamiltonian cycle on a cubic gra... |
I've read the definition for Rice's Theorem, here's the one from Wikipedia:
In computability theory, Rice's theorem states that all non-trivial,
semantic properties of programs are undecidable.
The classical proof for proving Rice's Theorem is on Wikipedia, which is similar to other sources.
However, I have a pr... |
The problem is - Given an undirected tree with some marked nodes in a set and a positive number K. We need to print the count of all such nodes which have distance from all marked nodes less than K.
My first approach-
I ran bfs on every from each marked node given in the set and takes the intersection of the respectiv... |
Have some code (written in C), need the equivalent notation for mathematics.
Is it possible using if-statements and sigma notation for this, and if so, how?
int res = 0;
for (int i=0; i < (N/2)+1; i=i+1)
if (N % pow(2, i) == 0) res = i;
I have gotten as far as:
$$ \sum _{i=0}^{{N\over2}+1}\:(N \mod 2^i )$$ (missing ... |
Suppose we have a term rewriting system $\mathcal{R} = (\Sigma, R)$ with signature $\Sigma$ and set of basic rewrite rules $R$. Suppose we also have a set $S$ of ground rewrite rules, i.e. rewrite rules where both terms are ground terms. For my specific application, we can also assume that the right-hand sides of all r... |
In CMU's HoTT course, lecture 1, which can be found here: https://scs.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0945cc7f-48b7-4803-81af-e7193a3f461d
At 33:52, Harper was giving parallel comparison between synthetic theories and analytic ones, and when he reached PL theory, he said Coq is analytic and said Coq onl... |
I was reading an article on Find the smallest binary digit multiple of given number. The problem is - We are given a decimal number N, we need to find the smallest multiple of N which is binary digit number.
There is an optimization done i.e. if a string with same mod value is previously occurred we won’t push this new... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.