instruction
stringlengths
0
29.8k
⌀
null
null
If I'm given a minimum spanning tree, my understanding is that it is a structure that connects all nodes to each other through some path, and that the overall weight of the tree is smallest. However, does this necessarily imply that for any 2 nodes V1 and V2 in the MST, that the path between V1 and V2 is definitely the...
Does a minimum spanning tree necessarily provide the lowest cost path between any 2 nodes?
|graphs|weighted-graphs|minimum-spanning-tree|
Yes, MSTs usually don't contain the shortest path for any pair of nodes. The simplest example is probably just the MST of 3 nodes connected to each other all with edge weight $1$.
String matching performed bit by bit would be much slower than character by character, because a character is made of 8 or 16 bits and a processor can handle them in a single go. Also note that string matching is based on comparisons, that conclude "equal" or "different", whether the symbols are bits or characters (...
In a Talk by Herb Sutter [C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2][1] at 46:30 the point is made that only around 15% of the physical space (or the transistors) on a CPU do actual processing while the rest is basically just caches. Further it is mentioned that of those 15%, only around 1% account fo...
Are really only ~1% of the physical CPU space used for computing
|computer-architecture|cpu|cpu-cache|
Consider two finite languages, $L_A$ and $L_B$, potentially over different alphabets. Now since these languages are finite, there exist minimal acyclic deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively. So $x \in L_A$ iff $M_A$ accepts $x$, and $y \in L_B$ iff $M_B$ accepts $y$. We are al...
How many page faults are there in the following accesses of pages in case of FIFO mechanism where page frame size is 8? 11,21,23,53,7,7,10,8,3,3,3,37,7 Soln: This question appeared in one of my the entrance tests for a company and I am pretty sure I got it right but there was no option matchinh what I had thought. ...
Page fault question
|computer-architecture|
Consider two finite languages, $L_A$ and $L_B$, potentially over different alphabets. Now since these languages are finite, there exist minimal acyclic deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively. So $x \in L_A$ iff $M_A$ accepts $x$, and $y \in L_B$ iff $M_B$ accepts $y$. We are al...
null
I don't have any actual numbers for you, but that's partly because I don't know what Herb Sutter meant by "actual processing". What I think he meant is, essentially, ALUs. So you have to consider what you're comparing with. This is a die shot of the Intel 8086, a top-of-the-line CPU from 1978. [![Intel 8086 annot...
I don't have any actual numbers for you, but that's partly because I don't know what Herb Sutter meant by "actual processing". What I think he meant is, essentially, ALUs. So you have to consider what you're comparing with. This is a die shot of the Intel 8086, a top-of-the-line CPU from 1978. [![Intel 8086 annot...
I don't have any actual numbers for you, but that's partly because I don't know what Herb Sutter meant by "actual processing". What I think he meant is, essentially, ALUs. So you have to consider what you're comparing with. This is a die shot of the Intel 8086, a top-of-the-line CPU from 1978. [![Intel 8086 annot...
null
I don't have any numbers for you, but that's partly because I don't know what Herb Sutter meant by "actual processing". What I think he meant is, essentially, ALUs. So you have to consider what you're comparing with. This is a die shot of the Intel 8086, a top-of-the-line CPU from 1978. [![Intel 8086 annotated di...
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]}
null
null
The text says it: direct access works by sequential search from a neighboring location (such as the start of a block known to contain the desired data). Though the search should not be long, the number of searched positions is variable. As far as I know, this peculiar definition is rarely met, and usually direct and...
null
Consider two finite languages, $L_A$ over alphabet $A$ and $L_B$ over alphabet $B$. $A$ might be the same as $B$. Since $L_A$ and $L_B$ are finite, there exist acyclic minimal deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively. So $x \in L_A$ iff $M_A$ accepts $x$, and $y \in L_B$ iff ...
The text says it: direct access works by sequential search from a neighboring location (such as the start of a block known to contain the desired data). Though the search should not be long, the number of searched positions is variable. As far as I know, this peculiar definition is rarely met, and usually direct and...
Consider two finite languages, $L_A$ over alphabet $A$ and $L_B$ over alphabet $B$. $A$ might be the same as $B$. Since $L_A$ and $L_B$ are finite languages, there exist minimal acyclic deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively.<!-- A self loop in a directed graph is not consi...
> It was established by the answer to my previous question that if two strings $u$ and $v$ map to the same Myhill-Nerode equivalence class in $B$ under $f$ [modeled by formula (2)], they map to the same equivalence class in $A$ [modeled by formula (4)] ... No, formula (2) does not describe the condition that two str...
null
Source: https://oj.vnoi.info/problem/cryptkey (problem statements are in Vietnamese, so here it is translated) ``` 1. There is a set S with some elements a_1, a_2, ..., a_n; 2. If A and B are 2 elements in set S, then GCD(A, B) and LCM(A, B) are also elements in set S You are given N numbers a_1 to a_n which are...
Check if number k exists in a special set (see desc)
|sets|
null
If you have parsed the input $1^l 0$ then to get a string in the language, we must have l ≥ 1, and the only possibility is to produce $1^l 0^l$, so the prefix $1^l 0$ has only one possible suffix $0^{l-1}$. The set of possible suffixes is $\{ 0^{l-1} \}$, for l ≥ 1. Now which other prefixes can be turned into a str...
Background: I'm working on a data structure benchmark tool to benchmark insert and search time and I am trying to improve my own implementation of a BST to support parallelism. I have implemented a Binary Search Tree, it is a very basic (naive) tree structure: ``` class Node: Node? right; Node? left; ...
Is there a way to parallelise find and inserts for a binary search tree?
|trees|parallel-computing|concurrency|binary-search-trees|
A sparse 1D array of integers is commonly encoded as pairs of [index, value], which consumes 2 memory spots per value. A dense 1D array is commonly encoded as a linear array of values [value1, value2, ..., valueN], consecutive in memory. If an array is encoded as a sparse array, but grows in density, until it bec...
There are adaptive algorithms for sparse and non sparse vectors?
|algorithms|optimization|arrays|efficiency|encoding-scheme|
The language of all Turing machines $T$ that do not halt on empty input is well-known to not be recognizable. If the Turing machine $M$ of your question existed then you could decide the above language as follows: - Generate (the description of) a Turing Machine $K$ that, on input $x$, simulates $T$ for (up to) $|x...
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]}
null
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]}
The language of all Turing machines $T$ that do not halt on empty input is well-known to not be recognizable. If the Turing machine $M$ of your question existed then you could decide the above language as follows: - Generate (the description of) a Turing Machine $K$ that, on input $x$, simulates $T$ on empty input ...
null
How many page faults are there in the following accesses of pages in case of FIFO mechanism where page frame size is 8? $$11,21,23,53,8,7,10,3,3,38,3,37,7$$ Soln: This question appeared in one of my the entrance tests for a company and I am pretty sure I got it right but there was no option matching what I had thou...
ridge [rɪdʒ] NOUN a long, narrow hilltop, mountain range, or watershed: "the North-East ridge of Everest" synonyms: mountain · hill · height · alp · aiguille · serac · puy · crag · tor · inselberg · [more] by looking at the definition of "ridge" I think we can simply understand it as a hill. although we need t...
null
| Page Number | Stack Contents | Page fault| |:------------- | :-----------------------|:------- | 11 | 11 | +1 | 21 | 11, 21 |+1 | 23 | 11, 21, 23 |+1 | 53 | 11, 21, 23, 53 |+1 | 8 | 11, 21, 23, 53, 8 |+1 | 7 | 11, 21, 23, 53, 8, 7|+1 | 10 | 11, 21, 23, 53, 8, 7,10|+1 | 3 | 11, 21, 23,...
Viterbi is not necessarily always better than smoothing. Viterbi returns the MAP estimate, but for some region in the input space, there might be too high of uncertainty that it is better to go with the "reject option". This is mentioned in Kevin Murphy's "Machine Learning: a probabilistic perspective" section 17.4.1, ...
| Page Number | Frame Contents | Page Fault| |:------------- | :-----------------------|:------- | 11 | 11 | +1 | 21 | 11, 21 |+1 | 23 | 11, 21, 23 |+1 | 53 | 11, 21, 23, 53 |+1 | 8 | 11, 21, 23, 53, 8 |+1 | 7 | 11, 21, 23, 53, 8, 7|+1 | 10 | 11, 21, 23, 53, 8, 7,10|+1 | 3 | 11, 21, 23,...
> Most algorithms I know don't "allocate" any space resources, they just use it, and they don't need to know the length of the input explicitly The intuition/description/statement of "most algorithms just use space resources" is so obvious for people who are entrenched in languages like Python or JavaScript that the...
> Most algorithms I know don't "allocate" any space resources, they just use it, and they don't need to know the length of the input explicitly The intuition/description/statement of "most algorithms just use space resources" is so obvious for people who are entrenched in languages like Python or JavaScript that the...
null
I'm trying to sort the elements of a set of "goal" stacks to minimize the number of pushes/pops to reach each state. The inputs and outputs can be some other structure rather than stacks, they just represent a target state of the stack. Each goal must be reached in the order given in the input. For example, given th...
Minimizing operations to reach a set of goal stack states
|algorithms|data-structures|optimization|sorting|
A sparse 1D array of integers is commonly encoded as pairs of [index, value], which consumes 2 memory spots per value. A dense 1D array is commonly encoded as a linear array of values [value1, value2, ..., valueN], consecutive in memory. If an array is encoded as a sparse array, but grows in density, until it bec...
Are there adaptive algorithms/data structures for sparse and non sparse vectors?
I was reading a textbook on COA, it says [![I have attached the corresponding passage][1]][1] [1]: https://i.stack.imgur.com/bTLO5.png If the processor is going to ignore the interrupt request line till the execution of the first instruction of the ISR, how will it know which device to service? I mean the pro...
What does it mean to have the processor ignore interrupt request line?
|computer-architecture|
null
null
Source: https://oj.vnoi.info/problem/cryptkey (problem statements are in Vietnamese, so here it is translated) > There is a set S with some elements a_1, a_2, ..., a_n. > If A and B are 2 elements in set S, then GCD(A, B) and LCM(A, B) are also > elements in set S. > > You are given N numbers a_1 to a_n which a...
Check if number k exists in a special set
|sets|number-theory|
Ridges are maxima that are very elongated in one direction. When you sample such a function, the sampling points will not fall exactly on the ridge line and will "fluctuate randomly", giving the impression of numerous local maxima. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/5fOEe.p...
null
After $m$ operations, a single digit becomes a string of about $2^{\log_{10}\frac m{10}}$ digits, as the number of digits doubles about every ten operations. So just writing the result takes time $\Omega(n\,m^{0.301\cdots})$. A possible method is to precompute the expansions of the ten digits after $m$ operations, a...
null
It turns out that we can check whether $k$ is in $S$ "from the perspective of each prime factor" of $k$ without listing all elements in $S$. ------ Here is a simple and fast algorithm. 1. If $k=1$, return whether $a_1, \cdots, a_n$ is relatively prime. 2. Now $k$ has at least one prime factor. Factorize $k$ t...
Consume M + 2 slots per each continuous sequence of M values in sparse array: [index, length, value1, value2, .., valueM]. When you append a new value to a sequence check if it is possible to join the next sequence to this one. If N is the high index of the array it will consume N + 2 slots when fully filled. In t...
Source: https://oj.vnoi.info/problem/cryptkey (problem statements are in Vietnamese, so here it is translated). <!-- https://oj-vnoi-info.translate.goog/problem/cryptkey?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en --> > There is a set $S$. If $A$ and $B$ are in $S$, then $\gcd(A, B)$ and $\text{lcm}(A, B)$ are also in $S$...
Find if a given number must be in a set that is closed under gcd and lcm with some given elements
|algorithms|time-complexity|sets|number-theory|
Source: https://oj.vnoi.info/problem/cryptkey (problem statements are in Vietnamese, so here it is translated). <!-- https://oj-vnoi-info.translate.goog/problem/cryptkey?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en --> > There is a set $S$ of positive integers. If $A$ and $B$ are in $S$, then $\gcd(A, B)$ and $\text{lcm}(A...
You can easily construct an aperiodic RNG with 2 building blocks: 1. An unbounded counter c as internal state and 2. a (cryptographic) hashing algorithm H(). Then your RNG is H(c) and you increment the state c after every application. As some others have noted, an aperiodic RNG is a theoretic construct, becau...
| Page Number | Frame Contents | Page Fault| |:------------- | :-----------------------|:------- | 11 | 11 | +1 | 21 | 11, 21 |+1 | 23 | 11, 21, 23 |+1 | 53 | 11, 21, 23, 53 |+1 | 8 | 11, 21, 23, 53, 8 |+1 | 7 | 11, 21, 23, 53, 8, 7|+1 | 10 | 11, 21, 23, 53, 8, 7,10|+1 | 3 | 11, 21, 23,...
Consider two finite languages, $L_A$ over alphabet $A$ and $L_B$ over alphabet $B$. $A$ might be the same as $B$. Since $L_A$ and $L_B$ are finite languages, there exist minimal acyclic deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively.<!-- A self loop in a directed graph is not consi...
It turns out that we can check whether $k$ is in $S$ "from the perspective of each prime factor" of $k$ without listing all elements in $S$. ------ Here is a simple and fast algorithm. 1. If $k=1$, return "YES" if $a_1, \cdots, a_n$ are relatively prime and "NO" otherwise. 2. Now $k$ has at least one prime fa...
null
> It was established by the answer to my previous question that if two strings $u$ and $v$ map to the same Myhill-Nerode equivalence class in $B^*$ under $f$ [modeled by formula (2)], they map to the same equivalence class in $A^*$ [modeled by formula (4)] ... No, formula (2) does not describe the condition that two...
Consider two finite languages, $L_A$ over alphabet $A$ and $L_B$ over alphabet $B$. $A$ might be the same as $B$. Since $L_A$ and $L_B$ are finite languages, there exist minimal acyclic deterministic finite-state automata to decide them: $M_A$ and $M_B$ respectively.<!-- A self loop in a directed graph is not consi...
null
The operations under scrutiny are memory reads and writes, i.e. accesses. So you care about average *access time*. There is no reason to call that *cycle time* (unless you would be studying the average cycle time, whatever that means).
I want to find the maximum possible value of an unknown function on a rectangle. What is the optimal method of doing this? Do I need to use simulated annealing?
Black Box Optimization
|optimization|
null
null
I am interested in understanding what we mean by a von Neumann architecture and need something at a very introductory level. Does anyone know of any good and readable references or notes that will introduce me to this topic?
Reference/notes for introduction to (von Neumann) architecture
|computer-architecture|reference-request|
null
Are there systems in computer science where we have several logic systems working all at once and without isolation? I am thinking there are system where subsystem A uses Paraconsistent logic, subsystem B uses Four-valued logic, and subsystem C uses ordinary logic, but the elements inside those subsystem don't interact...
Are there systems in computer science where we have several logic systems working all at once and without isolation?