instruction
stringlengths
0
29.8k
⌀
Assume a tower with $n$ floors. Each floor contains $C_i$ boxes such that $C_i>0$ for all $i\le n $ Moving $C_i$ boxes from floor $i$ to floor $j$ where $i>j$ costs $C_i\cdot(i-j)$ and we can only move all the boxes at once,and they all go to the same floor.(the boxes can only be moved downstairs) Given $C_i$ fo...
They are different. A walk is any sequence of vertices where every two consecutive vertices are connected via an edge. A trail is a walk where every edge is visited at most once. A circuit is a trail that starts and ends on the same vertex. A path is a trail where no vertex is visited twice and a cycle is a path that s...
Assume a tower with $n$ floors. Each floor contains $C_i$ boxes such that $C_i>0$ for all $i\le n $ Moving $C_i$ boxes from floor $i$ to floor $j$ where $i>j$ costs $C_i\cdot(i-j)$ and we can only move all the boxes at once,and they all go to the same floor.(the boxes can only be moved downstairs) Given $C_i$ fo...
I read a paper about [Parallel Matching][1], and I didn't understand what the in the following lemma/proof and how does it works in vertices and edges in the graph? Lemma 3. Using our graph representation, each node v in the graph can apply an associative operator ⊕ to all edges incident on v in O(log|A|) time and...
What is the associative operator ⊕ in graph matching? and How does it works?
|parallel-computing|matching|
I read a paper about [Parallel Matching][1], and I didn't understand what the associative operator ⊕ in the following lemma/proof and how does it works in vertices and edges in the graph? Lemma 3. Using our graph representation, each node v in the graph can apply an associative operator ⊕ to all edges incident on ...
The idea is that if you have any [associative operator](https://en.wikipedia.org/wiki/Associative_property) at all, then you can use the lemma to apply it to all edges incident on $v$. There are many possibilities for operators that are associative, including sum, min, max, and many more. You can use the lemma with...
null
null
null
null
Represent the string $x$ using the following encoding: $$0, x_k, \dots, 0, x_2, 0, x_1, 1, x_0$$ where $x_0 = x$, $x_{i+1} = \text{len}(x_i)$ is a binary representation of the length of $x_i$ in bits (namely, $\text{len}(x_i)=\lceil \lg x_i \rceil$, for $i\ge 1$), and $k$ is the smallest $k\ge 1$ such that $x_k \...
null
The difficulty of solving many hard problems using dynamic programming is to create/imagine/formulate/select the subproblems with the right number of dimensions/parameters. While the subproblems cannot be too many to include all dimensions of the problem that we are basically applying brute force, they cannot be too...
Assume a tower with $n$ floors. Each floor contains $C_i$ boxes such that $C_i>0$ for all $1\le i\le n $ Moving $C_i$ boxes from floor $i$ to floor $j$ where $i>j$ costs $C_i\cdot(i-j)$ and we can only move all the boxes at once, and they all go to the same floor. (The boxes can only be moved downstairs) Given $...
I am recently studying The Operation System, I am confused about how symlink work even after watching some YouTube videos, hope there's someone can help me out with some questions. According to wiki, symlink is pointing to the name of the file but not the inode, if the computer wants to access /opt/be which is a symlin...
How does symlink work?
|operating-systems|filesystems|
null
Because of Kolmogorov/Levin complexity considerations, most $N$-long bit strings require $N+\log N+o(\log N)$ bits to store, since we also need to specify where the sequence ends; see D.W.'s answer for the details. I wonder what is the most efficient way something like this can be realized on a *real* computer. What i...
In terms of $n$, $$\binom nk=\frac{n(n-1)\cdots(n-k+1)}{k!}$$ is indeed a polynomial in $n$ of degree $k$ (and not of degree $\min(k,n-k)$). In terms of $k$ (and constant $n$), there is no asymptotic expression as $k\le n$ is required. If both parameters are variable, the expression is complicated: $$\Theta\le...
Your problem is NP-hard, by reduction from the [equal-cardinality partition problem](https://en.wikipedia.org/wiki/Partition_problem). Let $a_1,\dots,a_n$ be an instance of the equal-cardinality partition problem (so $n$ is even). The reduction works as follows. Choose a sufficiently large constant $C$. Define $b...
Just to add to the previous answer, you can get $O(1)$ amortized bound for find, insert, and delete with some limitations with soft-heap [[wiki](https://en.wikipedia.org/wiki/Soft_heap), [original paper](http://www.cs.cmu.edu/afs/cs/academic/class/15859-f05/www/documents/p1012-chazelle.pdf), [simplified implementation]...
Just to add to the previous answer, you can get $O(1)$ amortized bound for find, insert, and delete with some limitations with soft-heap [[wiki](https://en.wikipedia.org/wiki/Soft_heap), [original paper](http://www.cs.cmu.edu/afs/cs/academic/class/15859-f05/www/documents/p1012-chazelle.pdf), [simplified implementation]...
I'm trying to write a program that generates a Tectonic/Seguru puzzle, and I'm struggling to find an algorithm that can generate them [The rules of the puzzle are here][1], but basically, it involves a grid that's divided into components, and the goal is to fill the grid with numbers according to these 2 rules : -...
Searching an algorithm to generate Tectonic/Seguru puzzle
|algorithms|
I am wondering whether every Euler graph is also traversable. I.e. are Euler circuits Euler paths, too? Therefore I am asking the question above. I am explicitly asking "euler circuit ⇒ euler trail?".
The runtime to find a max element in max heap is $O(1)$. It takes $O(\log n)$ time to delete an element and $O(\log n)$ time to insert a new element in the heap. Does there exists a data structure in which max element can be found in $o(\log n)$ and still the time to delete is $o(\log n)$ and $o(\log n)$ time to ins...
One way that puzzles *like* this (not necessarily *exactly* this) are often generated is to use a solver to test candidate solutions. We'll assume that you generate a polyomino tessellation first, and I'll assume that this isn't a challenge for you. The real difficulty is adding just enough clues to give the puzzle ...
The difficulty of solving many hard problems using dynamic programming is to create/imagine/formulate/decide/select the subproblems with the right number of dimensions/parameters. While the subproblems cannot be too many to include all dimensions of the problem that we are basically applying brute force, they cannot...
null
null
The difficulty of solving many hard problems using dynamic programming is to create/imagine/formulate/decide/select the subproblems with the right number of dimensions/parameters. While the subproblems cannot be too many to include all dimensions of the problem that we are basically applying brute force, they cannot...
*TL;DR: Floyd-Warshall algorithm seems to also accept "is-a" and "has-a" relationships as edge weights. I want to know exactly why this is fine, and how to generalize this notion of other unusual weights.* I also considered to ask this question on Mathematics Stack Exchange since it also contains significant portion...
Shortest path algorithm on graphs with non-numerical weights
|algorithms|shortest-path|weighted-graphs|
|algorithms|
null
You can achieve N+2log<sub>2</sub>N with a simple algorithm: 1. Write down the binary string. 2. Prefix it with its length. 3. Prefix that with as many zeros as the length is long. With this encoding, a 20 bit string is encoded as: > 00000 10100 XXXXXXXXXXXXXXXXXXXX Do decode it, count the number of leadi...
Because of Kolmogorov/Levin complexity considerations, most $N$-long bit strings require $N+\log N+o(\log N)$ bits to store, since we also need to specify where the sequence ends; see D.W.'s answer for the details. I wonder what is the most efficient way something like this can be realized on a *real* computer. What...
null
I found in <a href="https://cs.stackexchange.com/a/6136/155747">this</a> answer that if a problem is shown to be NP but not NP-complete then P$\neq$NP. What is the argument to prove this statement?
Why does showing that a NP problem is not NP-complete implies P$\neq$NP
|complexity-theory|np-complete|np|p-vs-np|
Why does showing that a NP problem is not NP-complete implies P$\neq$NP?
#### Show $L_U \le_m S$ Let $v=\langle T, w\rangle$, where $T$ is a Turing machine and $w$ is an input string to $T$. Fix two different input symbols $a$ and $b$. Construct Turing machine $M_v$ that upon input $x$, check whether $x$ is $aww^Rb$. - If it is, accept. - Otherwise, check whether $x$ is $bww^Ra$...
This statement is false. It is already known that the empty problem and the universal problem are in $\mathsf{NP}$ and are not $\mathsf{NP}$-complete (not even $\mathsf{P}$-complete). However, what is true is that if $A\in \mathsf{NP}$ is not one of the two problems above, then $A$ is $\mathsf{P}$-hard. To prove ...
To make the question better defined, we must specify the initial countable set $A$ of natural numbers, so that the specification can be used as input for our computer. Thus we assume that there is a program $E$ that lists the elements of $A$ one by one, not necessarily in order. Thus $A$ is *recursively enumerable*. ...
null
*TL;DR: Floyd-Warshall algorithm seems to also accept "is-a" and "has-a" relationships as edge weights. I want to know exactly why this is fine, and how to generalize this notion of other unusual weights.* I also considered to ask this question on Mathematics Stack Exchange since it also contains significant portion...
I'm not an expert on this, so I recommend you double-check my conclusions, but I believe you can compute all-pairs shortest paths using a generalization of the Floyd Warshall algorithm, for any objects and operators that form a closed [semiring](https://en.wikipedia.org/wiki/Semiring) (also known as a [star semiring](h...
**Update.** Since my original question was misunderstood by many, and lead to a lot of debate about various issues, let me try to pose this modified and rephrased question: > Assume that I have a computer with a giant disk that can store $2^{1000}$ bits. Is it possible for any $N<2^{999}$ to write a code in Python f...
null
null
This question is about the Halting Problem on a TM with finite space. The Halting Problem is obviously decidable on those TMs. So my question now is how efficient we can decide it. My intuition is, that there is now better way than brute force. Because, if we have a better algorithm than that (for an arbitrary T...
Efficiency of Halting Problem on finite space TMs
|time-complexity|turing-machines|halting-problem|
Let $G$ be an abelian group. We say that $G$ has property $V_n$ if for every $m > n$ and a list $L\subset G$ of $m$ elements s.t. $\sum_{g\in L}g=0$ there is a proper subset $\emptyset\neq L'\subsetneq L$ s.t. $\sum_{g\in L'}g=0$. We define $V(G)=\min\{n \mid G \text{ has property }V_n\}$. This is part of the problem ...
Finding all zero sums of length m and checking for zero subsums on an abelian group (generalization of the sub sum problem?)
|algorithms|discrete-mathematics|python|subset-sum|group-theory|
when we move the mouse we can see the cursor is Moving on the monitor.I know that mouse can send signals according to its movements. Which component of a computer is recieving those signals in the first place.Is this whole process is happening only between device controllers and device drivers? Is there any involvement...
How is the mouse sending signals to the computer?
|computer-architecture|operating-systems|memory-hardware|
To where is the mouse sending signals of a computer?
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells. The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in N : n \lt k\...
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells. The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in N : n \lt k\...
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells. The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in N : n \lt k\...
This question is about the (Edit: universal) Halting Problem on a TM with finite space. The Halting Problem is obviously decidable on those TMs. So my question now is how efficient we can decide it. My intuition is, that there is now better way than brute force. Because, if we have a better algorithm than that (...
How many ways can we insert elements { 1, 2, 3, .... 7 } to make an AVL tree so that it does not have any rotation? I broke it down into 2 cases: Case 1: height of tree = 2, (a complete binary tree) only 1 structure possible. case 2: height of tree = 3, there will be 16 structures possible. there will not be ...
Number of ways to insert elements into an AVL tree such that there are no rotations
|data-structures|combinatorics|avl-trees|
I have a square matrix (call it $A$) of size $n$ ($n$ is a positive integer). Each column is a permutation of $[1:n]$. I take the first row of $A$, i.e. $A(1,:)$ and wonder what will be the frequency of the mode. This is, how many times the most common element in the first row of $A$ will appear and whether the mode...
Expected value of maximum of a matrix of size $n$
|probability-theory|matrices|
This is the classical [balls into bins problem](https://en.wikipedia.org/wiki/Balls_into_bins_problem) with as many balls as bins. The maximum load is with high probability about $\frac{\log n}{\log \log n}$.
null
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells. The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in N : n \lt k\...
Consider a Turing machine with alphabet $\Sigma$, states $Q$, a transition function $\delta$ and a tape with $k$ cells. The configurations of this Turing machine (contents of the tape, current state, position of the read-write head) form a finite set $\Sigma ^k \times Q \times [k-1]$ if $[k-1] = \{n \in N : n \lt k\...
I have in the lectures a sentence in English, which I have to translate to First Order Logic. > Someone who loves all animals loves all humans. Textbook solution: > ∀x.(is_human(x) ⇒ is_animal (x)) ⇒ ∀y. ( is_human(y) ∧ ∀z.(is_animal > (z) ⇒ loves(y, z)) > > ⇒ ∀z.(is_human(z) ⇒ loves(y, z)))) My sol...
First order logic word someone
|first-order-logic|
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
>Given a list of $n$ pairs (cost,points) and number $k$ ($0 \le k$), find the maximum possible sum of points s.t their sum of costs no more than $k$. return the maximum possible sum of points and their corresponding sum of costs. For example the list $[(5,10),(1,2),(4,3),(6,12),(11,18)]$ and $k=15$, the maximum sum ...
Given a list of pairs (cost,points) and a number k, find the maximum sum of points with sum of costs less than or equal to k
|algorithms|dynamic-programming|
Your problem is the [Knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem). It is already well documented. It has a pseudo-polynomial time algorithm, and a [FPTAS](https://en.wikipedia.org/wiki/Fully_polynomial-time_approximation_scheme). The idea of the dynamic programming algorithm is that if that if $...
Consider an unweighted and directed graph G(V, E). Suppose, for every vertex v ∈ V we assign a vertex label y(v). We say that the vertex labeling is valid if for every edge (u, v) ∈ E that is directed from u to v, **y(v) − y(u) ≤ 1**. We say that the edge is admissible if **y(v) − y(u) = 1**. Now consider a dir...
Proof that Path with admissible edges is shortest
|algorithms|graphs|proof-techniques|
null
Consider an unweighted and directed graph G(V, E). Suppose, for every vertex v ∈ V we assign a vertex label y(v). We say that the vertex labeling is valid if for every edge (u, v) ∈ E that is directed from u to v, **y(v) − y(u) ≤ 1**. We say that the edge is admissible if **y(v) − y(u) = 1**. Now consider a dir...
Consider the following sentence: > The green men live on Mars. How would you translate this into first order logic? Be sure to note that the sentence does not claim that any green men actually exist.
This is an old question, but let me give a final response for anyone who comes across it. Your restriction is that we are not allowed to do any coding. In other words, every source codeword is transmitted directly across the channel. Since there is no redundancy being added, the transmission rate is 1 bit per symbol...
This is an old question, but let me give a final response for anyone who comes across it. Your restriction is that we are not allowed to do any coding. In other words, every source codeword is transmitted directly across the channel. Since there is no redundancy being added, the transmission rate is 1 bit per symbol...
null
{"Voters":[{"Id":118821,"DisplayName":"NirF"}]}
I can propose an algorithm that will work for an arbitrary group. If $Z \subseteq G$ is a multiset of elements, let $\mathcal{S}(Z)$ denote the set of sums of non-trivial submultisets of $Z$, i.e., $$\mathcal{S}(Z) = \left\{\sum_{y \in Y} y \mid \emptyset \ne Y \subsetneq Z \right\}.$$ Say that $Z$ is *annoying* if ...
If a problem X is NP-complete that means by definition that I can take any problem Y in NP, and for every instance of Y I can construct an instance of X so that solving X allows me to solve Y in polynomial time. Now assume P = NP. Then Y is in P, so I can solve it in polynomial time anyway - without having to const...