instruction stringlengths 35 29.1k |
|---|
Let L1, L2 be regular languages. And let A1=〈Σ,Q,q0,1,F1), A2=〈Σ,P,p0,2,F2) be their DFA.
Prove that the following language is regular, by making an appropriate NFA for it:
3={11′22′…′ |12…∈1,1′2′…′ ∈2} (Meaning, the language of all words in which the letters on the even positions (starting from 0) form a word from L2 ... |
I am trying to prove that following decison variation of MaxSAT is both NP hard and co-NP hard.
$(\phi ,k) \in L$ iff an assignment of $\phi$ satisfies k clauses and no assignment satisfies more than k clauses.
I think we can show that NP hardness by reducing SAT to L by setting k=m (number of clauses). But I can't re... |
I have a Mixed-Integer Linear Programming question.
There's this game called Islanders. Pretty graphics, it's about maximizing your score building a small city in a confined island.
Here's a quick rundown of the rules:
There are various building types
Every building type has a different size
Every building type has a... |
Let's call the two languages in question (untyped lambda calculus with single or multiple prompt delimited continuations) L_delim and L_prompt.
Is it possible to express multi-prompt delimited continuations in terms of single-prompt delimited continuations
By express I mean the macro-expressible sense (to provide som... |
A Boolean function $F(X_1, X_2, X_3, X_4, X_5, X_6)$ of six
variables is defined as $F = 1$, when three or more input variables are at logic 1. otherwise 0.
How many essential prime implicants does F have?
How to visualize this problem. A Six Variable k-map is very difficult to manage. Any hints?
|
Suppose $H = \{h_1, ..., h_T\}$ be a family of pairwise independent hash functions mapping $\{0, 1\}^n$ to $\{0, 1\}^{n/2}$. Let $M = \frac{2^{n/4}}{10}$ and let $x_1, ..., x_M$ be any M distinct points in $\{0, 1\}^n$. If we choose $h$ randomly form $H$ and let $E$ be the event that $h(x_1), ..., h(x_M)$ are all disti... |
if I take the result of a 32bit hash function(the param is random string) and apply module N on the result - will the values be evenly distributed?
so if I have a histogram of values [0,N-1] will the histogram be evenly distributed ?
Thanks
|
I am considering the following algorithm for obtaining a cycle $C_k$ of fixed length $k$ in an undirected graph $G$. Assuming $G$ is in adjacency list form, say $r \in G$ is the root for a truncated DFS of $G$. In typical fashion, be sure to mark nodes which have been visited. Do not go beyond depth $k-1$. In this way,... |
My background is not CS so sorry for using improper term. But basically I want to check if a point on XY plane is "too close" to any other points, and do so with every points. In another words, if I draw a circle with radius R at every points, would any circle cross other circles on the plane.
I want to code this in Py... |
It is well known that
Random variable is a function from sample space of a random experiment to $\mathbb{R}$.
Consider the following sentences from deep learning book
Let $\{x^{(1)}, \cdots , x^{(m)}\}$ be a set of $m$ independent and
identically distributed data points. A point estimator or statistic is
any func... |
I want to detect whether a subset of a directional graph reachable from a given root has a cycle, and print some useful debug information about the cycle. It's not a problem if there's a cycle not reachable from a given root. The useful debug information does not need to be exact (i.e. it is not a problem if the progra... |
In the traditional weighted set cover problem, we aim at minimizing the sum of the weight of the selected sets. Is there any problem/literature that aim at minimizing the average weight of the selected sets (i.e., sum of the weight / number of sets selected)?
|
Let $S$ be a string of length $N$, consisting of digits 0 to 9.
For convenience, we assume $N$ to be a multiple of 3.
Then, we split $S$ into $N/3$ equal parts, each of length 3.
For each equal part, we count/enumerate all subsequences of all lengths up to 3.
Finally, we total up how many such subsequences are there a... |
I am used to implementing algorithms in imperative languages. Many of the algorithms I have implemented use hash maps, hash sets, mutable arrays, heaps, doubly linked lists, etc. I understand that some of the data types don't exist in functional languages. For example, it may be hard to implement hash data structures o... |
Is it true that every algorithm with runtime complexity of $T(n)=\Omega(n)$ satisfies that $T(n)=\Theta(f(n))$ for some convex function $f$?
All the examples that I could think of satisfy the above mentioned requirement. For example, all polynomials are convex on $\mathbb N_+$. Additionally, $n\log(n)$ is convex from $... |
Maybe this question is not very smart but I really wanna learn this thing. also, I need someone who is familiar with printing 42 problem and zero program problem.
This is the context:
Consider the problem of determining whether a number belongs to a set. This
problem is easy for the following sets:
The set of odd n... |
Can SUU->V or any functional dependency that contains two or more times each attribute be simplified to the same dependency with one attribute? So SUU->V becomes SU->V or STTT->Q becomes ST->Q ?
|
Does anyone know when the list data structure was mentioned in computer programming/algorithms? Who gave birth to this list concept?
|
I am working on a problem where I have to completely scan a large unordered log file which contains purchasing details of customers. The file structure is as follows:
customerId itemId cost
The customer could have purchased the same item more than once in a day and at different times so there will be multiple entrie... |
I'm solving a complexity question where I have:
$$ n!/2^n $$
The goal is to find an upper bound for this.
My idea is using the fact that:
$$ n! = O(n^n)$$
$$ n!/2^n = O((n/2)^n) = O(n^n)$$
But is a correct upper bound, and if so is it the tightest upper bound that can be found? I know that n! is asymptotically larger ... |
Define a sequential circuit model be a directed graph with each vertices being a boolean gate. The difference is that we allow cycles in the boolean circuit. Each cycle will determine a boolean equation.
For example, constructing a loop by connecting the input and output of a negation gate will yield the equation $x=\l... |
I am reading about dynamic programming and I understand the overlapping subproblem requirement but not sure why optimal substructure is explicitly stated. Are there problems that can be solved recursively that do not have an optimal substructure?
|
For classic Heapsort (in this example using a maxheap), only the root node is extracted (popped) at each iteration and the last element in the heap is swapped into its place and then the tree is "re-heapified". This to me seems somewhat inefficient. We have more knowledge from the maxheap, namely, that the root node ... |
Consider the field $GF(p)$, where $p$ is a prime number. If there is a function $f: GF_p \times GF_p \rightarrow GF_p$ which has an unknown degree $d$ polynomial, with $1 < d < p / 4$.
Although $f$ is unkonwn to us, there is an erroneous oracle $O$ satisfy the following property:
$\underset{(x,y)\in GF_p \times GF_p}{P... |
Is there a name for a value which may only be -1, 0 or 1?
Is there a name for a function which creates such a value from arbitrary numbers?
It would be implemented like this:
T Function( T value ) {
return ( value < 0 ) ? -1 : ( value > 0 ) ? 1 :0;
}
|
I'm new to minimax algorithm, but i understand it's entire concepts as it's easy, my biggest issue is understanding it's implementation to my chess game, no internet solution answers this question
black or white players comprises of several pieces, so what piece is the AI predicting moves for, as the player could move ... |
I'm kind of new to the theory of computation and I was working on this problem:
We say that a Turing machine $M$ uses $k$ squares of tape for an input string $w$ if and only if there exists a configuration $(q, u\underline{a}v)$ of $M$, such that starting with input $w$, $M$ yields $(q, u\underline{a}v)$ and $|uav| \g... |
Definitions of Turing machines are always explicit about the blank symbol not being part of the input alphabet.
I wonder what goes wrong when you would make it part of the input alphabet, because effectively the blank symbol already seems to be part of the input.
To explain that 'seems' in the last sentence, consider ... |
I am trying to find the regular expression that defines this DFA, I am finding this particular case difficult since it has multiple accepting states.
If I understand this DFA correctly, it recognises:
empty strings or strings with any number of b => b*
or
a followed by any number of b => ab*
or
aa followed by any numbe... |
I am having a difficult time understanding callee and caller-save registers. I get that caller-save registers are those which are needed after function call and hence caller saves them in caller prologue and restored in caller epilogue. Callee-save are those who are used by callee and are saved in callee prologue and r... |
I am currently creating my own compiled programming language, and I have come to a point where I would like to start working on the type system and introduce some type checking. Ideally I would like to introduce type inference.
Right now I'm using the Visitor pattern to traverse the AST produced by the parser. I starte... |
Why does Feistel encryption algorithm encode half block every time? What would happen if the entire block is encrypted in each step?
|
How do we place $8n$ objects on a square of size $n\times n$ in a form of grid such that no 4 of them form a rectangle with sides parallel to those of square? Each object occupies exactly one cell in the grid and two objects cannot occupy the same cell. We are given $n\geq 100$.
Example. The following can be a $7\times... |
Can we prove that the 3 coloring graph problem (where no two adjacent nodes have same color) is NP instead of NP-complete?
$$\mathrm{3COLOR} = \{\langle G \rangle \mid G \text{ is colorable with 3 colors}\}$$
|
How to implement v=(a==b) using Linear Programming?
$$
v=
\begin{cases}
True, a=b\\
False, a≠b\\
\end{cases}
$$
Until now I tried the big M-Method.
To show a≤b:
$$a-b+Mv≤M$$
$$-a+b-Mv≤-1$$
To show b≤a:
$$-a+b+Mv≤M$$
$$a-b-Mv≤-1$$
When they are equal everything is okay, but when a≠b it doesn't work.
|
The Wikipedia article mentions non-determinism in the context of dataflow architectures. Arthur Veen's paper mentions non-determinism when it elaborates on MERGE nodes as conditional constructs.
Are dataflow architectures non-deterministic in the sense of Non-Deterministic Turing Machine?
For any program which determin... |
I want to know exactly how many iterations it would take this algorithm to terminate. In other words, is there a closed-form solution for the number of iterations? (For my input values, it is always guaranteed to terminate.)
Let $x$, $y$, and $z$ be some positive integers.
The values of $x$, $y$, and $z$ are chosen suc... |
This is in relation to this post I made. I eventually solved this by the following approach:
Take the un-ordered file with all the purchasing data and use the UNIX sort utility to order the file on the customer identifier. Since the file can be 500 million lines (and grows over time) I used the -T option and directed ... |
I'm trying to find pairs in a complete, weighted graph, similar to the one below (weights not shown).
For each possible pair there is a weight and I would like to find pairs for including all vertices, maximizing the weight of those pairs.
Many of the algorithms for finding maximum matchings are only concerned with fi... |
Both randomized and normal binary search takes O(log n) time complexity but why does the randomized version exist? In other words what is the advantage of randomized binary search even if it has same time complexity like that of the original binary search ?
|
i am struggling for quite a while with this. trying to understand why the following function can be calculated in polynomial time(in regards to the input length)
defining a function from assignments of truth values to a set of booleans to 3CNF propositions:
the function gets an assignment of truth values to a set of n ... |
I have two questions concerning the paper Nearly linear-size holographic proofs. In the second paragraph of section 6, A Graph Coloring Problem, it is claimed that
Using standard packet-routing techniques [Lei92], we can find switching actions for each node that establish collision-free paths in the graph for each pac... |
For the following phrase structure grammar I want to construct the type of string that satisfy it, but I am not sure the way to go.
$$\begin{align*}
S &\to xTy \\
T &\to xTT \\
xTx &\to xx \end{align*}$$
The thing I am struggling with is that I can't seem to be able to reduce it fully to the alphabet ($x$ or $y$) and ... |
I've been given the following two families of hash functions:
H
and
G
Each family has three functions $\{0,1,2,3,4\} \to \{0,1,2\}$ that can be seen in the tables above. For each family I need to decide whether it's universal. I know that a family of hash functions $F$ is called universal if for every $x \neq y$, $\... |
Consider the following decision problem:
Given: Two (3CNF-)formulas $\varphi_1$, $\varphi_2$ on a shared set $X\cup Y$ of variables ($X$ and $Y$ disjoint).
Question: $\exists$ assignment $\tau_X$ on $X$ such that $\varphi_1$ is satisfiable and $\varphi_2$ is unsatisfiable?
(The "satisfiable" and "unsatisfiable" condi... |
A paper was published recently in Science where the authors minimized the following function:
$$E_{\text{Ising}}(s) = -\dfrac{1}{2} \Sigma_{i=1}^{N} \Sigma_{j=1}^{N} J_{i,j} s_i s_j,$$
where $s_i$ denotes the $i$th Ising spin, which takes a value of 1 or -1, $s = (s_1 s_2 \cdots s_N)$ is the vector representation of a... |
Consider a BDD implementation in which each bdd in the system has a unique positive integer identifying it (thanks to canonicity and as common implementation designs follow, by utilizing a hashmap). I was thinking of assigning a negative integer to a bdd in order to represent its negation. So say bdd id -3 will be bdd ... |
if there is a better stack exchange suited for this question please inform me.
say you have a thread that is constantly checking the state of a variable in 2 ms intervals
volatile int var = 0;
while(true){
if(var == 1)
break;
Sleep(2);
}
you have another thread thats overwriting this variable to 1 in an external ... |
I am writing a paper in which I want to refer to a group of algorithms. Some of these algorithms are of complexity O(NlogN), and some of the are more complex (e.g polynomial-time) and I want to refer to them all in one term. Is there any common term to use in such a situation?
linearithmic refers to O(NLOGN) algorithms... |
For the Mersenne Twister prng, wikipedia, I feel the period exponent should be the size of the MT array,
$32\cdot 624 = 19968$.
How come the exponent is 19937 instead?
|
In a lecture of Algorithms of Data Structures (based on Cormen et al.), we defined the master theorem like this:
Let $a \geq 1$ and $b \gt 1$ be constants, and let $T : \mathbb{N} \rightarrow \mathbb{R}$ where $T(n) = aT(\frac{n}{b}) + f(n)$, then
$ \\ T\in\left\{\begin{matrix}
\Theta(n^{\log_b{a}}), & \text{ if } f... |
I'm TA'ing a course and have trouble solving an exercise.
Let $X$ be a RV defined to be the number of trials required to collect at least one of each type of coupon (of which there are $n$). Then $E[X] = nH_n = n \ln(n) + O(n)$ and $\sigma^2_X = n^2 \sum_{i=1}^n \frac{1}{i^2} - nH_n$ with $\lim_{n \to \infty} \frac{\si... |
I am trying to analyze supply chains in a game and have come across this problem:
First, an informal description: I have producers and consumers. Each producer produces a certain amount of goods, each consumer requieres a certain amount of goods. Each producer is connected to some consumers (these connections have infi... |
Suppose we are given that checking if there is a Hamiltonian path in a graph is NP Complete (HP problem). I want to prove that given a graph, node x, and node y, checking if there is a Hamiltonian path between x and y is NP Hard (HPN problem). Here is my proof:
Define a conversion from HP to HPN as follows:
result = ... |
Suppose that we have the following maze (_ = open, + = blocked), and we can move left,right,up,down:
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ + _ _ _ _ _ _ _ +
+ _ + + _ + + _ + _ + + _ + + _ + _ + + _ + + _ +
+ _ + _ _ _ + _ + _ + _ _ _ + _ + _ + _ _ _ + _ +
+ _ + _ _ _ + _ + _... |
What would the worst case array look like if I decide to always take the element on the position $\frac{n}{2}$ as the pivot element?
I know that if I choose the left or rightmost element as pivot ,the worst case occurs if:
Array is already sorted in same order
Array is already sorted in reverse order
All elements are ... |
I've written a "quiz" that prompts the user for comparisons between two items of subjective value, and once the position of all of the items is determined, displays an ordered list from most valuable to least. The number of items is fixed. The current implementation can be seen at https://dfdx.us/core-values-quiz/.
W... |
Let's say I have two numbers a and b. I want to find the number of steps it takes to find the GCD by Euclidean Algorithm by a closed formula which includes parameter a and b.
If I go by this implementation , in how many steps will I reach gcd:
public static int gcd(int a, int b)
{
if (a == 0)
... |
If I have the following system, I am wondering how to calculate the number of valid strings it contains.
The system is something like this, which can have arbitrary variations.
Only consists of an alphabet $\Sigma$.
It can't spell any words in a blacklist word list $\rho$.
It can't have more than $n$ characters of the... |
I am interested in the complexity of the following problems:
(a) Finding an independent set of a fixed size in an arbitrary hypergraph
(b) Finding an independent set of maximum size in an arbitrary hypergraph
It is well known that the analogues of (a) and (b) (say (a') and (b')) for graphs are NP-complete and NP-har... |
Define a size $k$ matching in a hypergraph $H = (V,E)$ to be a collection of $k$ pairwise disjoint edges in $E$. Is anyone aware of the (best-known) time complexity of finding, for fixed $k$, a size $k$ matching in an arbitrary hypergraph? I can find plenty of references for the problem with respect to graphs, but not ... |
Why is $BPP^{NP}$ in the polynomial hierarchy?
I know that $BPP$ is contained in $NP^{NP}$, so $BPP$ is inside $PH$. Should I just simply reuse the proof of $BPP\subset NP^{NP}$, feed in each machine an oracle solving 3SAT problem, and show that $BPP^{NP}\subset NP^{NP^{NP}}$? Is it because normally, the proof in compl... |
I have a image like this:
I have code to extract the lines in the form [x1,x2,y1,y2]
Now i need to extract the internal rhombi, one could bruteforce combinations and check for intersections easily, but I was hoping a named, optimal algorithm existed, as the combinatoric explosion would ruin the server,
Any help appre... |
I have bumped into this problem while working on something model checking related and can't seem to find materials or efficient solutions for it. I couldn't even find a name for it.
We have a directed graph as our input, a starting vertex and two special vertices, the winning vertices for player A and B.
The vertices ... |
In pipeline simulator exercise, it says that:
Traversing the stages in backwards order simplifies the instruction flow through the pipeline.
Also, in gpgpu-sim source code, the stages are reversed (line 2442):
void shader_core_ctx::cycle()
{
m_stats->shader_cycles[m_sid]++;
writeback();
execute();
rea... |
I'm asking about the answer here:
Do the minimum spanning trees of a weighted graph have the same number of edges with a given weight?
I didn't understand the best answer here
Choose edge $e \in T_1 \mathop{\Delta} T_2$ with $w(e) = \min W$, that is $e$ is an edge that occurs in only one of the trees and has minimum d... |
Given an array of numbers, I would like to find an algorithm which divides them into two groups, such that the sum of the numbers in each group is as close as possible to half of the sum of all numbers, meaning I am looking for two groups whose sums are as similar as possible to each other.
As an example, given the arr... |
I've been trying to understand why, for instance, even though there are oracles $A$ for which $P^A \neq NP^A$, we still don't know if $P=NP$.
As I understand it, it's because it's easy to construct languages that can only be efficiently taken advantage of in a non-deterministic settings. For example, pick a single arbi... |
I am looking for the run time of the following pseudo code.
FunctionA(n)
a ← 2
b ← 2n²
while b>1
a ← a +1
c ← n
while c ≥ n
b ← b - a
a ← a/2
c ← 2n/c
So I think the inner while loop has a run time complexity which will be definde by the outer loop since c is allways 2 and because ... |
Suppose we are given a directed weighted graph $G=(V,E)$, a source vertex $s$ and the value of the cheapest path $\delta(s,v)$ for every $v \in V$.
I want to find an algorithm for the shortest path tree rooted in $s$ with time complexity of $O(V+E)$.
We may assume that all vertices are reachable from $s$.
I thought of... |
What is approximation factor for the Greedy Motif Search algorithm?
I couldn't find an answer to my question except for the fact that the algorithm has a unknown aproximation factor. I'm not a native speaker and there is almost nothing about it available in my first language which makes it really hard to even understan... |
I have two questions:
Does acyclic/cyclic classification only apply to directed graphs?
If not, does the following undirected graph have any cycle?
A --- B
|
I'm aware that the halting problem is solvable for PDAs, but I have recently discovered that I am wrong about how to actually do it. I used to think that you could detect an infinite loop by meeting these four conditions:
arrive at the same state as you were in previously
with the same top symbol as you had last tim... |
Suppose I have a simple polygon whose vertices are $p_1,\ldots,p_n$ each $p_i \in \mathbb{R}^2$. Suppose now I pick two distincts vertices $p_i,p_j, i\neq j$ Is there some algorithm I can use to test for intersections between the segment $\overline{p_i p_j}$ and some edge of the polygon?
You can assume an half edge dat... |
In my theoretical CS class, we learned about Interior Point Methods for convex optimization, but it seems that projected subgradient descent works equally well for constrained optimization. What are the benefits of using Interior Point Methods?
|
I'd like to know if there are good techniques for faithfully and (reasonably) representing rational numbers with forms similar to:
2/3
1/10
4 * 10 ^ 1,000,000,000,000
I know arbitrary precision rationals can be represented by pairs of arbitrary precision integers, and they can be normalized using gcd, so operations l... |
So you have a sheet / area of a given dimension, and within this area are holes (their center point(x,y) and radius are given). The problem is you need to cover these holes with patches. These circular patches have a fixed radius (ie: radius of 5) and are not allowed to overlap with each other (but can touch). You're a... |
There are multiple $O$-Notations, like $O(n)$ or $O(n^2)$ and so on. I was wondering, if there are variations of those in reality such as $O(2n^2)$ or $O(\log n^2)$, or if those are mathematically incorrect.
Or would it be a right thing to say that it is possible to improve a $O(5n^2)$ to a $O(3n^2)$? I can't and don't... |
I am looking at a combinatorial optimisation problem where I have N classes and k objects of each class.
Now I am looking for the optimal subset such that each of the N classes is represented exactly once. Not all objects can be combined with each other, e.g. object (N=1,k=1) might not be compatible with (N=2, k=4).
I ... |
As I understand it, quantum circuits as a model are equivalent to quantum Turing machines, or at least they can be simulated on each other.
So my question is, why have quantum circuits become the chosen implementation rather than quantum Turing machines, such as in the IBM Q?
Is it related to entanglement and reversibl... |
is it possible for the Dana Angluin's L* algorithm that a hypothesis is inconsistent?
So assume we have a closded observation table for a regular language L. Now after creating the hypothesis we will get a counterexample w.
The Question is: Can the counterexample w be chosen in the hypothesis, so that I have two times... |
In the below image, the graph is being triangulated (added edges are in red). My question is simple :
Is the red edge between nodes 7 and 10 necessary in order to obtain a chordal graph?
(this image comes from Yaroslav Bulatov's excellent answer on https://cstheory.stackexchange.com/questions/5018/the-origin-of-the-no... |
I was reading about maximum flow algorithms comparing the efficiency of the different ones. On the Wikipedia Ford-Fulkerson algorithm page, they present the Edmonds-Karp algorithm as the BFS (instead of DFS) variant of Ford-Fulkerson algorithm.
The point is on time complexity, Ford-Fulkerson algorithm has $O(|E||f_{max... |
I have a language that consists of instructions for movement on a 2D-plane. You start at coordinate [0,0]
The instructions
DOWN 1 UP 10 LEFT 5 RIGHT 1
means you will move to coordinate [9,-4].
There is also the REP command which means you perform the instructions inside the REP X times.
For example
REP 2 "DOWN 1 FOR... |
Python quite famously uses indentation to syntactically define blocks of code. (See Compound statements in the Python Language Reference). After years of using Python I'm still intrigued by and very fond of this syntax feature.
But I wonder: Apart from Python and its "predecessor"(*) language ABC which other programm... |
I was reading the article Integer multiplication in time O(n log n) by David Harvey and Joris Van Der Hoeven, 2019.
Could this discovery increase the throughput of future CPU's? If so could we determine by how much preemptively?
|
By token I mean the smallest element of source data, that the compression algorithm works on. It may be a bit (like in DMC), a letter (like in Huffman or PPM), a word, or variable-length string (like in LZ).
(Please feel free to correct me on this term, if I use it incorrectly.)
I'm thinking: what if we first find opt... |
Introduction
I have created an algorithm that generates n^2 x n^2 Sudoku Grids. Out of those grids I remove elements to give only one solution. The algorithm follows an infinite language based on circular matrix shift of elements. It does so in such a way that allows valid grids to be formed. Explained Here-1 and Here... |
I looked at Sipser ("Introduction to the Theory of Computation"), Problem 7.17:
Prove that if P = NP, then every language in P, except $\emptyset$ and
$\Sigma^*$, is NP-Complete.
The solution is as follows:
Let $A$ be any language in NP and let $B$ be another language not
equal to $\emptyset$ or $\Sigma^*$. Then... |
We have an infinitely planar cartesian coordinate system on which $N$ points are plotted. Cartesian coordinates of the point $i$ are represented by $(X_i,Y_i)$. Now we want to draw $(N−1)$ line segments which may have arbitrary lengths and the points may or may not lie on these lines. The slope of each line must be $1$... |
Let $f: \mathbb{N} \rightarrow \mathbb{N}$ a computable function such that computing $f(n)$ takes $\Omega(2^{2^{2^{|n|}}})$ time in worst case terms and such that the languages:
$$\begin{align*} L_1 &= \{ n \mid f(|n|) = n \} \\
L_2 &= \{ (n,k) \mid \text{the first digit of $n$ is the $k$'th digit of $f(|n|)$} \}\end{a... |
On a 2D plane there is a set of vertices V and segments S.
Each segment has 2 vertices, and each vertex knows segments that use it.
That creates a kind of a graph.
I would like to find all polygons as is depicted above. A polygon P is a set of n segments.
I tried BFS for each vertex with first cycle detection and dupl... |
I cleaned up my computer and found 50GB of old cache on it and it made me wonder, why do computers keep old cache files?
|
I need to show that the following problem is in P:
$$\begin{align*}\text{HALF-2-SAT} = \{ \langle \varphi \rangle \mid \, &\text{$\varphi$ is a 2-CNF formula and there exists an assignment} \\
& \text{that satisfies at least half of the clauses} \}\end{align*}$$
I know that 2-SAT is in P, hence it got a decider and I w... |
For example, given 4 fractions $\frac{4}{2}$, $\frac{2}{3}$, $\frac{1}{2}$, $\frac{10}{20}$, I have to select 3 fractions out of these 4 so that the value of $\frac{\text{numerator sum}}{\text{denominator sum}}$ is maximized. As in this case, selecting $\frac{4}{2}$, $\frac{2}{3}$, $\frac{1}{2}$ will result in $\frac{4... |
Is there any connection between the size of the largest independent set in a graph, and the minimum number of colors required to color the graph? I know that we can potentially color all the vertices in the largest independent set in the same color, but we know nothing about the rest of the vertices (besides being a ve... |
Let G b the following CFG (Where S is the start symbol):
S→aB|aDc
B→bBc|c
D→bc|c
(a) Show that G is ambiguous.
(b) Show that G is not an LR(1) grammar.
(c) Modify G into an equivalent grammar G′ that is LR(1). Explain why G′ is an LR(1) grammar and why G and G′ are equivalent.
My current answers:
(a) I showed that th... |
From here: https://www.geeksforgeeks.org/algorithms-np-complete-question-2/
Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial-time reducible to R. Which one of the following statements is true? (GATE CS 2006)
(A) R is NP-comp... |
Consider the following matrix:
Input:
The entire list of coordinates ranging from (0,0) to (4,4).
A list indicating certain coordinates which cannot be used to generate a path reached.
So,
each position on the grid is a node
nodes share an edge if exactly one coordinate differs by exactly 1
X nodes (and their associa... |
I have the following alphabet:
$Σ = {0, 1, . . . , 9}$
and the Language $L$ defined as:
$L = \{ abc | a + b = c\} $
where substrings $a$, $b$ and $c$ are interpreted as ordinary integers.
My answer so far:
Assume $L$ is context-free. Then the pumping lemma for context-free languages applies to $L$.
Let $n$ be the the c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.