instruction
stringlengths
0
29.8k
⌀
A finite automaton has no memory other than which state is a the current state. The strings in the language consist of some substring, then another substring, then the reverse of the first substring. One way to recognize this language would be to check whether the end of the string matches the start of the string, w...
### Some simple examples The language $\{(01)^{n^2}: n\ge0\}$ is nonregular, but its prefix language is $(\epsilon+0)(10)^*(\epsilon + 1)$. The language $\{0^n1^{n^2}: n\ge0\}$ is nonregular, but its prefix language is $0^*1^*$. Given a non-regular language $N$ such that $\mathit{pref}(N)$ is regular, we have ...
null
**Mathematical derivation of the loops:** We first observe that a reverse diagonal is such that the difference between the row index and column index is constant, $r-c=d$. So we will fix $d$ and try all $(r,c)=(c+d,c)$. Notice that $d$ can be negative. So from the definition of the domain of the array $0\le r,c<n...
To prove $L_1 \cup L_2 \subseteq L_1L_2$ you prove that $\forall x. (x\in L_1 \cup L_2) \rightarrow(x\in L_1L_2)$ &nbsp; To prove *that*, you prove that $\forall x. (x\in L_1) \rightarrow(x\in L_1L_2)$ and $\forall x. (x\in L_2) \rightarrow(x\in L_1L_2)$ Can you see where to go from there?
**Mathematical derivation of the loops:** We first observe that a reverse diagonal is such that the difference between the row index and column index is constant, $r-c=d$. So we will fix $d$ and try all $(r,c)=(c+d,c)$. Notice that $d$ can be negative. From the definition of the domain of the indexes $0\le r,c<n$...
### Some simple examples The language $\{(01)^{n^2}: n\ge0\}$ is nonregular, but its prefix language is $(\epsilon+0)(10)^*(\epsilon + 1)$. The language $\{0^n1^m: 0\le n\le m\}$ is nonregular, but its prefix language is $0^*1^*$. Given a non-regular language $N$ such that $\mathit{pref}(N)$ is regular, we hav...
**Mathematical derivation of the solution:** We first observe that a reverse diagonal is such that the difference between the row index and column index is constant, $r-c=d$. So we will fix $d$ and try all $(r,c)=(c+d,c)$. Notice that $d$ can be negative. From the definition of the domain of the indexes $0\le r,c...
No, there is no "false positive". ------ Let me to explain the meaning of "the even-odd rule" a bit. > The SVG defines the even–odd rule by saying: > > This rule determines the "insideness" of a point on the canvas by drawing a ray from that point to infinity in any direction and counting the number of path ...
Trying to solve the recurrence, but no clue how to deal with the (loglogn)^2 part
How to solve T(n)=2T(√n)+(loglogn)^2?
|recurrence-relation|recursion|master-theorem|
null
null
null
Fano's inequality says the following: > Theorem: Let $X$ be a random variable with range $M$. Let $\hat{X} = g(Y)$ be the predicted value of $X$ given some transmitted value $Y$, where $g$ is a deterministic function. Let $p_e$ be the probability of making a mistake, i.e., $p_e = Pr[ \hat{X} \ne X ]$. Then $p_e \ge \f...
Generalizing Fano's Inequality
|probability-theory|information-theory|
Fano's inequality says the following: > Theorem: Let $X$ be a random variable with range $M$. Let $\hat{X} = g(Y)$ be the predicted value of $X$ given some transmitted value $Y$, where $g$ is a deterministic function. Let $p_e$ be the probability of making a mistake, i.e., $p_e = Pr[ \hat{X} \ne X ]$. Then $p_e \ge \f...
Fano's inequality says the following: > Theorem: Let $X$ be a random variable with range $M$. Let $\hat{X} = g(Y)$ be the predicted value of $X$ given some transmitted value $Y$, where $g$ is a deterministic function. Let $p_e$ be the probability of making a mistake, i.e., $p_e = Pr[ \hat{X} \ne X ]$. Then $p_e \ge \f...
I'm interested in characterizing the complexity of a decision problem related to path planning. For instance, consider the following problem: *Given the current location and battery charge of an outdoor robot, does a trajectory exist such that the robot reaches a goal region without running out of energy?* [![enter im...
Reducing a known NP-hard problem to a custom 4D planning problem
|complexity-theory|np-hard|planning|robotics|
null
#### Several simple examples The language $\{(01)^{n^2}: n\ge0\}$ is nonregular, but its prefix language is $(\epsilon+0)(10)^*(\epsilon + 1)$. The language $\{0^n1^m: 0\le n\le m\}$ is nonregular, but its prefix language is $0^*1^*$. Given a non-regular language $N$ such that $\mathit{pref}(N)$ is regular, we...
I see no reason to expect this to be NP-complete. If you discretize the state space, it is solvable with dynamic programming (in fact, reachability analysis on the state space suffices).
I want to find the slope of the building with respect to the ground which means that I need to find how tilted is the building with respect to the ground through computer vision or any other techniques?
Computer Vision techniques to find the slope of the buildings with respect to the ground?
|neural-networks|computer-vision|
null
**Hint:** Assuming base $2$ logarithms, we can write $$\begin{align}T(65536)&=2T(256)+4^2\\&=4T(16)+2\cdot3^2+4^2\\&=8T(4)+4\cdot2^2+2\cdot3^2+4^2\\&=16T(2)+8\cdot1^2+4\cdot2^2+2\cdot3^2+4^2\end{align}$$ Hence, generalizing the pattern, you see the sum $$\sum_{k=1}^{\lg(\lg(n))}{k^22^{\lg(\lg(n))-k}}$$ appe...
**Hint:** Assuming base $2$ logarithms, we can write $$\begin{align}T(65536)&=2T(256)+4^2\\&=4T(16)+2\cdot3^2+4^2\\&=8T(4)+4\cdot2^2+2\cdot3^2+4^2\\&=16T(2)+8\cdot1^2+4\cdot2^2+2\cdot3^2+4^2\end{align}$$ Hence, generalizing the pattern, you see the sum $$\sum_{k=1}^{\lg(\lg(n))}{k^22^{\lg(\lg(n))-k}}=\lg(n)...
There is a relational schema :- person (id, name, phone no, address, email, position) so there will be the following functional dependencies FD1:id, phone no, email -> name, address, position FD2:id -> name, address, position, phone no, email FD3:phone no -> id, address, position, name, email...
Which normal form is it in and How can we change it to 3rd and BC normal form
|database-theory|normal-forms|
null
I was told that search algorithm such as IDA* or Beam Search with any inadmissible heuristic is not guaranteed to find a solution. Can someone explain why that is the case? I was thinking sure the solution may not be optimal as the agent is too pessimistic to try out a potentially optimal path, but as least it will try...
search with inadmissible heuristics
|search-algorithms|heuristics|
There is a counter that counts the number of items in the store. For every increase in item or item that has been inserted, the cost is a + kb where k is the number of digits that has been changed in the counter. For example, from 2999 to 3000 we have a + 4b as 4 digits has been changed and from 999 to 1000, we also ha...
Potential Method For Decimal Counter
|amortized-analysis|
There is a counter that counts the number of items in the store. For every increase in item or item that has been inserted, the cost is a + kb where k is the number of digits that has been changed in the counter. For example, from 2999 to 3000 we have a + 4b as 4 digits has been changed and from 999 to 1000, we also ha...
flag=true for x=1 to n do { for i=1 to n do { for j=1 to n do { if flag=true then { for m=1 to k do { for n=1 to k do { some statements.... taking constant time } ...
what will be the time complexity of the following procedure?
|algorithms|complexity-theory|time-complexity|
flag=true for x=1 to n do { for i=1 to n do { for j=1 to n do { if flag=true then { for m=1 to k do { for n=1 to k do { some statements.... taking constant time } ...
flag=true for x=1 to n do { for i=1 to n do { for j=1 to n do { if flag=true then { for m=1 to k do { for l=1 to k do { some statements.... taking constant time } ...
When flag is true, the body of the third for takes time `ak²+b`; otherwise it takes `c`. So the total running time is n²(ak²+b) + (n-1)n² + d = O(n³ + n²k²).
null
When flag is true, the body of the third for takes time `ak²+b`; otherwise it takes `c`. So the total running time is n²(ak²+b) + (n-1)n²c + d = O(n²k² + n³).
Let $n = \sum_{i=1}^\infty d_i 10^{i-1}$ with $d_i \in \{0, \dots, 9\}$ and define $\Phi(n) = \frac{b}{9}\sum_{i=1}^\infty d_i$. Consider now an increment from $n$ to $n+1$ and let $k \ge 1$ be the number of affected digits. Following this increment, $d_k$ becomes $d_{k}+1$ while all $d_i$ with $i<k$ change from $9$...
Let $n = \sum_{i=1}^\infty d_i 10^{i-1}$ with $d_i \in \{0, \dots, 9\}$ and define $\Phi(n) = \frac{b}{9}\sum_{i=1}^\infty d_i$. Consider now an increment from $n$ to $n+1$ and let $k \ge 1$ be the number of affected digits. Following this increment, $d_k$ becomes $d_{k}+1$ while all $d_i$ with $i<k$ change from $9$...
Let $n = \sum_{i=1}^\infty d_i 10^{i-1}$ with $d_i \in \{0, \dots, 9\}$ and define $\Phi(n) = \frac{b}{9}\sum_{i=1}^\infty d_i$. In other words, $\Phi(n)$ is the sum of the digits of $n$, scaled by a factor of $\frac{b}{9}$. Consider now an increment from $n$ to $n+1$ and let $k \ge 1$ be the number of affected digi...
#### Considering the runtime analysis (with the master theorem) of the function below $T(n) = 12T(\frac{n}{4}) + 2\sqrt{n} + log^4(n)$. <hr> As I could not figure out a way to get the equation in the form $T(n)=aT(\frac{n}{b}) + \theta(n^d)$, I aimed to get the equation in the form of $T(n)=aT(\frac{n}{b})+\the...
In the Master Theorem, if one term is smaller than another, can we drop it from the equation and use big O instead of theta?
|runtime-analysis|master-theorem|
Thousands of reviews over the last year have found no errors with this presentation. This has been completely rewritten today 2022-09-16 to address all of the objections from these thousands of reviews. void Px(ptr x) { int Halt_Status = Hx(x, x); if (Halt_Status) HERE: goto HERE...
Are the halting problem proofs refuted by software engineering in C?
I suspect you have missed that $\sqrt{n} = n^{1/2}$.
> **Halting problem:** In computability theory, the halting problem is the problem of > determining, from a description of an arbitrary computer program and > an input, whether the program will finish running, or continue to run > forever. https://en.wikipedia.org/wiki/Halting_problem **Can anyone point out any e...
Halting problem undecidability and infinitely nested simulation
**Are the halting problem proofs refuted by software engineering ?** Thousands of reviews over the last year have found no errors with this presentation. This has been completely rewritten today 2022-09-16 to address all of the objections from these thousands of reviews. void Px(ptr x) { int Ha...
For each customer, keep track of the most-expensive item they've ordered and the total cost of all other items they've ordered. This can be stored in a hashmap that is maintained in memory. Then you can scan through your log file sequentially, updating the in-memory hashmap at each step. This requires memory propo...
Grinding through leetcode, I came across the question of the number of binary tree topologies for n nodes. When looking up the best solutions, I saw the same line of code in each solution: ```C# numberOfTrees += numberOfLeftTrees * numberOfRightTrees; ``` Why is the number of left and right trees multiplied ...
Need math explaining calculation of number of binary tree topologies given n nodes
|algorithms|permutations|
This has been completely rewritten today 2022-09-16 to address all of the objections from thousands of reviews in the last 12 months. **Are the halting problem proofs refuted by software engineering ?** void Px(ptr x) { int Halt_Status = Hx(x, x); if (Halt_Status) HERE: goto HE...
The Total number of comparisons for the worst case in the "Brute-Force String Matching" algorithm is: `(n-m+1)` where `n = lenght of string` and where `m = length of pattern`, that all makes sense to me except I want to be SURE my understanding of the `+1` is correct. Let me set up an example first: `n = "four"` ...
Understanding how the total # of comparisons is derived for the worst case in the "Brute-Force String Matching" algorithm
|algorithms|algorithm-analysis|strings|matching|
null
There is a relational schema :- person (id, name, phone no, address, email, position) so there will be the following functional dependencies FD1:id, phone no, email -> name, address, position FD2:id -> name, address, position, phone no, email FD3:phone no -> id, address, position, name, email...
There is a relational schema :- person (id, name, phone no, address, email, position) so there will be the following functional dependencies FD1:id, phone no, email -> name, address, position FD2:id -> name, address, position, phone no, email FD3:phone no -> id, address, position, name, email...
null
Now we can see that [Church][1] [was associated with][2] the [Simply][3] Typed [Lambda Calculus][4]. Indeed, it seems he explained the Simply Typed Lambda Calculus in order to reduce misunderstanding about the Lambda Calculus. Now when John McCarthy created Lisp - he [based it on the Lambda Calculus][5]. This is by...
null
Consider an algorithm that is tasked with searching the array A. Let *n* be the size of the array, let *i* be a random number between 1 and *n*. If A[*i*] = k, we have a match. If A[*i*] != k, we pick a new random *i* which has not not been chosen previously. The algorithm terminates when we have established a match or...
Average runtime random search without replacement
|algorithm-analysis|runtime-analysis|
Consider an algorithm that is tasked with searching the array A. Let *n* be the size of the array, let *i* be a random number between 1 and *n*. Finally, *k* is the target object we are searching for. If A[*i*] = k, we have a match. If A[*i*] != k, we pick a new random *i* which has not not been chosen previously. The ...
I'm developing a functional programming language that offers Rank-n polymorphism. Like Haskell I don't want types to appear at the term level, but I have no idea to insert type abstraction and type application in a term. For example, identity function is defined like below in Haskell. id :: forall a. a -> a ...
How does GHC insert type abstraction/application under the RankNTypes extension
|lambda-calculus|type-theory|type-checking|haskell|
I'm developing a functional programming language that offers Rank-n polymorphism. Like Haskell I don't want types to appear at the term level, but I have no idea to insert type abstraction and type application in a term afterward. For example, identity function is defined like below in Haskell. id :: forall a...
**Hint:** If the key is present, the probability to find it at the first attempt is $p_1=\dfrac1n$. Then the probability to find it at the second attempt is $p_2=\dfrac{1-p_1}{n-1}$ (because the first attempt must have failed and there are $n-1$ equiprobable choices left). The probability to find it at the third att...
rici wrote a very good answer. I actually intended to write a comment but I write it as answer instead. I can think of only these reasons: first POSIX as mentioned before. Second a misunderstanding. Third, formal language theory could have influenced it. **For the first reason,** I think, the best way of implemen...
Consider an algorithm that is tasked with searching the array A. Let *n* be the size of the array, let *i* be a random number between 1 and *n*. Finally, *k* is the target object we are searching for. If A[*i*] = k, we have a match. If A[*i*] != k, we pick a new random *i*. The algorithm terminates when we have establi...
null
I'm newbie in algorithm time complexity. I had a function, <code>f(n) = 2n<sup>2</sup> - 4n</code>. I have to proof that <code>f(n) = O(n<sup>2</sup>)</code>. We can take it like this:<br/> f(n) = 2n<sup>2</sup> - 4n $\le$ 2n<sup>2</sup> + n<sup>2</sup> $\le$ <code>3n<sup>2</sup></code> What if I just omit ...
Can 0 be a tight upper bound of -4n?
|time-complexity|algorithm-analysis|asymptotics|big-o-notation|upper-bound|
Today in my algorithms class, my professor explained how in divide and conquer algorithms we do things in "parallel" although I felt it was not exactly in parallel. Then I remembered from OS the fork() system call that creates literally another child process and computes in parallel with the parent process. Can we comb...
Combining fork() and algorithms
|algorithms|time-complexity|algorithm-analysis|optimization|operating-systems|
Today in my algorithms class, my professor explained how in divide and conquer algorithms we do things in "parallel" although I felt it was not exactly in parallel. Then I remembered from OS the fork() system call that creates literally another child process and computes in parallel with the parent process. Can we comb...
I can't count the number of times I've seen questions on StackOverflow related to regular expressions where the problem was due to the programmer not understanding the impact of greedy quantifiers. Most recently, [Python regex issue — \[\S\s\]* vs \d*][1]. I wonder why regular expression quantifiers were defined to ...
Many divide-and-conquer algorithms are actually implemented sequentially, and the idea of working on each half "in parallel" is more to help with conceptual understanding than an actual implementation practice. That said: yes, you are quite right, often it is possible to implement these steps concurrently / in paral...
null
In the absence of a direct answer, here are some ideas. I would say this is essentially a [job scheduling][1] problem with multiple optimization criteria: - total completion time - resource utilization The mathematical discipline that studies such problems is [scheduling theory][2], a subdiscipline of [oper...