instruction stringlengths 35 29.1k |
|---|
I was doing a practice question. As you can see below there is an Implication graph. To check whether the problem is satisfiable, I checked whether there were any 'bad loops'. To do so, for each literal/variable in the boolean formula, I see if there is a path from X --->-X and from -X---->X if both exist then a 'bad l... |
Let $L_1$ be the language over alphabet $\{0, 1\}$ defined by $L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$.
Give a regular expression that denotes $L_1$, and justify its correctness
Attempt
Believe this is asking for number of $01$'s in $x$ but $|x|$ must be an even number. Like $x = 0101$, $|x| = |0101| = 4 \mod 3 = 1$ woul... |
Part of something I'm working on (or rather begin working on) involves white box approaches to facial recognition. I previously worked on something for character recognition using scene segmentation and neural networks but for faces I'm trying to challenge myself by not using neural networks or other AI strategies.
Con... |
Let $L_1$ be the language over alphabet $\{0, 1\}$ defined by $L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$.
Using as few states as possible, give a DFSA that accepts $L_1$.
Also give an appropriate state invariant for your DFSA.
I have a regex for it and that is $1^*(00^*11^*00^*11^*00^*11^*)1^*$.
An example of accepted str... |
I've been reading up on programming languages to better my understanding with the textbook Essentials of Programming Languages (3e) - Friedman & Wand.
In a chapter regarding the states of languages (i.e. when we account for the effects that a computation may have rather than the immediately evaluated value), I've noti... |
An encryption algorithm with information-theoretic security is one which even with infinite amount of computation cannot be broken. That is, given only the ciphertext, no amount of computation can reduce your uncertainty about the plaintext.
Fully homomorphic encryption is, roughly, an encryption scheme where $\text{En... |
For an assignment I have to proof that for two given decidable languages A,B, A\B is decidable too.
My idea is as follows:
If B is empty or doesnt have elements in common with A, then A\B is decidable because A\B=A.
If B is not empty and intersects with A, A\B is just a smaller subset of A and therefore decidable.
I ha... |
I found that shell sort with the gaps of Fibonacci sequence has the lower bound complexity $\Omega(N \log N)$ in average cases.
I want to know the upper bound complexity in average cases, so I write
some of code to test it. It seems to be $O(N\log N)$ but how to prove it?
Here is the lower bound of average cases anal... |
By computable real I mean $x\in\mathbb{R}$ such that there is some computable total function $p_x$ that takes a natural number $n$ and returns a dyadic rational $r$ such that $|x-r|<2^{-n}$. I think this is probably equivalent to any other reasonable definition but I want to fix this to avoid ambiguity.
By a semi-decid... |
I came across this problem in an online judge: We are given a distance matrix consisting of $N$ rows and columns. The $i$th line of $j$th row is the distance between node $i$ and $j$ (not necessarily neighbors). The task is to find out if there exists a tree satisfying the given distance matrix or not. The only constra... |
I have a formal language that describes digit production like
<digit> ::= 0|1|2|...|9
and I need to intruduce fraction to write decimals like 3.14 and so on
What did I do:
<frac> ::= <digit><frac> | .<digit><frac> | <digit>
I feel that the .<digit><frac> part is wrong, as every time we go this production we can subst... |
Let us consider the class $\cal F$ of functions that contains
all constant functions
all projections
the successor function
the Ackermann function
as basic functions, and that is closed under composition and primitive recursion.
(If we remove the line with the Ackermann function from this definition, then
this is th... |
Given a graph G, how can I check that its diameter doesn't exceed log(n) (n is the number of vertices)- by using only O(log(n)) space? (adjacency matrix doesn't seems to help...)
|
I am trying to figure out if this language is decidable:
$$ \{ \langle M \rangle \mid \text{$M$ accepts all strings starting with 010}\}. $$
My intuition is that it is. Whatever string $w$ starts with 010 it accepts, and if it doesn't it rejects.
|
I have an educational assignment to make an VLSI floor-planning tool.
Can I use machine learning in some part of the algorithm? For example, I was reading the book Algorithms for VLSI Physical Design Automation by Naveed Sherwani, and here's a quote from there:
Initial estimate on the set of feasible
alternatives fo... |
There is question in one of my exercise but I couldn't prove or disprove anything about it.
This is language $L$ which is introduced with grammar:
$$S \to 0S1 | 1S0 | AA$$
$$A \to 0A | \lambda|A1$$
My explanation and work:
I know that we can prove with pumping lemma that a language is not regular.
I know that if $L_1 \... |
Would you say that the following problem is undecidable?
$$L_1 = \{\langle T \rangle \mid T \text { accepts 14 words}\}$$
My intuition says that this must be undecidable, and I want to try to reduce it from the emptiness problem for Turing Machines. If we can tell whether or not a TM accepts 14 words, then we should b... |
Note: my main experience with theorem provers is with Type theory based proof-assistant, rather than an actual automated theorem prover.
It is obvious why naive automated theorem proving is inefficient: just doing an uninformed search through proof-space (e.g. with breadth first search) runs into the problem that the n... |
I know that there exist type theory based proof-checker, and I know that there are logic/sequent-calculus based automated theorem provers.
But I haven’t heard of a type-theory based automated theorem prover (nor of a sequent-calculus based proof-checker). Does a type-theory based ATP exist? (And a sequent-calculus base... |
If P is a program that can be run in exponential time on a deterministic RAM. Can P always be run in polynomial time on a non-deterministic RAM?
|
I have a vague understanding what formal verification is about, a vague understanding of what the cutting edge is of type theory for programming languages, and a better understanding of formal proofs.
So far as I understand, the purpose of formal verification is to (1) specify a set of “desired properties” in the form ... |
While learning to prove undecidability of problems, I came across a statement that you can't reduce a recognizable language to a co-recognizable language and vice-versa to prove undecidability. Why is it so?
Eg: Halting problem of TMs can't be reduced to Emptiness problem of TM
$\qquad$ $H_{TM}$ = {$\langle M,x \rangle... |
$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^R = w, |w| = n \}$
Informally x is palindrome of length n
where $\Sigma = \{0,1\}$
I'm having a hard time understanding this could someone please explain.
For $n = 1$
$L_1 = (0+1)^*(0+1)^*$ (Why? What does this mean?)
$L_1^c = ?$ (What would the com... |
Sentence: From every reachable state it is possible to reach a state where $p$ is true.
How do you write this sentence as a CTL formula? So far I only dealt with CTL syntax and trees but maybe it will also be asked in a test how you convert a sentence to a CTL formula..
So I've read that $AX$ means all next.
Then $AXp$... |
İf Somebody wants to play perfect chess.I consider for finding solution to this problem,possible minimum data compression method which describes with 10 bit maximum possible data is in the range of 2^10.Then with some formula which can take input as next move in the chess,There should be some formula that can change al... |
I am interested in solving the following problem:
Given an undirected graph whose vertices are weighted, find a subset of vertices of minimal weight whose removal disconnects the graph.
Is there any known algorithm solving this problem?
Here is an attempt at a solution (in python), using network flow:
deg_G = nx.deg... |
Propositional extentionality in the lean theorem prover is stated as the following axiom:
axiom proptext {a b : Prop} : (a $\iff$ b) \to a = b
My confusion about this is as follows: Previously I’ve read (in “introduction to type theory” by Herman Geuvers) that one key property of type theory is that we don’t say that... |
It is well known that if some computing apparatus is Turing-complete, then the halting problem is undecidable for that computing apparatus. However, is it true that if the halting problem is undecidable for some computing apparatus, then it is Turing-complete?
|
In this formulation of quotient types in cubical type theory I was able to implement an eliminator and use that to implement basically curried function application. However, in all this, the only requirement on the factoring relation is that it is reflexive.
I find this surprising. I would have expected transitivity an... |
I am trying to implement a simple web search engine mechanism with using HITS algorithm. I understand how the algorithm work and produce hubs and authority values for each page. But how can I use this hubs and authorities values to sort web pages? Let's say I have 100 page, their urls, their contents and their hub and ... |
I'm studying Binary Search Trees (BST) and I would like to verify that my understanding of BSTs is correct.
For example, let S = [17, -10, 7, 19, 21, 23, -13, 31, 59].
Binary Search Tree for S, with S1 as root:
How many comparisons is needed to search this tree for the presence of each of the elements in I = {-13, 31}... |
Let $n\in\mathbb{Z}$ and $0\leq b\leq63$, $b\in\mathbb{N}$. Find the $b$-th bit for the number n on it's $64$ bit representation with sign.
and $T$ be the number of test cases.
This is my attempt:
#include <iostream>
#define f cin
#define g cout
using namespace std;
int T;
long long n;
int b;
int main()
{
f >> ... |
I'm trying to develop an Algorithm for Polygon Intersection. Where each polygon is an array of Points, where each Point has X and Y properties.
Algorithm limitations:
- Algorithm input: 2 Polygons.
- Algorithm output: Intersection Polygon.
- Polygons may be convex or concave (angle between 2 neighbor edges my be more ... |
I am learning about stream algorithms and am implementing Count-Min sketch data structure. I am also learning to approximately solve the HH problem with sublinear space complexity.
I want to know what are some of the basic applications of HH problem.
|
If I have two languages L1 and L2 that are pumpable, what is the minimum pumping length for the union of them?
Does it differ if either of them contains just one string like 001?
|
Chinese postman problem, but where the postman have to visit each vetex at least once.
Is there a name for this problem?
What is the ideal algorithm to solve this problem?
|
Let $q$ be a prime number and let $\mathbb{Z}_q = \left\{1,\dots,q-1\right\}$; I need to prove that the family $\mathcal{H} = \left\{h_s \colon \mathbb{Z}_q \rightarrow \mathbb{Z}_q\right\}_{s \in \mathbb{Z}_q^3}$ is 3-wise independent, where $h_s$ is defined as:
$$h_s(x):=h_{s_0,s_1,s_2}(x):=s_0 + s_1 x + s_2 x^2 \bmo... |
Let $L_{n} = \{x \in \Sigma^* | x = ywz, w^R = w, |w| \geq n, |y| = |z| \}$
Generate a cfg of $L_n$
For n = 1, 2, 3
Informally, x is in $L_n$ means
some palindrome of at least length n is a substring of x that occurs
exactly at the midpoint of x.
for $n = 1$
$S \to 0S0 | 1S1 | 0S1 | 1S0|0 | 1 | 00 | 11$
for $n... |
Let's say I have a Las Vegas algorithm $L$ for some problem $P$, which runs in $n^3$ steps with 50% likelihood. My friend asks me for an algorithm for $P$ that runs in $n^3$ steps with 75% likelihood. My intuition says, "No problem! I'll just run $L$ once, and if it doesn't return after $n^3$ steps, I'll terminate it. ... |
Proving that L is not regular by showing that $\equiv_L$ has infinite index.
$\Sigma$ = {a}, L = {$a^{3^n} : n \geq$ 0}
My ideas:
theorem of Myhill-Nerode: L $\in$REG $\Leftrightarrow$ $\equiv_L$ has finite index
We show: $\equiv_L$ has infinte equivalence classes.
$a^{3^i}$ $\not\equiv$ $a^{3^{i+k}}$, $k>0$
-> equival... |
I try to design a LL(1) grammar to parse the basic regular expression. Here's the origin grammar.(\| is the escape character, since | is a special character in grammar's pattern).
E -> E \| T | T
T -> TF | F
F -> P* | P
P -> (E) | i
To remove the left recursive, import new Variable
E -> TE'
E' -> \| TE' | ε
T -> FT'
T... |
Usually formal grammars have production rules in the format N=tNt where simple concatenation function is used for the expansion of the nonterminal. https://www.grammaticalframework.org/ has concrete grammars (e.g. FoodEng https://www.grammaticalframework.org/doc/tutorial/gf-tutorial.html#toc19 grammar) with more genera... |
I am looking at the following implementation of Quicksort that uses Hoare partition scheme (two approaching indices $i$ and $j$ starting from either end of the array).
I am having trouble seeing why in the inner while-loops, the condition $i \leq j$ is needed in addition to checking $M[i] \leq p$ (or $M[i] > p$).
What... |
The convolutional layers are most computationally intense parts of Convolutional neural networks (CNNs).Currently the common approach to impement
convolutional layers is to expand the image into a column matrix(im2col) and perform and perform Multiple Channel Multiple Kernel (MCMK) convolution
using an existing parall... |
I'm plotting the fitness histogram of my particle swarm optimizer - i.e. the individual fitness scores for each particle and iteration - during a run.
The problem tackled is basically curve fitting/predicting time series data.
In some runs I'm seeing a rugged landscape with no tendency towards a stabilization of fitnes... |
How to balance this AVL tree after inserting node 5, using left/right rotations as indicated in the AVL tree tutorial. I have tried applying both double rotations but with no luck. Either of the double rotations still ends up producing a tree with imbalance as indicated above.
Do you mean the below solution?
|
I am learning hash tables, and I would like to know how to determine the average length of the linked lists.
For example: A hash table holds about 10,000 employee records. Each record is indexed by the 2-character initials of the employee name, transformed into integers using the mapping: A=01, B=02, C=03, and Z=26. On... |
I am looking for the name of an algorithm category, or even specific algorithms, that solve the following problem.
I have noisy data. For simplicity, let this data be represented by numbers. I have the full data set in RAM. In this noisy data, I want to find signal. Signal is an interval of contiguous numbers that ... |
How to check if a given point lies inside or outside a polygon with holes?
Does the below algorithm works for polygon with holes?
https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/
|
Hello i am studying about LZW algorithm by watching this video:
https://www.youtube.com/watch?v=j2HSd3HCpDs&t=481s
I couldnt fully understand decoding process.
At current 258,how does 116 come at add to dictionary part ?
At current 256,how does 101 come at add to dictionary part ?
|
Are there any known problems in $UP \cap co-UP$ other than integer factorization and parity games (or a problem that can be reduced in polynomial time to either problem), that aren't known to be in $P$?
|
I have a basic understanding how operators work (bitwise, logical, unary, ternary, etc.), but I am confused how you define what the operator does so the machine knows how to treat the operator when you use it in your code base. Are operators predefined by the compiler and is there a way for me to access the source code... |
In Aurora and Barak, they give the following alternative definition of $BPP$:
What is the meaning of the subscript to $Pr$? Is that $Pr_{r \in_R \{0,1\}^{p(|x|)}}$? My guess is this is supposed to represent $poly(|x|)$ many coin toss results, but what is $R$? And why is this a subscript to $Pr$?
|
I am trying to write a Turing machine enumerator that enumerates the language where $w = 0^n1^n$ and $n ≥ 0$.
So for example it should output the following to the first tape:
e,#,0,1,#,0,0,1,1,#,0,0,0,1,1,1 etc.
Here e means empty, i.e., to leave that index blank.
I can't figure out how to display this as a Turing mach... |
I have the following optimalization problem. I use the notations below because maybe it would be easier to understand that way, but I'm not good at conventions – I'm not sure if I'm using it all the right way – so feel free to correct me on this.
We have multiple tasks, $T_1,…, T_n$. Each of them has exactly one type (... |
For a while, all classification tasks in natural language processing were based on simple RNN's, which operate in a very word-by-word order. Adding gating mechanisms increased ability to "look back", and the newer addition of context vectors which can train attention to different words during the task have made classi... |
It's well known that depth-first search order of a graph is (usually) not unique, and multiple orders are possible depending on the order in which successors are processed for each node. Let's consider rooted directed graphs in the following discussion.
Muchnick 1997 gives an example:
.
Intuitively, DFS with (more) for... |
I saw the following animation at making sense of PCA
, which shows blue data points.
I am reading a paper on Eigenfaces which says that:
"a typical image of size 256 by 256 becomes a vector of dimension
65536 or equivalently a point in 65536 dimensional space"
The paper is available at the following link:
Eigenface... |
I have this NPDA for language L = {w: num_a(w) == num_b(w)}
all loops in q1
a, $ -> 0$ b, $ -> 1$
a, 0 -> 00 b, 1 -> 11
a, 1 -> \lambda b, 0 -> \lambda
------>q1-----------------\lambda, $ -> $------>q2
initial state: q1
final state: q2
What if I modified L such that the number of a's is not ... |
$B = \{w \in \{0,1\}^* | w^R = w, w \text{ length is odd} \}$
Solution:
For example: $111$ should be accepted
steps are
$q_1 \to q_2$ stack: [$\$$]
$q_2 \to q_2$ stack: $[\$, 1, 1]$ (using up $11$ only having a single $1$ left)
$q_2 \to q_3$ stack: $[\$, 1, 1]$ (no change except we lost our final $1$)
$q_3 \to$ (no st... |
So I have the following function:
def lcm(a,b):
x = a
y = b
while x != y:
if x < y:
x += a
else:
y += b
return x
I'm not sure how I will go about finding the loop invariant of this question. I know I have to find some sort of relationship between $x$ and $y$ but n... |
I have the following question and its solution
Here T -> XTX
since T -> X and X->b
S ->XbX
since X->a
S->aba
So,why is option 3 not accepted ?
|
What will happen if we change the DES encryrption algorithm to use the same key in each round ?
How will it affect the encryption - will it only make the encryption same as decryption or are the more effects ? I couldn't find any other possible effects in the DES standard description.
Thanks
|
I had already been given the answer by the TA in class, but I don't understand it. I'm not asking for the answer on a homework problem or anything.
The problem:
The Hamming distance ("distance") of a word w to v of the same size is the number of positions wherein they differ. The distance between a w and L is the small... |
In the following graph, we can traverse entire graph if we select the nodes 0 and 2. I am looking for an efficient algorithm which returns this two nodes. Note that this is neither vertex-cover problem nor dominating-set problem since we don't need to select node 3. We say that, if we select node 0, we can go to node 1... |
I'm working on an algorithm that takes a number of unit coins ([1, 2, 5, 10] for example) and a certain amount of money (13 in this case), and figures out how many ways there are to provide change for it. In the case of this testset the solution is 16.
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,... |
Let $A$ be an event divided into 4 events $A_i$ with the same probability. Why does the quantity of information of $A_i$ satisfy
$$ I(A_i) = I(A) + \log (4)?$$
|
I am having difficulty understanding the distinction between NP and Co-NP.
According to my textbook (Sipser), the HAMPATH problem is in NP. That is, for the language: HAMPATH = { (G,s,t) | G is a directed graph with a Hamiltonian path from s to t}, there exists a nondeterministic Turing Machine M that can decide this p... |
I am following this algorithm example: https://en.wikipedia.org/wiki/Christofides_algorithm#example
The graph:
Calculate minimum spanning tree T:
Calculate the set of vertices O with odd degree in T.
They are the same as "the minimum spanning tree T" as the degree of all vertices are odd.
Form the subgraph of G using... |
Is there anyway to express a Product Buchi game as a parity game? There is no stochasticity in my original turn-based game and a Deterministic Buchi Automaton is constructed for LTL specifications.
|
For a given MAXSAT problem, it is trivially easy to compute the mean number of clauses satisfied for all assignments, or equivalently the expected number of clauses satisfied by a random assignment.
Is it likewise possible to compute the variance of the number of clauses satisfied? And I mean an exact computation, not ... |
I'm not sure if reusing variable is allowed in CNF.
For example, I have this grammar not in CNF. So I have to convert it to CNF.
1. S->abAB|abB|abA|ab
2. A->bAa|ba
3. B->BAa|bAa|ba|Ba|Aa|a
For conversion, I'm using a convention where new variables and terminals are in the form
(V1,V2,V3,...,Vk) for k > 0
Ti where... |
First Let's take a look at the convolution $\displaystyle C _ { i } = \sum _ { j \oplus k = i } A _ { j } * B _ { k }$, and the $\oplus$represents any boolean operation. And we are able to evaluate $C$ in $O(n \log n)$ time, using an algorithm called Fast Walsh Transform, where $n$ represents the length of the binary d... |
I was reading Elad Hazan's book on Online Convex Optimization(http://ocobook.cs.princeton.edu/OCObook.pdf) and am facing difficulty understanding the proof given for the No regret algorithm for MAB (Pg 102-103). It would be great if someone can provide a clarification on this.
The No-regret (sub-linear) algorithm is g... |
I'm going through a tutorial that is using the Game of Life as example code. It has a function in it that finds the neighbor of a given cell. It is explained quickly that "When applying a delta of -1, we add self.height - 1 and let the modulo do its thing, rather than attempting to subtract 1" which would require a bun... |
I am doing some exercises on dynamic programming in order to get familar with this concept.
I've noticed that most of the time it's not difficult to calculate the complexity of a program using dynamic programming since most of the time we are recursively calculating a function $f$.
Let's suppose this function $f$ has ... |
Having two bit strings $x,y \in \left\{0,1\right\}^n$, where $x$ is selected following a uniform distribution but $y$ is not.
Is $z = x \oplus y$ uniform?
|
The Problem:
Given 3 inputs Bounce, Ball drop height, and ball view height.
How do I calculate the number of times the observer can see the ball pass.
So my code gives correct output, but it takes a longer time as bounce approaches 1, how do I make it deterministic in nature.
def bouncingBall(h, bounce, window):
... |
I would like to select an appropriate number of buckets in my hash table for this scenario:
A hash table with collision resolved is required to hold about 10000 records. Each record is to be indexed by the 2-character initials of the customer's name, transformed into integers using the mapping: A=01, B=02,..., Z=26. It... |
I was given a question that is stated that;
Suppose you’re consulting for a bank that’s concerned about fraud
detection, and they come to you with the following problem. They have
a collection of n bank cards that they’ve confiscated, suspecting them
of being used in fraud. Each bank card is a small plastic obje... |
I want to be able to recognise handwritten math numbers using images of the numbers , i was able to do create a ANN model for recognising simple decimal numbers , but i have no idea on how to recognise fractional number.
What kind of ML model do i need to recognise fractional numbers (p/q forms). As i am relatively n... |
Recently while solving programming challenges for the fun of it, I encountered a challenge which left me kind of puzzled and yearning for a proper solution, other than brute forcing. The problem (stated in my own words) is as follows:
In each testcase you are given N (6 <= N <= 10) sticks.
Each stick has length L (1 <... |
In the common model of FSA, the automaton reads the input string once, moving from one state to another after reading each letter in the input string. Epsilon transitions allow moving from one state to another without reading a character. However, the movement over the input string is still unidirectional.
Is there a ... |
A friend of mine and I are trying to teach a bot play a card game (bela)
We are using monte carlo tree search (MCTS) to estimate the probability of winning hand in regards to multiple possible (!important) card configurations.
We are randomizing both plays and possible card configurations. The problem is not all card c... |
Prove/disprove that the class of decidable (resp. partially decidable) languages is closed under symmetric difference. A symmetric difference of sets A and B is the set (A \ B) ∪ (B \ A).
I know that the class of decidable languages is closed under symmetric difference, because it is closed under union, complement and ... |
Having two deterministic functions $G_1, G_2 : \left\{0,1\right\}^\lambda \rightarrow \left\{0,1\right\}^{\lambda+l}$, at least one of which is a secure PRG.
Being $\alpha$ a constant, is it possible to build a secure PRG $G' : \left\{0,1\right\}^{\alpha\lambda} \rightarrow \left\{0,1\right\}^{\alpha(\lambda+l)}$ using... |
The title may be a bit confusing but the problem is this;
Lets assume I have 5 points in 4 groups (in total 20 points). What I want to achieve is;
-> Pick one point from each group (we will have 4 points at the end)
whose pairwise distance is larger than a threshold and
sum of pairwise distances is maximized.
For rea... |
Here is an approximation algorithm that finds vertex cover of a graph.
C = {}
E' = {Edge set}
while E' =/ 0
Let (u,v) be an arbitrarily edge of E'
C = C U {u,v}
remove E' incident on u and v.
return C
A variant: what if instead of removing edges incident on both $u$ and $v$, we removed only $u$. Would th... |
Can addition (or subtraction) of polynomials of degree $< n$ be done in constant time ?
I am quite new to algorithms. I thought about using sorted arrays for storing the coefficients. But the addition of two sorted arrays appears to be $\in O(n)$. However, I am not convinced that this is the best solution. Could some... |
I'm exploring algorithms to compress small strings like the following - every line is to be compressed individually, i.e. even those small strings should get compressed:
ZYXH1|104932,104932,927.6000,200,1,927.4000,1600,1
ZYXH1|104932,104932,3390,1600,1,3389,2700,1
HXDFF|0001739.42;HXDFF:Y|0U010:49:32
ZYXH1|104932,10493... |
Assume the language:
$$L=\left\{w\in\{0,1\}^*\,| \text{ w has odd length and 111 right in the middle}\right\}$$
This is my attempt for constructing a grammar $G$ for this language:
$$G: S \rightarrow A111B,\, A \rightarrow 01B |10B|00B|11B,\, B \rightarrow 01A |10A|00A|11A$$
This process adds random even strings of $\... |
I was recently helping a friend with homework from a dynamic programming class, and this was the question:
Given a set of
n
precincts
P1
,...
Pn
, each containing
m
votes, with n being even. We
want to divide each precinct into two districts, each consisting of
$\frac{n}{2}$ of the precincts. For each precinct, we k... |
I got the following from a web site:
The feature vectors represent each image as a linear combination of
the eigenfaces defined by the coefficients in the feature vector; if
we multiply each eigenface by its corresponding coefficient and then
sum these weighted eigenfaces together, we can roughly reconstruct the... |
The problem is:
Suppose you're given $n$ points in the coordinate plane, and for convenience assume that no two of their $x$ or $y$ coordinates are the same. Design an algorithm that finds the shortest possible distance between a pair of these points. What is the time complexity of your algorithm?
Ofcourse there is a... |
Lemma 4 in How easy is local search by Johnson, Papadimitriou, and Yannakakis, states:
If a PLS problem is NP-hard then NP = P
So assuming L is a PLS problem (polynomial local search problem) that is NP-hard, then every NP problem can be reduced to L.
Usually if $P_1$ is reducible to $P_2$ (being two decision proble... |
Given is the following recurrence relation:
$T(n)=n^2+T(\frac{n}{2})+T(\frac{n}{4})+T(\frac{n}{8})+...+T(\frac{n}{2^k})$
where $k$ is some constant and $n = 2^t$ for some $t\in \mathbb{Z}$.
I'm trying to find an asymptotic bound for $T(n)$.
My work so far:
First, I've tried to guess and prove by induction.
Then, I tri... |
I am confused regarding Binary Search Trees (BST) when an element does not exist in the tree.
For example, to search for element "6", would it take 5 comparisons to search for this element?
My understanding is:
Compare root (Not found - move left)
Compare left node (Not found - move left)
Compare left node (Not found... |
How can I show that $\{a^ib^jc^k|i=0 \lor j=k\}$ is not regular?
I tried applying the pumping lemma but it does seem to have a pumping length of 1?
Alternatively there is the Myhill–Nerode theorem.
Are $\{a^ib^j|i=0 \lor j\in\mathbb{N}\}$ infinite many equivalence classes?
|
I have a problem (A) on undirected graphs that I wish to show is NP-Hard. I can show that there is a reduction from a well known NP-Hard problem (B) to A by constructing an instance of A with a complete graph that solves B.
Since undirected graphs generalize complete graphs, am I safe in saying that A is NP-Hard for u... |
The title should explain my question thoroughly enough. I can't seem to get started anywhere. Intuitively it seems like some kind of brute-forcing would work i.e if the DFA has the symbols $\Sigma$ you would simply be passing strings from $\Sigma^*$ until the DFA rejects. What would even be the time complexity of this ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.