instruction
stringlengths
0
29.8k
⌀
matplotlib.widget.Slider displays but isn't active when plt.show() is called outside function that created the slider. Am I missing something?
|graphics|
I'm trying to recreate the RSA key generator, from what I understood you must create two prime numbers of 256 bytes long, `p` and `q`. Since there really isn't a method able to generate prime numbers, you must generate random numbers so then you can test their primality using an algorithm. Here is where the [Rabin-M...
Is Miller-Rabin not suitable algortihm for the RSA key generation or am I missing something?
|algorithms|cryptography|primes|
Is Miller-Rabin not a suitable algortihm for the RSA key generation or am I missing something?
Found answer under button issue. Need to maintain class reference to the slider. Replace "slider" with "self.slider" works.
I came a across a question where there were some statements made on Finite Automata, DFA and their states. One such statements in the question was that a "Every DFA accepting a finite language must contain a dead state" And the answer stated the statement to be true, and showed some DFA where there was a dead sta...
Every DFA accepting a finite language must contain a dead state?
|finite-automata|
Yes you are making a mistake. There is an important condition here, which is **finite**. The language $(a+b)^*$ is not finite. For $L$ any language, $L^*$ is finite if and only if $L = \emptyset$ or $L = \{\varepsilon\}$.
Turing Machines can be used to compute functions. For example `f(x)=x-1`. `0011` is on the tape. Turing Machine computes for some time and finishes in accept state. On the tape, we see: `_00_10_`. Where `_` is a blank symbol. Is it correct? Meaning `0011 == _00_10_`. For exaple in Python: `[] + [1] + [] + [2...
How to think about blank symbol when Turing Machine used as a function?
|turing-machines|computability|
Hopefully I solved it: let $B \in Union, A <_p B$, then from $ B \in NP \implies A \in NP$ and from $B \in co-NP \implies B \in co-NP$, thus $A \in Union$. So $Union$ is closed under polynomial time reductuons.
So it would be a prove that P=NP, isn't it? IMHO worth checking and researching... Big prize ahead!
So it would be a PROOF that P=NP, isn't it? IMHO worth checking and researching... Big prize ahead!
null
When inserting into an AVL tree, the existing nodes are not compared with each other, so the probability of comparing $a_4$ and $a_9$ with each other when inserting $a_{40}$ is $0$. On the other hand, the probability of comparing $a_{n}$ to both $a_4$ and $a_9$ is derivable asymptotically by considering how many com...
null
This can be solved with dynamic programming. Let $W[1,\dots,n]$ denote the weights of the items. Fix a value of $\ell$. Define the array $A[\cdot,\cdot]$ as $A[i,j] = $ the smallest value of $h$ such that there is an allocation of the first $i$ items to the first $j$ containers where the lightest container is $\g...
There are various meta-learning algorithms in RL that are proposed for settings when we have a (deep) neural network and the policy (or the value function) are parameterized as such. Can these methods be applied to tabular cases? For instance by following the steps of algorithm 3 in the MAML paper (https://arxiv.or...
Tabular Meta-Learning in RL
|dynamic-programming|neural-networks|reinforcement-learning|
null
> "Every DFA accepting a > finite language must contain a dead state" This depends on the definition. If dead state is the same as what some call a garbage state (not accepting, for all letters a loop back to the state) then this statement is *not* true. See the automaton below, which accepts only the empty string....
It is known that $QSAT$ is $PSPACE$ complete, and it is known that $QSAT_i$ is $\Sigma_i$ complete for any constant $i$. However, what if we had $QSAT_{\log n}$? That is, $QSAT$ where the quantifiers can alternate $\omega(1)$ times, but still $o(n)$. Would this be enough to make the problem $PSPACE$ complete, or are al...
What Complexity Class Contains $QSAT_{\log n}$?
|complexity-theory|complexity-classes|oracle-machines|
P.S. Sorry if this question is not meant for this community, was wondering whether or not to ask this question here or on stack overflow. I am currently learning about how the compilation and linking works in c++. I think I kinda get how the compiler works and that for a file to fully copile you don't need to have f...
How does linker know where to look for a function implementation in c++?
|compilers|c|c++|
null
The compiler compiles from a .cpp file to an object file (.o) with the binary code. The linker combines all of the object files together into a single binary. So, the linker doesn't need to know which cpp to look at, because the linker doesn't look at cpp files. Instead, the linker looks at all of the .o files, ...
From [the Wikipedia article](https://en.wikipedia.org/w/index.php?title=Lambda_calculus&oldid=1135426911): > An abstraction $\lambda x.t$ denotes an anonymous function that takes a single input $x$ and returns $t$. For example, $\lambda x.x^{2}+2$ is an abstraction for the function $f(x)=x^{2}+2$ using the term $x^{...
null
The linker is given explicitly the list of files to use. They can be object files (.obj / .o) - compiled code - or libraries (.lib / .a) - object files in a single one. The filenames are given in the command line of the linker. Part of the job of the linker is to establish a list of the available functions and assig...
I know that Busy Beaver problem can be used to illustrate the Halting Problem and it's probably the canonical problem used when talking about the Halting Problme . But long time ago I came across some a computation of a sequence from a starting value, that was used to illustrate the problem (I thought the source was Un...
Is there a good example of computing a sequence that illustrates the Halting Problem?
|halting-problem|
The linker is given explicitly the list of files to use, in the command line of the linker. They can be object files (.obj / .o) - compiled code - or libraries (.lib / .a) - object files structured in a single one. Part of the job of the linker is to establish a list of the available functions and assign them an add...
Let $\Sigma_{O(\log n)} \mathrm{P}$ be the class of languages accepted by a polynomial-time alternative Turing machine with $O(\log n)$ alternations. Then, $QSAT_{\log n}$ is complete for this complexity class (under polynomial-time many-one reduction, for example). This question in TCS.SE [Quantified Boolean Formulas ...
Given a fixed number of infinite-capacity containers and a list of items of varying weights, how can I best place the items into the containers **preserving their original order** in a way that minimises the difference between the heaviest and lightest containers? For example, given 3 containers and 10 items with we...
line 1: c1 line 2: 2^n line 3: c2 line 4: c3 line 5: c4 T(n) = c1 + 2^n + c2n + c3n + c4n T(n) = theta(2^n)
Suppose we have some trees of the following forms: [![Zigzag trees][1]][1] We want to place these trees in a linear fashion in a way such that the last node has the minimum distance to the first node. For instance, if we have the following trees: [![Example][2]][2] Then an optimal placement will be like...
Optimum placement of zigzag trees in order to minimize the makespan
|algorithms|graphs|trees|scheduling|
line 1: c1 line 2: n line 3: c2 line 4: c3 line 5: c4 T(n) = c1 + n + c2n + c3n + c4n T(n) = theta(n)
null
I am working on the following problem, given input list of length n to two sublists of length n2 , which are recursively sorted and then merged into a sorted list of length n. The merge sort has the recurrence for its time complexity as T (n) = 2T (n/2) + O(n). We can assume that the algorithm is modified such that th...
Verification of modified version of mergesort
|algorithms|
null
I am trying to analyze the algorithm *Product*: multiply two n-bits binary numbers x and y. ``` function Product(x, y); 1. prod = 0; 2. while y not eq 0 3. y = y -1; 4. prod = prod + x; return prod; ``` Assume: n = |x| = |y| Give the worst case time T(n) function for algorithm Product. ...
How can we analyze the procedure Product: multiply two n-bits binary numbers x and y?
null
I am working on the following problem, given input list of length n to two sublists of length n2 , which are recursively sorted and then merged into a sorted list of length n. The merge sort has the recurrence for its time complexity as T (n) = 2T (n/2) + O(n). We can assume that the algorithm is modified such that th...
null
You misunderstand soundness and completeness of logic. You think that it says: > A statement is true if, and only if, it is provable. But it really says: > A statement is true *in every model* if, and only if, it is provable. It *can happen* that there is a model in which a statement is true but not provabl...
I need to convert a Max Heap to a "Partially Sorted Max Heap" such that all keys at level i are smaller than all keys at level i-1. What is the most efficient way of doing this? Can this be done in O(n)?
Partially sorted Max Heap
|heaps|
Recently I began learning a couple array based programming languages: Dyalog APL and BQN. And I cam across this peculiar manner in which division by zero is handled in Dyalog APL. Using the in-built method ```⎕DIV``` a user can change the behaviour of $0÷0$. For instance if ```⎕DIV=0``` then $0÷0$ will return $1$ and i...
Division by zero in APL: assign return value 0 or 1
|programming-languages|arrays|mathematical-foundations|
In the [Church-Turing thesis Wiki page][1], there are a set of descriptions of the "behavior of a computor—`a human computing agent who proceeds mechanically'". I am content with all of them, except: > (L.2) (Locality) A computor can shift attention from one symbolic configuration to another one, but the new observe...
While "unlimited" is also correct, "bounded" is much preferred. ------ Here is the expanded answer. > The new observed configurations must be within a bounded distance of the immediately previously observed configuration. As you have explained, it is certainly reasonable and correct to replace "a bounded di...
null
While "unlimited" is also correct, "bounded" is much preferred. ------ Here is the expanded answer. > The new observed configurations must be within a bounded distance of the immediately previously observed configuration. As you have explained, it is certainly reasonable and correct to replace "a bounded di...
null
Consider the following problem: Given an undirected, weighted graph $G=(V,E)$, and a pair of vertices $s,t$, we wish to find a lowest cost path from $s$ to $t$ with length exactly $k$. That is, out of all paths from $s$ to $t$ with length $k$, we wish to find the one with the lowest cost. As D.W tried to direct y...
I have a formula which cannot be expressed in terms of y. fv = (p (1 + r) (-1 + (1 + r)^m) ((1 + r)^(m y) - (1 + x)^y))/ (r (-1 + (1 + r)^m - x)) + c (1 + r)^(m y) I'd like to solve it numerically with some kind of matrix operation. A simpler case is this, solved for r s = (a (1 + r) (-1 ...
Linear algebra matrix coding to solve specific formula
|linear-algebra|
I have a formula which cannot be expressed in terms of y. fv = (p (1 + r) (-1 + (1 + r)^m) ((1 + r)^(m y) - (1 + x)^y))/ (r (-1 + (1 + r)^m - x)) + c (1 + r)^(m y) I'd like to solve it numerically with some kind of matrix operation. For example with r = 0.05/12 m = 12 p = 100...
Linear algebra and matrices are not relevant here. Roughly speaking, they are useful when you have a system of linear equations. Here, you have a single equation, not a system of equations; and it is nonlinear. If I understand correctly, given $p,m,\dots$, you are trying to find a value of $y$ that satisfies the e...
I'm trying to say this in my paper: "$M$ is a key-value store, where 1) all keys are unique, 2) $k \in M$ means that the $k$ key exists in the store, 3) $M[k \to v]$ is a new store equal to $M$ but the key $k$ is assigned to $v$, 4) $M - k$ is a new store equal to $M$ but without the $k$ key. Is it possible to omit ...
What is the right name for a "map" data structure?
|definitions|
null
I'm trying to say this in my paper: "$M$ is a key-value store, where 1) all keys are unique, 2) $k \in M$ means that the $k$ key exists in the store, 3) $M + (k, v)$ is a new store equal to $M$ but the key $k$ is assigned to $v$, 4) $M - k$ is a new store equal to $M$ but without the $k$ key. Is it possible to omit ...
You might be looking for a [dictionary][1]. Common implementations are [hash tables](https://en.wikipedia.org/wiki/Hash_table) and [binary search trees](https://en.wikipedia.org/wiki/Binary_search_tree). [1]: https://en.wikipedia.org/wiki/Dictionary_(data%20structure)
null
Let $H$ be the max-heap represented as an array. We assume that the elements of the heap occupy the non-zero indices of $H$ e.g. the maximum element is at index 1. Notice that all elements at depth $d$ of the heap and their children, which are the elements at depth $d+1$, form a contiguous subarray, $H[2^{d}], ,..., H[...
Let $H$ be the max-heap represented as an array. We assume that the elements of the heap occupy the non-zero indices of $H$ e.g. the maximum element is at index 1. Notice that all elements at depth $d$ of the heap and their children, which are the elements at depth $d+1$, form a contiguous subarray, $H[2^{d}], ,..., H[...
Let $H$ be the max-heap represented as an array. We assume that the elements of the heap occupy the non-zero indices of $H$ e.g. the maximum element is at index 1. Also, I will use depth instead of level but that should not be a problem. Notice that all elements at depth $d$ of the heap and their children, which are...
I need to convert a Max Heap to a "Partially Sorted Max Heap" such that all keys at depth i are smaller than all keys at depth i-1. What is the most efficient way of doing this? Can this be done in O(n)?
Is there a way to make implication graph of expression of form : $$ ((x_1 \lor x_2)\land(x_3 \lor x_2))\lor(x_3 \lor x_4)$$ I haven't been able to find any sort of text on this and the usual way to make implication graph like of 2-SAT doesn't really make sense because of the extra AND in between.
Is there a way to make a implication graph of the following expression?
|time-complexity|2-sat|
Is there a way to make implication graph of expression of form : $$ ((x_1 \lor x_2)\lor(x_3 \lor x_2))\land(x_3 \lor x_4)$$ I haven't been able to find any sort of text on this and the usual way to make implication graph like of 2-SAT doesn't really make sense because of the extra OR in between.
> It is the linker's job to link the function declaration to it's implementation This is not true. This is the compiler's job. Essentially the declaration (I'm assuming you mean the prototype, as in `return_type function_name (arguments...)`) is part of the language to allow you to tell the compiler what the functio...
I might be about to provide an unusual perspective on this, but in my view there is no one convention on division that suits all practical purposes. I can certainly recall code I've fixed in the past - I forget any exact details - where a division by zero was not considered an error at all, but the result was intend...
I want to know if checking whether a 3-SAT is satsifiable if and only if every clause has at least 2 or all three literal set to true NP-complete? It seems similar to Exact-3SAT but it differs from it as the version of this problem which we'll call Exact2or3-3SAT ,where all literals are positive is trivial as its alway...
Is checking whether a 3-SAT is satsifiable if and only if every clause has at least 2 or all three literal set to true NP-complete?
|complexity-theory|np-complete|
null
Is checking whether a 3-SAT is satsifiable if and only if every clause has at least 2 or all three literal set to true an NP-complete problem?
null
Here's a question about semaphore. (True/False) The signal operation can be implemented with spinlocks The answer is false, but I don't know why. I thought the signal operation can be implemented like signal(mutex): C.S. Entry section (including busy-waiting) mutex++ C.S. ...