instruction
stringlengths
0
29.8k
⌀
|linear-programming|
*(larger context at the end)* ## My view of the problem I have an undirected graph whose nodes can be categorized into three classes depending on some metadata (I have a function that can tell me the class of a node in constant time), let's name the classes $A$, $B$ and $C$. I want to find the $C$ node that is...
Longest shortest path between two classes of nodes
|graphs|
Let's say I have a optimization problem P1, where the constraints are linear but the objective function is not. Let's say I have another optimization problem which is linear in constraints and linear in the objective function. The goal of the problem is to show that if P1 has a bounded optimum value then P2 has the ...
null
null
null
I've heard it said that "fortran uses column-major ordering because it's *faster*" but I'm not certain that's true. Certainly using a column-major algorithm with column-major ordering will be faster than mixing things up, but I'm curious if there's any *absolute* reason to prefer row- or column-major ordering which lea...
Are there absolute reasons to prefer row/column-major memory ordering?
|memory-access|performance|matrix-multiplication|
I've heard it said that "fortran uses column-major ordering because it's *faster*" but I'm not certain that's true. Certainly using a column-major algorithm with column-major ordering will be faster than mixing things up, but I'm curious if there's any *absolute* reason to prefer row- or column-major ordering which lea...
i think because when proposer become leader.it send accept RPCs in it's term with firstUnchosenIndex ,so if the accepter found it's index<firstUnchosenIndex and acceptedProposal[index]'s proposalNum == leader's proposalNum. it knows that this leader has chosen index's value,because there is acceptedProposal[index],so l...
null
Consider a P1 where the values of the objective function are constrained. P1 Objective: max f(x) = Sin(x) Constraints: 0 <= x <= 10 P2 Objective: max g(x) = x Constraints: 0 <= x <= 10 It should be obvious that in this case, 1. holds but 2. does not. A proof could look like t...
null
I've heard it said that "fortran uses column-major ordering because it's *faster*" but I'm not certain that's true. Certainly matching column-major data to a column-major implementation will outperform a mixed setup, but I'm curious if there's any *absolute* reason to prefer row- or column-major ordering which lead me ...
I have a question : is the term front-end in this context phpmyadmin is frontend for mysql slang is it taught in academy in this context I don't want to use slang term
Is frontend slang term is it used in teaching in univ
|terminology|
null
I've heard it said that "fortran uses column-major ordering because it's *faster*" but I'm not sure that's true. Certainly, matching column-major data to a column-major implementation will outperform a mixed setup, but I'm curious if there's any *absolute* reason to prefer row- or column-major ordering. To illustrate t...
Whether row-major or column-major order is more efficient, depends on the storage access patterns of a specific application. The underlying principle of computing is that accessing storage in sequential locations tends to be the most efficient pattern possible, whereas accessing storage at disparate locations incurs...
Are there any problems which are known to be both NP-complete and EXPTIME-compelte? My guess is no, because we know that $P$ is not equal to $EXPTIME$ and EXPTIME-complete problems are not in $P$, and hence a problem that was both NP-complete and EXPTIME-complete would imply $P \not= NP$. Is my thinking correct?
Are there any problems which are known to be both NP-complete and EXPTIME-complete?
|complexity-theory|time-complexity|
null
null
Are there any problems which are known to be both NP-complete and EXPTIME-compelte? My guess is no, because we know that $P$ is not equal to $EXPTIME$ and EXPTIME-complete problems are not in $P$, and hence a problem that was both NP-complete and EXPTIME-complete would imply $P \not= NP$. Is my thinking correct? N...
null
null
null
No, that is not currently known. If such a problem were known, it would prove that: $$NP=EXPTIME$$ Incidentally, it would also prove that $NP=PSPACE$, because it is known that: $$P \subseteq NP \subseteq PSPACE \subseteq EXPTIME$$ We don't know which of these subset relations are strict subset relations, bu...
null
null
null
According to Merriam Webster [frontend](https://www.merriam-webster.com/dictionary/front-end) is not slang.
null
Similar answer to that of Steve. The most appropriate storage order depends on the traversal patterns. But the programmer has some freedom to optimize the pattern in a way that is cache-friendly. E.g. a matrix-vector multiply can be implemented as - clear all $b_r$, - loop on the matrix rows: - loop on...
Consider a P1 where the values of the objective function are constrained. P1 Objective: max f(x) = Sin(x) Constraints: 0 <= x <= 10 P2 Objective: max g(x) = x Constraints: 0 <= x <= 10 It should be obvious that in this case, 1. holds but 2. does not. A proof could look like t...
The theorems are true iff the images of the feasible sets coincide (whatever the kind of constraints and kind of functions). This has no reason to occur in general. One of the theorems can hold accidentally if one of the images is a subset of the other.
The theorems are true iff the images of the feasible sets by their respective function coincide (whatever the kind of constraints and kind of functions). This has no reason to occur in general. One of the theorems can hold accidentally if one of the images is a subset of the other. For instance if the P2 function is...
**Task** Build the Parse Table > Let $\mathcal{G}$ be the following context-free grammar: $$ \begin{aligned} E &\to TE' \\ E' &\to +TE'\; |\; \epsilon \\ T &\to F T' \; \\ T' &\to *FT'|\;\;\epsilon \\F &\to (E)\; | \;id \\ \end{aligned} $$ I calculated $ FIRST $ and $ FOLLOW $ sets \begin{aligned} FIRST...
Getting something wrong while building parse table for the grammar
|compilers|parsers|
**Task** Build the Parse Table > Let $\mathcal{G}$ be the following context-free grammar: $$ \begin{aligned} E &\to TE' \\ E' &\to +TE'\; |\; \epsilon \\ T &\to F T' \; \\ T' &\to *FT'|\;\;\epsilon \\F &\to (E)\; | \;id \\ \end{aligned} $$ I calculated $ FIRST $ and $ FOLLOW $ sets \begin{aligned} FIRST...
null
**Task** Build the Parse Table > Let $\mathcal{G}$ be the following context-free grammar: $$ \begin{aligned} E &\to TE' \\ E' &\to +TE'\; |\; \epsilon \\ T &\to F T' \; \\ T' &\to *FT'|\;\;\epsilon \\F &\to (E)\; | \;id \\ \end{aligned} $$ I calculated $ FIRST $ and $ FOLLOW $ sets \begin{aligned} FIRST...
**Task** Build the Parse Table > Let $\mathcal{G}$ be the following context-free grammar: $$ \begin{aligned} E &\to TE' \\ E' &\to +TE'\; |\; \epsilon \\ T &\to F T' \; \\ T' &\to *FT'|\;\;\epsilon \\F &\to (E)\; | \;id \\ \end{aligned} $$ I calculated $ FIRST $ and $ FOLLOW $ sets \begin{aligned} FIRST...
The fact is that with current computer hardware, the time to access one cache line (often as large 64 byte) of consecutive bytes is practically the same as the time to access a single word (say 8 bytes) in a cache line, so it is much more efficient to access items that are stored in consecutive memory positions. And ac...
The recurrence can be written $$S(0)=1=4^0\\S(k)=S(k-1)+4^k$$ and you should recognize the sum of a geometric series, by $$S(k)=S(k-1)+4^k=S(k-2)+4^{k-1}+4^k=S(k-3)+4^{k-2}+4^{k-1}+4^k=\cdots\\=S(0)+4^1+\cdots4^{k-1}+4^k=\frac{4^{k+1}-1}3=\frac{4n^2-1}3.$$
The recurrence can be written $$\begin{cases}S(0)=1=4^0\\S(k)=S(k-1)+4^k\end{cases}$$ and you should recognize the sum of a geometric series, by $$S(k)=S(k-1)+4^k=S(k-2)+4^{k-1}+4^k=S(k-3)+4^{k-2}+4^{k-1}+4^k=\cdots\\=S(0)+4^1+\cdots4^{k-1}+4^k=\frac{4^{k+1}-1}3=\frac{4(2^k)^2-1}3=\frac{4n^2-1}3.$$
null
You can find the solution "manually" by successive doublings and by writing the recurrence as $$\frac{T(n)}{n^2}=\frac{T\left(\dfrac n2\right)}{n^2}+1.$$ The sums are $$\frac{T(1)}1=1,\\\frac{T(2)}4=\frac14+1,\\\frac{T(4)}{16}=\frac1{16}+\frac14+1,\\\frac{T(8)}{64}=\frac1{64}+\frac1{16}+\frac14+1,\\\cdots$$ ...
I've heard it said that "fortran uses column-major ordering because it's *faster*" but I'm not sure that's true. Certainly, matching column-major data to a column-major implementation will outperform a mixed setup, but I'm curious if there's any *absolute* reason to prefer row- or column-major ordering. To illustrate t...
null
I am reading a book about data architecture, and I am wondering about the text segment and the memory adresses. In one example(assembly using ARM) where the code was compiled there were adresses to global variables. Does this mean that the executable is always loaded in the same place in the text segment?, so that t...
Is the executable always loaded to the same place in the text segment?
|computer-architecture|assembly|
null
Let A[1...n] be an array of n distinct numbers. The ordering of the numbers is any permutation of [1,2,...,n]. An array Inv_A is defined as follows: Inv_A[i] = number of elements A[j] such that j<i and A[j] > A[i]. Give an optimal algorithm that computes the above array Inv_A. For example if A = [3,1,4,5,2] then Inv_A ...
Inversion array of a given array
|algorithms|time-complexity|data-structures|algorithm-analysis|arrays|
Given the following: - A set of input types **I** = {a, b, c, ...} - A set of functions **F** (With associated weights, and possibly identical signatures) {(a -> d), ((a,b) -> e), (c -> (d,f)), ...} - A set of desired output types **O** {f, g, h, ...} I would like to build a system that can return the smallest...
Data structure and optimal algorithm for modeling reachable outputs given a set of inputs
|graphs|functional-dependencies|
Front-end and back-end are very common terms, with several meanings. https://en.wikipedia.org/wiki/Frontend_and_backend They are *jargon*, not *slang*. You *should* use them rather than periphrases.
|graphs|
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) {(a -> d), ((a,b) -> e), (c -> (d,f)), ...} - A set of desired output types $O$ {f, g, h, ...} I would like to build a system that can return the smallest set o...
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) {(a -> d), ((a,b) -> e), (c -> (d,f)), ...} - A set of desired output types $O$ {f, g, h, ...} I would like to build a system that can return the lowest cost se...
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) {(a -> d), ((a,b) -> e), (c -> (d,f)), ...} - A set of desired output types $O$ {f, g, h, ...} I would like to build a system that can return the lowest cost se...
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) {(a -> d), ((a,b) -> e), (c -> (d,f)), ...} - A set of desired output types $O$ {f, g, h, ...} I would like to build a system that can return the lowest cost se...
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) {($w_1$, a -> d), ($w_2$, (a,b) -> e), ($w_3$, c -> (d,f)), ...} - A set of desired output types $O$ {f, g, h, ...} I would like to build a system that can retu...
|graphs|data-structures|
The problem is NP-hard, by reduction from [set cover](https://en.wikipedia.org/wiki/Set_cover_problem). In particular, suppose we have a instance of the set cover problem, i.e., sets $S_1,\dots,S_m$, and the goal is to identify the smallest collection of sets whose union is $U$. We can create an instance of your pr...
Given the following: - A set of input types $I$ = {a, b, c, ...} - A set of functions $F$ (With associated weights, and possibly identical signatures) = {($w_1$, a -> d), ($w_2$, (a,b) -> e), ($w_3$, c -> (d,f)), ...} - A set of desired output types $O$ = {f, g, h, ...} I would like to build a system that can ...
Given the following: - A set of input types $I$ = {a, b, d, ...} - A set of functions $F$ (With associated costs, and possibly identical signatures) = {($c_1$, a -> d), ($c_2$, (a,b) -> e), ($c_3$, e -> (d,f)), ...} - A set of desired output types $O$ = {f, g, h, ...} I would like to build a system that can re...
Apply [heap-sort][1] for in-place sorting in $O(log(n))$ time. For a real application, it's better to use the simple randomized-quick-sort. You can get enough build-in routines in almost every popular language. [1]: https://www.happycoders.eu/algorithms/heapsort/
null
While studying Shannon's notion of perfect secrecy I came upon the idea that a bit is perfectly random if it happens to be 0 or 1 with an equal probability. What does this mean? Also, what can we say about the determinism here?
Does a random phenomenon have a pre defined probability distribution? what does it mean for something to be random?
|nondeterminism|randomness|cryptography|
null
*(larger context at the end)* ## My view of the problem I have an undirected graph whose nodes can be categorized into three classes depending on some metadata (I have a function that can tell me the class of a node in constant time), let's name the classes $A$, $B$ and $C$. I want to find an $A$ node and a $C...
Determinism is not broken, it is just that you are unaware of the value of the bit and can make no bet on it (because the two outcomes are as likely). If you have some extra information such as "there are twice as many ones as zeroes in total" (but you still don't know where), you'd better bet one than zero to maxim...
null
null
null
If I understand correctly, only the bits $a_k=1$ are to be counted. Then, a given bit influences exactly one sum per group, and no sum in the same group have common terms. So a straightforward solution is to associate to every bit the list of sums it takes part to (one per group), and to accumulate that bit to these su...
Given a set of nodes $N$ on an undirected, weighted graph $G$ and a query node $n$, what is the fastest algorithm for finding the node in $N$ that is closest to $n$? Furthermore, say we are doing many of these queries, so have many $n$'s, is there some data structure that could speed up this computation? Thank yo...
Algorithms for finding closest graph node within set of nodes
|algorithms|graphs|data-structures|discrete-mathematics|weighted-graphs|
null
Given two strings ABC and CBA, find A, B and C. Input: abcacab, cabcaab Output: ab, ca, cab The time complexity of brute force is O(n^3). Are there any better algorithms to solve this problem? Thanks!
Given two strings ABC and CBA, find A, B and C
|algorithms|time-complexity|
My algorithm homework revolves around matching 4 `"O"`'s or 4 `"X"`'s on a diagonal, horizontal, or vertical. Hopefully that makes sense... This is what the data looks like below (2D tuples) where I need to recreate a function that returns `"O"` or `"X"` or `False` depending on what is found. xwins = ((None, ...
algorithm homework help
|algorithms|python|
I'd start by trying to find possible values of A. A could be an empty string obviously. Otherwise, you know the last character of A. Let's say that character is the first, fourth and nineteenth character of ABC. Then A could be one character. Or it could be the first four characters of ABC (if it matches the la...