instruction
stringlengths
0
29.8k
⌀
Too long for a comment: If we call the number of calls for sorting an array with n items T(n), then T(1) = 1, and T(n) = T(n div 2) + T((n+1) div 2) + T(n-1) for n >= 2. Assume that $T(n) = n^{c_n \cdot \log_2 n}$ Calculating $c_n$ by computer shows that $c_n$ gets smaller until $c_n = 0.432840$ when n = 716,727; t...
Too long for a comment: If we call the number of calls for sorting an array with n items T(n), then T(1) = 1, and T(n) = T(n div 2) + T((n+1) div 2) + T(n-1) for n >= 2. Assume that $T(n) = n^{c_n \cdot \log_2 n}$. Calculating $c_n$ by computer shows that $c_n$ gets smaller until $c_n = 0.432840$ when n = 716,727; ...
null
Too long for a comment: If we call the number of calls for sorting an array with n items T(n), then T(1) = 1, and T(n) = T(n div 2) + T((n+1) div 2) + T(n-1) for n >= 2. Assume that $T(n) = n^{c_n \cdot \log_2 n}$. Calculating $c_n$ by computer shows that $c_n$ gets smaller until $c_n = 0.432840$ when n = 716,727; ...
Does someone know a proof for Camerinis Algorithm for finding a minimum bottleneck spanning tree? To my knowledge its the only algorithm that performs in linear time to solve this task but I cant find a correctness prove for that. https://stackoverflow.com/questions/22875799/how-to-compute-a-minimum-bottleneck-sp...
Is there a proof for camerinis algorithm for finding a minimum bottleneck spanning tree?
|algorithms|graphs|correctness-proof|
On page 77 (section 6.1) of *Types and Programming Languages* by Benjamin C. Pierce (1st and only edition thus far), there is the following quote regarding naming contexts and de Bruijn indices: > Γ = x ↦ 4, y ↦ 3, z ↦ 2, a ↦ 1, b ↦ 0 > > Then x (y z) would be represented as 4 (3 2), while λw. y w would be...
I have a doubt regarding relation between MTTF (Mean Time to Failure) and FIT (Failure in time). Is it FIT = 1/(MTTF1 + MTTF2 + ...) or FIT = 1/MTTF1 + 1/MTTF2 + ... ?
Relation between MTTF (Mean Time to Failure) and FIT (Failure in time) in computer architecture
|computer-architecture|
null
null
Prove That the Language $L_1 = \{0^i1^j0^k | i < j\ or\ i > k\}$ is not regular using the pumping lemma. I am not sure how to begin with this I ended up using the string: $0^p1^{p+1}0^{p+1}$ S = 00001111100000 It holds for the conditions because the first set of 0s is less than the set of 1s, and the ...
Pumping Lemma Applied to 3 Variables
|finite-automata|pumping-lemma|
Your idea works only if you are allowed to _pre-color_ vertices. That's not given in the problem statement, so a much simpler idea is to add _a single universal vertex_, i.e. a vertex $u$ that is neighbors with every vertex in the graph. Let this graph be $G'$, and the original graph $G = G' - u$. Now, if $G'$ is ...
You seem to misunderstand a bit how the Pumping lemma works. You're not free to choose the value of $p$ or how to divide the string, but need to show that there's *no* factorization for some $w \in L$ with $|w| \geq p$ and $p$ arbitrary that would satisfy the pumping lemma. The trick here is to find values of $i, j...
You seem to misunderstand a bit how the Pumping lemma works. You're not free to choose the value of $p$ or how to divide the string, but need to show that there's *no* factorization for some $w \in L$ with $|w| \geq p$ and $p$ arbitrary that would satisfy the pumping lemma. The trick here is to find values of $i, j...
You seem to misunderstand a bit how the Pumping lemma works. You're not free to choose the value of $p$ or how to divide the string, but need to show that there's *no* factorization for some $w \in L$ with $|w| \geq p$ and $p$ arbitrary that would satisfy the pumping lemma. The trick here is to find values of $i, j...
null
Let $\Phi$ be a k-CNF and $\Phi_{min}$ be a minimal CNF (one that contains smallest amount of literal occurences) that is equal to $\Phi$. Can $\Phi_{min}$ contain a clause of size $m > k$? What I have tried: Let's define the concept of partial assignment: an assignment that has free variables. Example: $x_1 =...
The simplest Reduction for 3-SAT to 1-in-3-SAT reduction is as follows: For each 3SAT clause: $x+y+z=1$ Introduce 4 new variables $\{a, b, c, d\}$ and replace original clause with below 3 clauses: 1. $R(x^-, a, b)=1$ 2. $R(y, b, c) =1$ 3. $R(z^-, c, d)=1$ In a similar vein is what is the generic way to co...
Optimally converting N-SAT to 1-in-SAT?
|complexity-theory|reductions|
Golang has this feature (named return values): ```go package main import "fmt" func f(a, b int) (c, e int) { c = a * b d = 3*c e = c + d return } func main() { fmt.Println(f(4, 5)) } ``` `c` and `e` are named return values of `f` function.
I have an object mesh. This is loaded into a physics simulator, which does a convex decomposition. Now I want to perform operations outside the simulator that require a mesh representation. I could use the original object mesh but in many cases the convex decomposition is quite rough (the difference between object mesh...
Algorithm for surface mesh of convex decomposition
|convex-hull|
I have an object mesh. This is loaded into a physics simulator, which does a convex decomposition. Now I want to perform operations outside the simulator that require a mesh representation. I could use the original object mesh but in many cases the convex decomposition is quite rough (the difference between object mesh...
null
Say we're back in the 1950s and our clunky computer has a $1$ kilobyte memory. $1$ kilobyte is $1024$ bytes, which is $8192$ bits. When we consider the entire available storage space, there are $2^{8192}$ states we can harness (each bit can be on or off), but in actuality we only utilize $1024$ size-$8$-bit states. In ...
Memory Question
|memory-management|
I've been working on proving that this language L = {x ∈ {a, b}∗ | na(x) < nb(x) < 2na(x)} is not Context Free. "na(x)" stands for "number of a's in the string x". I however can't find a string where all possible divisions of the string can be pumped out of the language. For example, I tried a^(p+1) b^(2p...
Proving that L = {x ∈ {a, b}∗ | na(x) < nb(x) < 2na(x)} is not a context free language
|formal-languages|context-free|pumping-lemma|
null
|computer-architecture|cpu-pipelines|c|assembly|mips|
null
How to prove that $L = \{{a^{n} b^{n} c^{j} | n,j \geq 0}\}$ is a CFL?
null
Consider a bipartite graph $G=(U, V, E)$. Each $v \in V$ represents a soccer team, and each $u \in U$ represents a mini-tournament which needs to be scheduled. Tournament $u$ is adjacent to team $v$ if $v$ plays in that tournament $u$. Each tournament uses a full day. If $u_i$ and $u_j$ share no common neighbor, the...
null
For an NFA with language: {w ∈ {0, 1}*: the length of w is odd but not a multiple of three}. How many states are required? This is the work I have come up with so far: q0: non-accepting state - because of even length q1: accepting state - because odd length and not multiple of 3 q2: non-accepting state - be...
For an NFA with langauge: {w ∈ {0, 1}*: the length of w is odd but not a multiple of three}. How many states are required?
null
Consider the alphabet $\Sigma = \{a,b\}$. For which languages does the [Myhill&ndash;Nerode equivalence relation][1] have exactly one class? From what I understand about equivalence classes, each state is considered a class. So would $\{ a^n : n>0\}$ be the one class? [1]: https://en.wikipedia.org/wiki/Myhil...
|regular-languages|finite-automata|
null
The language *is* context-free. Slightly different: https://cs.stackexchange.com/q/10928/4287 $\{ a^mb^n \mid m≤n≤2m \}$.
null
You are thinking about it wrong. 8192 bits can only store 8192 single bit items. Now, the number of **combinations** that the entire collection of 8192 bits can store is indeed 2 to the 8192.
Working on exercise 6.1.5 part 1 provided some clarity on the issue (at least I believe so). However, the solution provided in the appendix doesn't seem to get into the weeds (implementation details) enough to address this question. It seems that we can get around this by starting the de Bruijn indices for bound var...
I have a weighted undirected graph `G=(V,E,W)`, I want to find an independent set `S` of `V`, such that if we sort the vertices of `S` in increasing order of their weights, the cumulative sum of the weights is maximized. In other words, if we suppose without loose of generality that $S={v_1,...,v_h}$ are the vertices o...
Let $G$ be a graph and let $v$ be a vertex. Is there a polynomial algorithm for the following operation? **Operation.** Find all the **induced paths** in $G$ with first vertex $v$.
Find all the induced paths with a start vertex
|graphs|
In the CSES problem [Sliding Window Cost][1], given an array and an integer `k`, we are asked to compute the **minimum cost** for each sliding window of fixed size `k`. The minimum cost is defined as the cost of making all elements equal. Therefore, it can be expressed as the sum of differences between each value and t...
CSES Sliding Cost - why is this formula for updating the cost c?
|algorithms|sets|
CSES Sliding Cost - why is this formula for updating the cost correct?
{"Voters":[{"Id":755,"DisplayName":"D.W."}]}
I'm looking for an efficient algorithm to merge a list of overlapping intervals (each of which has data associated) into non-overlapping intervals. In case two or more intervals overlap, the _latter_ one wins (e.g. the later intervals shadow the earlier ones). In my case, the intervals actually come pre-sorted (by s...
Turning stacked overlapping intervals (with associated data) into non-overlapping intervals
|algorithms|intervals|
Suppose that instead of a stack, you had a single counter, $x$, that you could either increment or decrement, under the control of a non-deterministic finite-state machine. (Each transition of the finite-state machine either increments $x$, decrements $x$, or leaves it unchanged.) Can you think of how to recognize ...
null
The language *is* context-free. Slightly different: https://cs.stackexchange.com/q/10928/4287 $\{ a^mb^n \mid m≤n≤2m \}$. For strings where the symbols $a,b$ may be in any order, you might find inspiration in the language [$\{w∈\{a,b\}^∗:\#_a(w)=2\#_b(w)\}$][1]. [1]: https://cs.stackexchange.com/a/12901...
I run the Python code below. `x` and `y` differ in their 4th and 5th number, and `x` has larger values. The program correctly shows that there is a difference between the two sums, and the difference is not that small. I therefore expect that the sum for `y` is smaller than the sum for 'x'. However, it shows that `x` h...
A floating-point rounding problem
|floating-point|python|
null
One conceptually simple approach is to sort the intervals by which is latest. Then create an empty binary tree for the intervals you keep. Iterate through the intervals, from latest on to earliest, and for each interval, check if it overlaps any interval in the tree; if not, add it to the tree. If you use a self-bal...
The total number of Turing machines is the cardinality of the set of natural numbers. Now consider the following functions - f1(x) = x + 1 - f2(x) = x + 2 - f3(x) = x + 3 - and so on Since the total number of these functions is also the same as the cardinality of the set of natural numbers, each of these functio...
Are there some additions that a Turing machine cannot perform
|turing-machines|computability|
null
The cardinality of even natural numbers is the same as the cardinality of natural numbers. That does not mean that odd natural numbers do not exist.
null
I run the Python code below. `x` and `y` differ in their 4th and 5th number, and `x` has larger values. The program correctly shows that there is a difference between the two sums, and the difference is not that small. I therefore expect that the sum for `y` is smaller than the sum for 'x'. However, it shows that `x` h...
I run the Python code below. `x` and `y` differ in their 4th and 5th number, and `x` has larger values. The program correctly shows that there is a difference between the two sums, and the difference is not that small. I therefore expect that the sum for `y` is smaller than the sum for 'x'. However, it shows that `x` h...
Let $G$ be a graph and let $v$ be a vertex. Is there a polynomial algorithm for the following operation? **Operation.** Find all the **induced paths** in $G$ with first vertex $v$. ---------- **Background** This problem is the confusion I encountered while reading the article *[Induced paths in graphs ...
Let $G$ be a graph and let $v$ be a vertex. Is there a polynomial algorithm for the following operation? **Operation.** Find all the **induced paths** in $G$ with first vertex $v$. ---------- **Background** This problem is the confusion I encountered while reading the article *[Induced paths in graphs ...
|algorithms|graphs|algorithm-analysis|
Say we're back in the 1950s and our clunky computer has a $1$ kilobyte memory. $1$ kilobyte is $1024$ bytes, which is $8192$ bits. When we consider the entire available storage space, there are $2^{8192}$ states we can harness (each bit can be on or off), but in actuality we only utilize $1024$ size-$8$-bit states. In ...
My understanding why distributed transaction need synchronized clock is the following Assume NTP max drift is 250ms true time = 100ms node A local time = 100ms node B local time = 0ms the following transaction will run into conflicted sequence transactionA arrive nodeA at (true time 10...
How does waiting 7ms and atomic clock help GCP spanner create external consistency?
|computer-networks|concurrency|database-theory|databases|consistency-model|
I've only recently started learning about deterministic/nondeterministic finite automatas and languages and I'd like some clarification on common notation used to describe languages. A 0 or 1 raised to an nth power just means that 0 or 1 occurs n times, correct? For example: the language L = { 0^n | n ≥ 1 } U { 1^m 0^k...
Notation in NFA, DFA diagrams and language
|formal-languages|regular-languages|nondeterminism|
Are languages generated from a statically typed language statically typed? So say, generating Python from C++. *to generate a language from another language:* You write a *transpiler* in a static language $L_s$ so that it can produce the equivalent program in language $L_{sORd}$. --- Issues: - The st...
I tried to solve the exercise: > Proof that determining the existence of a Hamilton Path in a bipartite graph is NP-complete by making a bipartite graph from a general one (undirected) by inserting a vertex in the middle of every edge of the first (general) graph. This generates problems as suggested here: https:...
null
For a (usually finite) set $A$ the star denotes the [free monoid](https://en.wikipedia.org/wiki/Free_monoid) on $A$ where $$A^* = \{a_1a_2...a_k : k \geq 0 \land \forall i. a_i \in A\}$$ is the set of all finite sequences or strings of elements in $A$. So $$\{0, 1\}^* = \{\varepsilon, 0, 1, 00, 01, 10, 11, 00...
For a (usually finite) set $A$ the star denotes the [free monoid](https://en.wikipedia.org/wiki/Free_monoid) on $A$ where $$A^* = \{a_1a_2...a_k : k \geq 0 \land \forall i. a_i \in A\}$$ is the set of all finite sequences or strings of elements in $A$. So $$\{0, 1\}^* = \{\varepsilon, 0, 1, 00, 01, 10, 11, 00...
|polygons|convex-hull|
Are there existing SAT solver libraries that can count the number of solutions of a boolean formula? Can you give examples? I mean implementations more efficient than the naive approach, i.e. each time a solution is found, a new clause is added to prevent it to be found again.
SAT solvers for counting the number of solutions