instruction
stringlengths
0
29.8k
⌀
I got a n*m matrix updated in realtime (i.e. about every 10ms) with values between 0 and 1024, and I want to work out from that matrix a multitouch trackpad behaviour, which is: * generate one or more points on the surface given the values on the matrix, * make this or those point as big as the value can be. F...
I finally managed to get what I want. I used python's scipy's interpolate.RectBivariateSpline(x,y,z,kx,ky) to create a 60x60 matrix out of the 3x3 matrix. And out of that, I used opencv libraries to detect blobs (mainly, `findContours()` and `fitEllipse()`), so now I got a list of ellipses matching the severa...
from talking to the poster, algorithms that handle parallel matrix multiplication are apparently acceptable answers. matrix multiplication and parallel algorithms for it are a highly studied problem in CS partly because of its widespread application eg in scientific computing. (there are other ways to parallelize the p...
from talking to the poster, algorithms that handle parallel matrix multiplication are apparently acceptable answers. matrix multiplication and parallel algorithms for it are a highly studied problem in CS partly because of its widespread application eg in scientific computing. (there are other ways to parallelize the p...
null
Regarding this [article][1] every time you expand a node in the AO* algorithm you must go backwards to update all of its predecessors’ estimated cost. When you use linear data structure to contain the nodes you must traverse the data elements sequentially and only one data element can be directly taken (stack, q...
I would like to know what impacts does a scheduling algorithm say Round Robin of FIFO have on a Operating system. I understand the a scheduling algorithm has the processes run in burst then switch between one another. But what does this mean for an OS. All i can figure out is that the OS has to keep track of which proc...
Scheduling algorithms and quantum time
|algorithms|scheduling|
This is not a research question. Merely observe that $2^{2n} = 4^n \equiv 1^n\equiv 1 \mod 3$ and $10^n \equiv 1^n\equiv 1 \mod 3$. The relevance of $2^{2n}$ is that exchanging two characters (stored in bytes with even numbers of bits) amounts to multiplying one part of a key by $2^{2n}$ for some $n$, and dividing a...
This is a textbook based question. In The Art of Computer Programming Vol 3, Knuth says that for a hash function: $h(k) = k \mod M\\$, $M$ should not be a multiple of 3. The explanation given is that "if keys are alphabetic, two keys that differ only by permutation of letters would differ in numeric value by a mult...
TAOCP 3: hash function should not be mod 3
|untagged|
In Prim's and Kruskal's Algorithm. There are many implementations which will give different running times. However suppose our implementation of Prim's Algorithm is: O(|E| + |V|*log(|V|)) Kruskals's Algorithm is: 0(|E|*log(|V|)) 1. What is the base of the log?
Complexity Analysis in Prim and Kruskal's Algorithm
|time-complexity|
To expand on what David Eppstein said, you can assume it's in any base. If the log were initially in base $b$, it is asymptotically the same as if it were in base $k$: $$O(\log_b n) = O\left(\frac{\log_k n}{\log_k b}\right) = O(\log_k n)$$ because $k$ and $b$ are both constants; $\log_k b = O(1)$. The log...
|operating-systems|process-scheduling|
This is a textbook based question. In The Art of Computer Programming Volume 3, Knuth says that for a hash function $h(k) = k \mod M$, $M$ should not be a multiple of $3$. The explanation given is: > If keys are alphabetic, two keys that differ only by permutation of letters would differ in numeric value by a mul...
|data-structures|hash-tables|hash|
Modulo hash function and multiples of three
Observe that $2^{2n} = 4^n \equiv 1^n\equiv 1 \mod 3$ and $10^n \equiv 1^n\equiv 1 \mod 3$. The relevance of $2^{2n}$ is that exchanging two characters (stored in bytes with even numbers of bits) amounts to multiplying one part of a key by $2^{2n}$ for some $n$, and dividing another part by a like amount. (Also note...
null
For Prim's and Kruskal's Algorithm there are many implementations which will give different running times. However suppose our implementation of Prim's algorithm has runtime $O(|E| + |V|\cdot \log(|V|))$ and Kruskals's algorithm has runtime $O(|E|\cdot \log(|V|))$. What is the base of the $\log$?
Base of logarithm in runtime of Prim's and Kruskal's algorithms
|algorithms|time-complexity|graphs|algorithm-analysis|runtime-analysis|
The state of a qubit, or of a collection of qubits, is given by a state vector. However, most people would say that the *output of a quantum computer* is in fact the result of a measurement, which transforms the state into one which indicates a single outcome. There are many ways to approach this, but the simplest o...
The state of a qubit, or of a collection of qubits, is given by a state vector. However, most people would say that the *output of a quantum computer* is in fact the result of a measurement, which transforms the state into one which indicates a single outcome. There are many ways to approach this, but the simplest o...
null
The method you propose is, as far as I know, the historically first one for "perfect" hashing in linear space. In perfect hashing, lookup takes $O(1)$ time in the worst-case. (Recall that in most simple hash tables, lookup takes $O(1)$ time only in expectation.) The idea is to use chaining (rather than open addressi...
null
Production for $\{b^jc^k\; |\; j\neq 2k \}$ can be written as $B\rightarrow bBcc\;|\;bB_1\;|\;cB_2$ $B_1\rightarrow bB_1\;|\;b\;|\;c\;|\;\epsilon$ $B_2\rightarrow cB_2\;|\;c\;|\;\epsilon$ You can see that it can't accept $bbcccc$. We can use $B\rightarrow bBcc$ twice but the final $B$ would have to be subs...
Context Free Grammar for language
null
The language is $L = \{a^{i} b^{j} c^{k} \;|\; k \neq 2j\}$. I'm trying to write a grammar for this language, what I have so far is: $S \rightarrow AT_{1} \;|\; AT_{2} \;|\; AT_{3} \;|\; AB \;|\; AC$ $A \rightarrow aA \;|\; \varepsilon$ $B \rightarrow bB \;|\; \varepsilon$ $C \rightarrow cC \;|\; \varepsil...
null
The tree having maximum number of nodes is a [full binary tree][1]. A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children. If the height is $h$, clearly maximum number of nodes would be $2^h - 1$ [1]: http://...
{"Voters":[{"Id":4422,"DisplayName":"Shashwat"}]}
Here is my version of a grammar for $\{a^ib^jc^k \mid k\neq 2j \}$. It is based on the very straight-forward grammar for $\{a^ib^jc^k \mid k= 2j \}$, but then it requires to have either an additional (non-empty) sequence of `b`s or an additional (non-empty) sequence of `c`s to show up in the proper place. There is on s...
I think it should be a [full binary tree][1] to support maximum number of nodes at a particular height. A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children. At successive level, number of nodes would be 1, 2, 4, 8...
{"Voters":[{"Id":4422,"DisplayName":"Shashwat"}]}
This is a beginners question. I and reading the book "Intro to computer theory by Daniel cohen". But in the end i end up with confusion regarding simplification and FA. I want to create an FA for expression<br/> ![enter image description here][1] My first question is that how we can simplify this expression? Ca...
Regex simplification and FA
|finite-automata|regular-expressions|
I think it should be a [full binary tree][1] to support maximum number of nodes at a particular height. A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children. At successive level, number of nodes would be $1, 2, 4, ...
I am currently working on a project where I'm using an implementation of Hoffman and Pavley's "[Method for the Solution of the Nth Best Path Problem][1]" to find `n` best path through a directed graph. The implementation is based on [QuickGraph's Ranked Shortest Path implementation][2]. I have been trying to determi...
What is the complexity of Hoffman and Pavley's Nth best path algorithm?
|time-complexity|shortest-path|
This is a beginners question. I and reading the book "Intro to computer theory by Daniel cohen". But in the end i end up with confusion regarding simplification and FA. I want to create an FA for expression<br/> ![enter image description here][1] My first question is that how we can simplify this expression? Ca...
I am currently working on a project where I'm using an implementation of Hoffman and Pavley's "[Method for the Solution of the Nth Best Path Problem][1]" to find n-th best path through a directed graph. The implementation is based on [QuickGraph's Ranked Shortest Path implementation][2]. I have been trying to determ...
|algorithms|time-complexity|graphs|algorithm-analysis|shortest-path|
|formal-languages|automata|finite-automata|regular-expressions|
This is a beginners question. I and reading the book "Introduction to Computer Theory" by Daniel Cohen. But I end up with confusion regarding simplification of regular expressions and finite automata. I want to create an FA for the regular expression $\qquad \displaystyle (a+b)^* (ab+ba)^+a^+\;.$ My first questio...
Simplification of regular expression and conversion into finite automata
I know that Hamilton Cycle problem is NP. But i think about one modification of this problem and I think that's can be solved in polynomial time. But i don't have any ideas how to do it. Given a random planar graph with V vertex and E edges. We also have a start node S and finish node F. Our task is to find ha...
Modification of Hamilton Cycle
|algorithms|graphs|
I know that Hamilton Path problem is NP. But i think about one modification of this problem and I think that's can be solved in polynomial time. But i don't have any ideas how to do it. Given a random planar graph with V vertex and E edges. We also have a start node S and finish node F. Our task is to find ham...
Modification of Hamilton Path
null
I know that Hamilton Path problem is ${\sf NP}$. But I think about one modification of this problem and I think that's can be solved in polynomial time. But i don't have any ideas how to do it. Given a planar graph with vertex set $V$ and edge set $E$. We also have a start node $S$ and target node $F$. Our tas...
Consider an Exclusive-OR gate with inputs (logical variables) $x$ and $y$ and output $z = x\oplus y$. Suppose $x$ and $y$ are equally likely to take on values $0$ and $1$ and are _independent_, that is $$P\{x = a, y = b\} = P\{x = a\}P\{y = b\} = \frac{1}{4} ~~\text{for all} ~a, b \in \{0,1\}.$$ Then, $P\{z = 1\}...
Perhaps the problem is still NP-complete; this reduction should work: given a planar graph $G$ and two nodes $s$ and $t$ (start and end), expand it to a new graph $G'$ in this way: for every node $u$ of $G$ add two nodes $u_1,u_2$ and two edges: $(u,u_1),(u_1,u_2)$ (informally add a *tail* made with two new nodes). Pic...
I know that Hamilton Path problem is ${\sf NP}$-complete. But I think about one modification of this problem and I think that's can be solved in polynomial time. But i don't have any ideas how to do it. Given a planar graph with vertex set $V$ and edge set $E$. We also have a start node $S$ and target node $F$...
At the point of writing, your NFA is still a bit off. One version of a correct answer looks like this: ![enter image description here][1] So this NFA is design in an ad hoc manner, but there's still some basic organisation to it. You can see that there's three basic bits, the $a,b$ loop on the start state, a forced...
|complexity-theory|graphs|np-hard|
Take a Turing machine, with a terminating program, convert it to some representation of the machine which captures, in a loss less manner, it's state as it performs the computation. So you have a complete representation of the machine, the program, and the it's internal organisation as it performs the computation. ...
Is it possible to analyse computation?
|graphs|runtime-analysis|artificial-intelligence|
null
I have got one problem with this task. I developed an algorithm but i want to create something faster than adding edges to graph ( using $n * BFS ) and dijkstra. The problem is : Given a graph with n vertex and m edges. Every edge has got a weight costs x dollars. To vertices between which there is no direct p...
Shortest path in graph - upgrade an algorithm
|algorithms|graphs|
How can one show that a machine with a three dimensional memory arranged in an infinite grid can be simulated by a single-tape Turing machine? I'd imagine there's some sort of mapping possible from three dimensional coordinates to single coordinates (eg. (0,0,0) -> 0, (1,0,0) -> 1, (-1,0,0) -> 2, ...) but I can't figur...
Robustness of Turing Machines - 3 dimensional case
|turing-machines|
Assume that we have a set $D$ and each member of $D$ is a data and key pair. We want a data structure that would support the following operations: * Insert $(d,k)$ into $D$, * Delete member $e$, (no need to search to find $e$, e.g. $e$ points to a member in $D$), * MostFrequent, which returns a member $e \in D$ su...
An efficient data structure supporting Insert, Delete, and MostFrequent
|algorithms|data-structures|abstract-data-types|
How many different max-heaps can I form using a list of $n$ integers. Example: list [1,2,3,4] and max-heap is `4 3 2 1` or 4 / \ 3 2 / 1 other possible max-heap is `4 2 3 1` 4 / \ 2 3 / 1
How many max heaps are there?
|data-structures|counting|
It seems that the missing piece here is that the switching does not only occur when a process completes. The switch will occur when either 1) the process completes, or 2) when the process explicitly yields its remaining run time slice (whatever it has not used of its time quantum), or 3) when the OS pre-emptively inte...
I did not found a closed form, but according to this entry in the [Online Encyclopedia of Integer Sequences](http://oeis.org/A056971) the sequence starts with 1, 1, 1, 2, 3, 8, 20, 80, 210, 896, 3360, 19200, 79200, 506880, 2745600, 21964800, 108108000, 820019200, 5227622400, 48881664000, 319258368000, ... You ca...
I know that Hamilton Path problem is ${\sf NP}$-complete. But I think about one modification of this problem and I think that's can be solved in polynomial time. But i don't have any ideas how to do it. Given a planar graph with vertex set $V$ and edge set $E$. We also have a start node $S$ and target node $F$...
Take a Turing machine, with a terminating program, convert it to some representation of the machine which captures, in a lossless manner, its state as it performs the computation. So you have a complete representation of the machine, the program, and its internal organisation as it performs the computation. I am ...
|graphs|optimization|runtime-analysis|compilers|artificial-intelligence|
|algorithms|complexity-theory|graphs|np-hard|
Assume that we have a set $D$ and each member of $D$ is a data and key pair. We want a data structure that would support the following operations: * Insert $(d,k)$ into $D$, * Delete member $e$, (no need to search to find $e$, e.g. $e$ points to a member in $D$), * MostFrequent, which returns a member $e \in D$ su...
This is a textbook based question. In The Art of Computer Programming Volume 3, Knuth says that for a hash function $h(k) = k \bmod M$, $M$ should not be a multiple of $3$. The explanation given is: > If keys are alphabetic, two keys that differ only by permutation of letters would differ in numeric value by a mu...
null
How would I solve these problems involving time complexity: 1) Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in $64n log_2 n$ steps. For which values of n does insertion sort beat merge sor...
Comparing Time complexity?
|complexity-theory|time-complexity|
Although I know that the [Hamilton Path problem][1] is ${\sf NP}$-complete, I think the following variant can be solved in polynomial time: > Given a planar graph with vertex set $V$, edge set $E$, start node $S$ and target node $F$, > our task is to find the Hamiltonian path from $S$ to $F$ or write that the path ...