instruction stringlengths 0 29.8k ⌀ |
|---|
|regular-expressions|strings|string-metrics| |
|complexity-theory|np-complete|approximation|p-vs-np| |
|graphs|combinatorics|check-my-proof| |
|terminology|data-mining|data-sets|statistics| |
|complexity-theory|reference-request|turing-machines|combinatorics| |
A homework assignment asks me to state the complexity in Big-O notation of the function
$$f(n) = 7n – 3n \log n + 100000 $$
I graphed this function and decreases all the way down to zero nearly its entire lifespan.
Therefore I concluded that the complexity is bounded by a constant and has the complexity $O(1)$.
... |
Asymptotics of a function that decreases as n increases |
|asymptotics| |
If you use suitable definitions, you'll find that your function is in
* $O(2^n)$,
* $O(n^4)$,
* $o(1)$ and
* $\Omega(-n^2)$,
among many others. It's likely that the question (implicitly) asks for sharper bounds; I'll leave that for you to figure out. |
null |
Suppose Palindrome[][] is an array and Palindrome(i,j) is a function which checks, whether substring from i to j is palindrome and returns 1 if is palindrome or returns infinity if is not palindrome, and you looking for smallest number of partitions, create it bottom up:
$$Palindrome[i][i] = 1.$$
$$\forall 0\le i ... |
For 1., trouble is that you don't *know* $f$; it could be any one of the functions in $\Theta(n^2)$. Therefore, applying the master theorem directly is not (immediately) possible.
So let's unfold $\Theta$! Let $f \in \Theta(n^2)$ arbitrary. We know by definition of $\Theta$ that there are $d_1, d_2, n_1, n_2 \in \ma... |
For $k$-bit inputs, this function works:
$\mathrm{hash}(n) = (n \mod 2^{\lceil\frac{k}{2}\rceil})\cdot 2^{\lceil\frac{k}{2}\rceil} + n \,\mathrm{div}\, 2^{\lceil\frac{k}{2}\rceil}$
This is reversible, in that $\mathrm{hash}(\mathrm{hash}(n)) = n$, and has non-sequential pairs $\{n,m\}, n < m$, where $\mathrm{hash... |
null |
We'll use the **max-flow min-cut theorem** to solve this.
Therefore we map each instance $(G,K,\{c_{1},\dots,c_{k}\})$ to the network $N:=(V(G) \stackrel{.}{\cup} \{C\},E(N),e,K,C)$, where $C$ is a new vertex not in $V(G)$ (our sink), $K$ is our source and $e$ denotes the edge capacities,
$$E(N) := \{(u,v)|\{u,v\... |
null |
null |
I'm stuck on the following question:
"Regular languages are precisely those accepted by finite automata. Given this fact, show that if the language $L$ is accepted by some finite automaton, then $L^{R}$ is also accepted by some finite; $L^{R}$ consists of all words of $L$ reversed." |
null |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$, $\exists L = NL$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
<hr/>
Long Version:
... |
Witness length independent \exists-Operator |
|complexity-theory| |
I've been looking into the math behind converting from any base to any base. This is more about confirming my results than anything. I found what seems to be my answer on mathforum.org but I'm still not sure if I have it right. I have the converting from a larger base to a smaller base down okay because it is simply t... |
The math behind converting from any base to any base without going through base 10? |
|logical-validity| |
I'll answer this, even thought the question is not well defined and would possibly be better suited for cross validated. But since it has some connection to information it's not totally off topic here.
Short version: **Now, we can't apply that to any data set**. Variance alone is not a good measure of information. P... |
I'm trying to understand the approach to constructing a PDA which accepts a language and a string
What if the language is { $a^i b^j c^k \mid i,j,k \geq0, i+2k = j$ } and the string is $a^3b^7c^2$ |
Constructing PDA to accept language { $a^i b^j c^k \mid i,j,k \geq0, i+2k = j$ } and string $a^3b^7c^2$ |
|pushdown-automata| |
I'm trying to understand the approach to constructing a PDA which accepts the language { $a^i b^j c^k \mid i,j,k \geq0, i+2k = j$ } |
Constructing PDA to accept language { $a^i b^j c^k \mid i,j,k \geq0, i+2k = j$ } |
I have an algorithm which basically given an array of n numbers, checks if there is any repeated numbers in the array, returns true if there is and false otherwise.
It uses a direct access table (hashing function h(x)=x), which makes the running time linear. (so it creates a new array, initializes all values to fals... |
how to get the expected running time of an algorithm |
|algorithms|algorithm-analysis|runtime-analysis| |
This seems a very basic question to me, so excuse me if I lecture you a bit. The most important point for you to learn here is that **a number is not its digit representation**. A number is an abstract mathematical object, whereas its digit representation is a concrete thing, namely a sequence of symbols on a paper (or... |
Usually you assume uniform distribution on inputs which share a certain parameter.
You could assume uniform distribution on e.g.
1. All inputs of length $n$, e.g. if your input looks like $w_1\#\dots\#w_k$, where $w_i\in\{0,1\}^*$.
1. All multisets (bags) of $n$ integers up to $k$
1. All $n$-tuples of integer... |
How to get the expected running time of an algorithm |
I have an algorithm which basically given an array of n numbers, checks if there is any repeated numbers in the array, returns true if there is and false otherwise.
It uses a direct access table (hashing function h(x)=x), which makes the running time linear. (so it creates a new array, initializes all values to fals... |
Hint: The PDA has three phases: an $a$ phase, a $b$ phase and a $c$ phase. Your goal in the $a$ phase is to "compute" $i$ by strong an appropriate load on the stack. Your goal in the $b$ phase is to compute $j-i$. Finally, your goal in the $c$ phase is to compare $j-i$ to $2k$. |
You don't need a witness at all. You can allow the Turing machine to make a non-deterministic "guess" at any time. A string is accepted iff there is a sequence of guesses that make the Turing machine accept it, otherwise it is rejected. |
null |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$, $\exists L = NL$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not ... |
Usually you assume uniform distribution on inputs which share a certain parameter.
You could assume uniform distribution on e.g.
1. All inputs of length $n$, e.g. if your input looks like $w_1\#\dots\#w_k$, where $w_i\in\{0,1\}^*$, $n=k-1+\sum_{i=1}^k|w_i|$.
1. All multisets (bags) of $n$ integers up to $k$
1... |
You can use *Fibonacci hashing*, namely
$\qquad h_F(k) = k \cdot \frac{\sqrt{5} - 1}{2} - \left\lfloor k \cdot \frac{\sqrt{5} - 1}{2} \right\rfloor$.
For $k=1,\dots,n$ you get $n$ pairwise-distinct numbers (about) evenly spread in $[0,1]$. By scaling to $[1..M]$ and rounding (down), you get about evenly spread ... |
I've been looking into the math behind converting from any base to any base. This is more about confirming my results than anything. I found what seems to be my answer on mathforum.org but I'm still not sure if I have it right. I have the converting from a larger base to a smaller base down okay because it is simply t... |
|algorithms|arithmetic|number-formats| |
I have an algorithm which, basically given an array of $n$ numbers, checks if there is any repeated numbers in the array, and returns true if there is and false otherwise.
It uses a direct access table (hashing function $h(x)=x$), which makes the running time linear. So it creates a new array, initializes all values... |
heres a very good online reference on FSMs & related theory, 75p, with many diagrams. has many applications after the middle theory section, and also in many exercises with sample applications eg p485:
[ch12. Finite-State Machines](http://www.cs.hmc.edu/~keller/cs60book/12%20Finite-State%20Machines.pdf) by Keller, H... |
heres a very good online reference on FSMs & related theory, 75p, with many diagrams. has many applications after the middle theory section, and also in many exercises with sample applications eg p485:
[ch12. Finite-State Machines](http://www.cs.hmc.edu/~keller/cs60book/12%20Finite-State%20Machines.pdf) by Keller, H... |
Here is the question:
Show that:
`L = {0m1n, m > 1, n > 1, n < m }` , where m & n are superscripts
is not regular.
I am not sure what superscripts mean in this situation? Does it mean something like this:
0^5 = 00000 or 1^7 = 1111111
P.S. How can I show superscripts in SO?? |
Formal Language Syntax |
|formal-languages|regular-languages|automata| |
You don't need a witness at all. You can allow the Turing machine to make a non-deterministic "guess" at any time. A string is accepted iff there is a sequence of guesses that make the Turing machine accept it, otherwise it is rejected.
Edit: If you want a definition which does not rely on the machine model, then it... |
Here is the question:
Show that $L = \{0^m1^n : m > 1, n > 1, n < m \}$ is not regular.
I am not sure what superscripts mean in this situation? Does it mean something like this:
$0^5 = 00000$ or $1^7 = 1111111$.
|
null |
One major application is modelling of systems. Essentially, simple software systems can be modeled as Finite State Machines. (By simple software, I mean languages that can be represented using regular expressions). There are many of such "simple" systems, vending machines are examples (as vzn indicated).
By finding ... |
Yes, `0^n` or $0^n$ denotes the string obtained by concatenating $n$ copies of the symbol $0$. |
Yes, superscripts mean exactly what you think they do. For your other question (how to use superscripts in SO), there are two ways: use html tags like sup, or use $...$ math. |
If I had a Dijkstra graph with the number shortest paths from Node A to O being 1
Would it be correct to say: **the equal number of shortest paths from A to O is 1 and not 0** because that node is included as an 'equal shortest path'. I am really confused.
I have a nice image to illustrate my question but i need... |
Dijkstra algorithm |
|algorithms|shortest-path| |
If I had a Dijkstra graph with the number shortest paths from Node A to O being 1
Would it be correct to say: **the equal number of shortest paths from A to O is 1 and not 0** because that node is included as an 'equal shortest path'. I am really confused.
I have a nice image to illustrate my question but i need... |
If I had a Dijkstra graph with the number shortest paths from Node A to O being 1
Would it be correct to say: **the equal number of shortest paths from A to O is 1 and not 0** because that node is included as an 'equal shortest path'. I am really confused.
Here is an image to illustrate my question:
![enter i... |
null |
If I had a Dijkstra graph with the number shortest paths from Node A to O being 1
Would it be correct to say: **the equal number of shortest paths from A to O is 1 and not 0** because that node is included as an 'equal shortest path'. I am really confused.
Here is an image to illustrate my question:
![enter i... |
Witness length independent $\exists$-Operator |
Hint: find a PDA for the language $\{a^kb^k:k\ge 0\}$ and apply it twice. |
There will be atleast one shortest path from source to destination. There can be multiple shortest paths from source to destination but Dijkstra will choose only one based on the nearest neighbors.
This will give you a good idea on how Dijkstra works:
http://optlab-server.sce.carleton.ca/POAnimations2007/Dijkstr... |
Depends on how you define "equal number of shortest paths".
If we change the graph so that Q -> O is 3, then we have two shortest paths from A to O, one via P and one via Q, both of distance 4.
Then there are 2 shortest paths with equal distances. This is what you mean by "equal number of shortest paths", correct... |
Your language is equivalent to the language $a^ib^ib^{2k}b^k$, and since concatenation is associative, this is equivalent to $(a^ib^i)(b^{2k}b^k)$.
A PDA for the first of these parts pushes an $a$ for each $a$ it sees and pops an $a$ when it sees a $b$. If the topmost stack symbol after this is $Z_0$, transition to ... |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not rely on any specif... |
Hint: find a PDA for the language $\{a^kb^k:k\ge 0\}$ and apply it twice.
The other approach is to find a grammar for the language and convert it to an equivalent PDA. Here is the grammar version:
$S \to AB \mid \epsilon$
$A \to aAb \mid ab$
$B \to bbBc \mid bbc$ |
null |
Your language is equivalent to the language $a^ib^ib^{2k}c^k$, and since concatenation is associative, this is equivalent to $(a^ib^i)(b^{2k}c^k)$.
A PDA for the first of these parts pushes an $a$ for each $a$ it sees and pops an $a$ when it sees a $b$. If the topmost stack symbol after this is $Z_0$, transition to ... |
I don't know much about yacc, bison, flex or lex and please correct me if I'm wrong but a programming language is also a turing machine and a Turing machine is defined as the tuple (Q, Γ, b, Σ, δ, q0, F) where Q, Γ, b ∈ Γ, Σ ⊆ Γ ∖ {b} as input, δ: Q × Γ → Q × Γ × {L, R, N} as transition function where L = number of ste... |
What is the exact relation between programming languages and turing machines? |
|turing-machines|programming-languages|compilers|sets|turing-completeness| |
|turing-machines|programming-languages| |
Given an undirected unweighted multigraph $G=(V,E)$ and $s,t \in V$ find an $st$-path $P$ s.t. the number of edges leaving $P$ (i.e. the edges with exaclty one endpoint in $P$ ) is minimized.
Does anybody have any idea how to solve this?
I first thought about replacing edges by two arcs and weight them according t... |
$st$-path with fewest leaving edges |
|algorithms|graphs| |
|turing-machines|formal-grammars|programming-languages| |
null |
I don't know much when it comes to computers,
But If I wanted to learn how to programm algorithms that perform symbolic calculations and other techniques used to solve or aid mathematical problems, and to be able to classify the efficiency of different types of algorithms in terms
of different factors, what sub... |
Studying advice |
|reference-request|soft-question| |
Let $\Theta$ and $o$ be defined as usual (Landau-notation).
For two equivalence classes defined by $\Theta$ we define
$$\Theta(f) <_o \Theta(g) :\Leftrightarrow f \in o(g)\qquad.$$
Let $$\mathbb{F}:= \{\Theta(f)|f:\mathbb{N}\rightarrow\mathbb{N}\}$$
**My question**:
Is $\langle \mathbb{F},<_o\rangle$ Dedekind-co... |
Is $\{\Theta(f)|f:\mathbb{N}\rightarrow\mathbb{N}\}$ Dedekind-complete? |
|landau-notation| |
True, all programming languages are believed to be equivalent to the Turing machine, see Church-Turing thesis. That does not mean that programming a Turing machine is a practical thing to do. Far from it. To do real programming better languages are developed. In fact those languages evolve over time, when we learn what... |
Maybe I'm misreading the question, but it sounds like there's some confusion in the comparison between Turing machines and programming languages.
The definition and method of defining a Turing machine constitute a programming language. Turing machines represent programs in that language.
Language syntax and seman... |
No and no. If you have a supposed function $f(n)$ as infimum, the function $f(n) / n$ is smaller; if $F(n)$ is a supposed supremum, $n F(n)$ is larger. |
I have a recurrence relation which is like the following:<p>
T(n) = 2T(n/2) + log<sub>2</sub> n
</p>
I am using recursion tree method to solve this. And at the end, i came up with the following equation:<p>
T(n)=(2log<sub>2</sub>n)(n-1)-(1*2 + 2*2<sup>2</sup> + ... + k*2<sup>k</sup>) where k=log<sub>2</sub>n.... |
Need help about solving a recurrence relation |
|algorithms|algorithm-analysis|recurrence-relation|recursion| |
I have a recurrence relation which is like the following:<p>
$T(n) = 2T(\frac{n}{2}) + \log_{2}n$
I am using recursion tree method to solve this. And at the end, i came up with the following equation:<p>
$T(n)=(2\log_{2}n)(n-1)-(1\times 2 + 2\times 2^{2} + \ldots + k\times2^{k})$ where $k=\log_{2}n$
I am tr... |
This question arises from my reading of ["Types and Programming Languages"][1] ([WoldCat][2]) by Benjamin C. Pierce.
For the small step operational semantic evaluation rules for the arithmetic expressions (NB) in Figure 3-2 on page 41, there is the rule
> $pred\;(succ\;nv_1)\rightarrow\;nv_1$
My understanding... |
How does one deduce small step operational semantics? |
|semantics|operational-semantics|small-step-semantics| |
Devising an operational semantics of a programming language requires ingenuity, just like engineering a new car does. Nevertheless, there are some principle and correctness criteria by which we can judge whether a given semantics is "good".
For example, a good operational semantics should make sure that "valid progr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.