instruction
stringlengths
0
29.8k
⌀
|blockchain|
I came across a proof that an AVL tree has $O(\log n)$ height and there's one step which I do not understand. Let $N_h$ represent the minimum number of nodes that can form an AVL tree of height $h$. Since we're looking for the **minimum** number of nodes, let its children's number of nodes be $N_{h-1}$ and $N_{h-2}$...
|data-structures|search-trees|balanced-search-trees|avl-trees|
Here is a dominance frontiers algorithm, mentioned on [Wikipedia][1]: ``` for each node b dominance_frontier(b) := {} for each node b if the number of immediate predecessors of b ≥ 2 for each p in immediate predecessors of b runner := p while runner ≠ idom(b) ...
Is the predecessors number check in dominance frontiers algorithm necessary?
|algorithms|graphs|static-analysis|
There are several ways to explain "computable implies continuous", I shall give here two such explanations. ### Turing machines compute continuous maps Suppose we have a Turing machine which takes possibly infinite amount of input written down on an input tape. It writes the result on an output tape, where the ou...
null
I am learning algorithm complexities. So far it has been an interesting ride. There is so much going behind the scenes that I need to understand. I find it difficult to understand complexity in recursive function. `my_func` takes an array parameter `A` of length $n$. Runtime of `some_func()` is constant. ```pytho...
|algorithms|complexity-theory|time-complexity|asymptotics|recurrence-relation|
null
|compilers|
null
**Problem Description:** We have an array of $n$ positive integers and in one operation we have to choose two elements in the array and decrease them by $1$. (Elements on which we are performing this operation must be positive). How can we do this operation on this array repeatedly as many times as possible? *[Probl...
Given n positive integers, pick two elements and subtract each by one with one operation. Find maximum number of operations
|algorithm-analysis|arrays|greedy-algorithms|correctness-proof|priority-queues|
null
I have made a red-black tree and I think that it is not valid. Could someone please verify? B / \ / \ / \ / \ R R / \ / \ B B B B / \ /...
null
I'm having trouble understanding lamport timestamps in practice and how they guarantee causal ordering. ### Definitions [Lamport defines the "happens before" relationship in his paper](https://lamport.azurewebsites.net/pubs/time-clocks.pdf). He states that an event a happens before an event b (denoted as a -> b) u...
Lamport Timestamps and Causality
|distributed-systems|partial-order|ordering|consistency-model|
After the build-up phase of the heap, HeapSort repeatedly removes the root of the heap. You can find configurations such that every root removal implies the movement of nodes on every level, resulting in a total work proportional to log(n)+log(n-1)+...log(1).
After the build-up phase of the heap, HeapSort repeatedly removes the root of the heap. You can find configurations such that every root removal implies the movement of nodes on every level, resulting in a total work proportional to log(n)+log(n-1)+...log(1) ~ log(n!).
No, there is no inherent logical/temporal inconsistency in the events described in the question, although it can be considered "unfair" that process P2 can receive and broadcast messages faster than other process. Well, this kind of "unfairness" occurs naturally and commonly. It is not the responsibility of Lamport ti...
null
The $\delta$ trick will work with a suitable choice of $\delta$, but a bulletproof method is to rate the paths with the pair (sum of weights, length), and use lexicographical ordering (i.e. in case of ties on the sums, compare the lengths). Besides this, the algorithms remains completely unchanged.
There is a kind of templates to translate common NLP patterns into LTL. https://matthewbdwyer.github.io/psp/patterns/ltl.html Hope it helps :D.
Let $P_1P_2...P_k$ be a page sequence that gives $n$ page faults with the optimal page replacement algorithm. Does the page sequence $P_kP_{k-1}...P_1$ give the same number of page faults. This can be proved quite easily in the case of LRU, and disproved for FIFO. Does it hold for Optimal Replacement?
Does optimal page replacement cause the same number of faults for the reverse string?
|operating-systems|page-replacement|
As said by others, the number of passes equals the amplitude of the largest element displacement required. The displacement is the difference between the index and the rank of an element. Finding all ranks is... a sorting operation. I don't see a possible shortcut (but I cannot swear).
null
I am given an undirected, weighted graph $G$, on its base I have to create a spanning tree with such a property that the difference between the largest edge weight and the smallest edge weight is the smallest possible. I know how to find a minimal spanning tree, e.g. using Prim's algorithm or Kruskal's algorithm, bu...
Spanning tree - minimum difference between smallest and largest weight
|graphs|minimum-spanning-tree|spanning-trees|
null
Sorting a million numbers with a poor algorithm takes 50000 times longer than with an efficient one. Can you afford waiting 31 years before Moore's law compensates ? By the way, the task of algorithmics is not just to improve the speed of known algorithms, but to develop algorithms that address new problems.
Constructing the Delaunay triangulation of a set of 2D points (a pretty useful geometric construction) on 1000 points would take 50 million times more operation by brute force than by an efficient method. Can you afford waiting 51 years before Moore's law compensates ? By the way, the task of algorithmics is not jus...
Constructing the Delaunay triangulation of a set of 2D points (a pretty useful geometric construction) on 1000 points (a relatively small problem) would take 50 million times more operation by brute force than by an efficient method. Can you afford waiting 50 years before Moore's law compensates ? By the way, the ta...
null
The quest for new algorithms is unending. It is not just about solving the solved problems faster, it is about how to solve more problems. By the way, improvements by a factor $2$ is peanuts. In extreme cases, algorithmic improvements allow you to gain factors like $2^{3000}$, for instance.
You can solve the problem in $O(m \log n)$ time. For the sake of simplicity assume that all edge weights are distinct (this assumption can be easily removed). Let $e_1, e_2, \dots, e_m$ be the edges in the input graph $G$ in increasing order of weight. Define $G_i$ as the subgraph of $G$ induced by $\{e_i, \dots, e_...
You can solve the problem in $O(m \log n)$ time. For the sake of simplicity assume that all edge weights are distinct (this assumption can be easily removed). Let $e_1, e_2, \dots, e_m$ be the edges in the input graph $G$ in increasing order of weight. Define $G_i$ as the subgraph of $G$ induced by $\{e_i, \dots, e_...
I'm not 100% sure about this but here's what I think: > Would applying DeMorgan's rule to the minimal DNF result in the minimal CNF? If you negate the expression and then apply De Morgan's laws you a CNF for the negation of the original expression. I think it's also minimal though I don't have a rigorous proof. ...
null
Based on increasing values of weights, sort the edges; e.g. $e_1,...,e_m$. For $i=1,...,m-n+1$ (we need atleast $n-1$ edges to produce a spanning tree) produce an MST $T_i$ on $e_i,...,e_m$ and calculate the difference $d_i$ between the edge weight which is selected with maximum value and $w(e_i)$. Note that, the e...
I realized that my answer is similar to **Steven**'s answer but maybe suitable for someone. Based on increasing values of weights, sort the edges; e.g. $e_1,...,e_m$. For $i=1,...,m-n+1$ (we need atleast $n-1$ edges to produce a spanning tree) produce an MST $T_i$ on $e_i,...,e_m$ and calculate the difference $d...
You can solve the problem in $O(m \log n)$ time. For the sake of simplicity assume that all edge weights are distinct (this assumption can be easily removed). Let $e_1, e_2, \dots, e_m$ be the edges in the input graph $G$ in increasing order of weight. Define $G_i$ as the subgraph of $G$ induced by $\{e_i, \dots, e_...
null
This looks like the so called *master-slave scheduling model* introduced by [Sahni][1]. In particular, your problem falls under the Single-Master Master-Slave Systems. You can distinguish several cases: 1) If you do not add any additional constraint on the order of job execution (as in your case), the problem is cal...
null
> Given a BST $T$, $x$ is a random node in it and $y$ is the right child of $x$.<br> How does the PostOrder traversal of BST $T$ change after we rotate the tree left on node $x$? In which cases does the traversal not change? **My Attempt:** <br> I've decided to draw a sketch of the sub-tree of $T$ rooted in $x$: ...
Solution Verification: How does the postorder traversal of a BST change after rotating left?
|data-structures|binary-trees|binary-search-trees|tree-traversal|
Due to nature of data, just storing the data is better of than compressing it.
Everyone knows that merge sort will continuously divide the array into halves until they are small enough to (like 2 elements per block or so) be able to be sorted quickly, hence its time complexity being (n*log n). n part being the merge and log n being the splitting part of the algorithm. But how would the algorit...
How will changing the mid point in merge sort affect the algorithm and its time complexity
|time-complexity|mergesort|
How will changing the splitting point in merge sort affect the algorithm and its time complexity
You can't compress Bitcoin addresses, so this is a dead end.
null
You can solve the problem in $O(m \log n)$ time. For the sake of simplicity assume that all edge weights are distinct (this assumption can be easily removed). Let $e_1, e_2, \dots, e_m$ be the edges in the input graph $G$ in increasing order of weight. Define $G_i$ as the subgraph of $G$ induced by $\{e_i, \dots, e_...
null
You can solve the problem in $O(m \log n)$ time. For the sake of simplicity assume that all edge weights are distinct (this assumption can be easily removed). Let $e_1, e_2, \dots, e_m$ be the edges in the input graph $G$ in increasing order of weight. Define $G_i$ as the subgraph of $G$ induced by $\{e_i, \dots, e_...
null
You can't compress blockchain addresses (in any blockchain I am familiar with), so this is a dead end.
Is it possible to enumerate through all the Turing Machines that solve the same given problem? For example, we know that there exists a Turing Machine that finds a satisfying assignment given a 3SAT formula. Therefore there are infinitely many 3SAT assignment finder Turing Machines. Could we enumerate all of them? Intu...
Enumerating through Turing Machines That Solve Same Problem
|turing-machines|enumeration|3-sat|
This MIPS code is given: ``` loopA: lw $t0, 0($s1) # $ array element addu $t0, $t0, $s3 # add scalar in s3 sw $t0, 0($s1) # store result addi $s1, $-4 # decrement pointer bne $s1, $zero, loopA # branch if s1!=0 loopB: lw $t0, 0($s2) ...
Computer Architecture MIPS assembler with predictors
|computer-architecture|operating-systems|assembly|mips|
null
|complexity-theory|turing-machines|computability|enumeration|3-sat|
null
null
Your question is, given a TM $M$, where $L(M) = L$, is it possible to create an enumerator $E_L$ that enumerates every $TM \ M'$, such that $L(M') = L$ The answer to this interesting question is actually no, we prove this by contradiction First consider the language $ATM = \{<M, w>| M \ is \ a \ TM \ and \ M \ ...
What is the time complexity of finding the kth smallest element of all the elements in two order statistics binary search trees? An order statistics tree is a binary search tree where the size of a subtree at each node is stored at that node.
Complexity of finding the kth smallest element of all the elements in two order statistics binary search trees
|time-complexity|binary-search-trees|
By solving for $n_0$ and $c$ the system of inequations $$\begin{cases}n>n_0,\\f(n)>c\,g(n).\end{cases}$$ Concretely, you can study the function $\dfrac{f(n)}{g(n)}$ and find a lower bound (f.i. the global minimum, or any gross approximation).
null
[Dulmage–Mendelsohn decomposition][1] is a powerful tool to capture the structure of the bipartite graph, and it can be found by computing any maximum matching. > Let $G = (V = (A, B), E)$ be a bipartite graph, then $G$ can be partitioned into three parts $(C, H, R)$ and we let : > 1. $C \subseteq V$ is an indepen...
It's not entirely clear to me what you need to design. You seem to have quoted a part of a description of a ready ISA. In your description the CMP instruction takes two arguments, i.e. the two registers to be compared. The instruction sets two 1 bit registers or flags based on the outcome of the comparison. These fl...
[Dulmage–Mendelsohn decomposition][1] is a powerful tool to capture the structure of the bipartite graph, and it can be found by computing any maximum matching. > Let $G = (V = (A, B), E)$ be a bipartite graph, then $G$ can be partitioned into three parts $(C, H, R)$ and we let : > 1. $C \subseteq V$ is an indepen...
In the case of two spheres - if the two straight-line trajectories do not interfere (in space-time), this is the optimal solution and the time taken is the length of the longest trajectory over the maximum speed; - if they do interfere, there are several options: - let the two spheres travel in a straight li...
What is the time complexity of finding the kth smallest element of all the elements in two order statistics binary search trees? An order statistics tree is a binary search tree where the size of a subtree at each node is stored at that node. Taking the root of the first tree and trying to find the largest element not ...
What is the time complexity of finding the kth smallest element of all the elements in two order statistics binary search trees? An order statistics tree is a binary search tree where the size of a subtree at each node is stored at that node. Taking the root of the first tree and trying to find the largest element not ...
[Dulmage–Mendelsohn decomposition][1] is a powerful tool to capture the structure of the bipartite graph, and it can be found by computing any maximum matching. > Let $G = (V = (A, B), E)$ be a bipartite graph, then $G$ can be partitioned into three parts $(C, H, R)$ and we let : > 1. $C \subseteq V$ is an indepen...
I have a hierarchical graph structure on a vertical timeline with nodes that have a fixed `y` coordinate. I am now looking for: 1. an algorithm (suggestions, any related papers, anything at all) to optimize the `x` of each node to reduce edge crossings (and generally increase graph readability). * One idea that ...
Graph Layout Algorithm that optimizes only `x` (not `y`) of nodes?
|graphs|
null
> Given a BST $T$, $x$ is a random node in it and $y$ is the right child of $x$.<br> How does the PostOrder traversal of BST $T$ change after we rotate the tree left on node $x$? In which cases does the traversal not change? **My Attempt:** <br> I've decided to draw a sketch of the sub-tree of $T$ rooted in $x$: ...
ZF and CF are computed by the instruction and stored in some "status register". They can later be used by conditional jumps. ZF is the "zero" flag and CF the "less than" flag. They can be obtained as a by-product of the subtraction of the two operands.
Below is a different reduction from CLIQUE to $\sqrt{n}$-CLIQUE which is essentially an extension of the reduction from CLIQUE to $\frac{n}{2}$-CLIQUE. Given an instance $(G=(V,E),k)$ of CLIQUE, we construct an instance $G'=(V',E')$ of $\sqrt{n}$-CLIQUE as follows. Suppose $V=\{v_1,...,v_n\}$, then $G'$ is defined a...
Suppose that the minimum VCP size is s. If $|Y|=s$ then the optimal solution (without solving any problem) is $Y=1$ and $X=0$. Else, we can solve $min$ $W_uX_u+W_vY_v$ s.t. {$x_u+y_v\ge 1$, $0\le x_u,y_v \le 1$}; i.e. the original VCP relaxation model, where $W_u=1$ and $W_v=1-\epsilon$. Based on Nemhauser a...
null
Double-SAT = {: has at least two satisfying truth assignments}. Hint: reduce from SAT. Start with a formula and modify it to get a formula so that is satisfibale if and only if has at least two satisfying truth assignments. If is not satisfiable, then also needs to be unsatisfiable. How do I the problem lie...