instruction
stringlengths
0
29.8k
⌀
|operating-systems|virtual-memory|
I had a question about inverted page table that I don't understand and would appreciate some help please. For the inverted page table, since the number of entries in the inverted page table equal number of entries in the main memory, wouldn't that result in two problems... One, the page can't have disk as physica...
For an inverted page table, it's number of entries = number of frames in main memory. One frame in the main memory, could be shared by two (or more) processes, say process A and process B. Usually this is noted down in process A and process B page table. Like process A page 0 maps to frame 1 offset 1-50, process B p...
How are frames split up in an inverted page table?
For an inverted page table, it's number of entries = number of frames in main memory. One frame in the main memory, could be shared by two (or more) processes, say process A and process B. Usually this is noted down in process A and process B individual page table. Like process A page 0 maps to frame 1 offset 1-50, ...
For an inverted page table, it's number of entries = number of frames in main memory. One frame in the main memory, could be shared by two (or more) processes, say process A and process B. Usually this is noted down in process A and process B individual page table. Like process A page 0 maps to frame 1 offset 1-50, ...
An inverted page table maps each page frame in physical memory to a list of one or more virtual pages in virtual memory. There is typically some kind of chaining or pointer to represent this list of virtual pages via a singly linked list. Since most page frames map to only a single process, this isn't needed for most...
null
null
To avoid contention(hazard) between the 2 stages, a [split cache][1] i.e. I-cache(instruction cache) and a D-cache(data cache) is used. Consequently, Fetch and Writeback operations are handled by I and D cache respectively. [1]: https://en.wikipedia.org/wiki/Modified_Harvard_architecture#Split-cache_(or_almost-v...
Start with $N>3$ vectors $\vec{v}_I$ in $\mathbb{R}^3_+$, any $3$ of which are linearly independent. $I$ here ranges from $0$ to $N-1$. Let $v_{\left[abc\right]}$ be a matrix in $\mathbb{R}^{3 \times 3}_+$ that picks three of the (column) vectors $\vec{v}_a\, \vec{v}_b\, \vec{v}_c$ in order $a < b < c$, without dupl...
Start with $N>3$ vectors $\vec{v}_I$ in $\mathbb{R}^3_+$, any $3$ of which are linearly independent. $I$ here ranges from $0$ to $N-1$. Let $v_{\left[abc\right]}$ be a matrix in $\mathbb{R}^{3 \times 3}_+$ that picks three of the (column) vectors $\vec{v}_a\, \vec{v}_b\, \vec{v}_c$ in order $a < b < c$, without dupl...
If a problem is NP-complete that means that lots and lots of great mathematicians, computer scientists, and very clever software developers have not been able to find an efficient solution for the problem. And that means nobody can blame you if you can't find one. If you could find one, they'd introduce a Nobel prize f...
How do I convert a graph to a search tree? Here's the question- [![enter image description here][1]][1] The problem is that I don't know how to represent interconnections in a graph on a tree. In the diagram A is connected to D, and same goes for B and E, C and F. But in tree I think no interconnections should be...
Representing graph as a search tree
|graphs|data-structures|search-trees|
[Algorithms](http://algorithmics.lsi.upc.edu/docs/Dasgupta-Papadimitriou-Vazirani.pdf) by Dasgupta, Papadimitriou and Vazirani represents a traversal tree as a tree rooted in the first vertex of the traversal search, with solid edges corresponding to edges crossed during the traversal, and dashed or dotted edges corres...
As a programmer, you likely do not need to pay *much* attention to the class of NP-complete problems. The class of NP problems is *much* more useful. Obviously, if your problem is NP, it cannot be solved for all inputs in polynomial time (by a deterministic Turing machine, and assuming $P\ne NP$... which is currently...
As a working programmer, you need to recognize when you are being asked by the business to *do the **literally** impossible*. Assuming ≠ (you don't need to understand what that means, just know that most of us do), then when you are being asked to solve a problem that falls into NP the solution is going to necessa...
I have some basic information about the graph coloring problem, which is an **NP-Complete** problem. I am very new to genetic algorithms, and I have faced a problem in which we have to solve the graph coloring problem using genetic algorithms. I have seen this [video][1], and also I have read the explanation which...
Solving graph coloring problem using genetic algorithms
|artificial-intelligence|genetic-algorithms|colorings|
In some languages, e.g. Ruby, an expression like: val = call_fn() || DEFAULT_VAL; will set val to the results of call_fn() if it is "truthy" (non-zero, non-NULL, etc), or to DEFAULT_VAL otherwise. This can be really useful. In C, the result of the || operator is always a boolean. Is there a strong arg...
In C, why limit || and && to evaluate to booleans?
|c|
It depends on the processor design. In the most simple solution, a pipeline bubble is inserted. The read (because it's earlier in the pipeline) has to wait until the next cycle after the write is done. In a more complex processor with a cache, the cache may be able to process multiple read and write requests at t...
Boolean types and Boolean expressions are the crux of the logical formalism and the latter is ubiquitous in programming. C was lacking them in the beginning, yet another design flaw of this language (took like twenty years to be fixed!). Tinkering a boolean type with integers is not just a conceptual mistake, it is ...
Boolean types and Boolean expressions are the crux of the logical formalism and the latter is ubiquitous in programming. C was lacking them in the beginning, yet another design flaw of this language (took like twenty years to be fixed!). Tinkering a boolean type with integers is not just a conceptual mistake, it is ...
Boolean types and Boolean expressions are the crux of the logical formalism and the latter is ubiquitous in programming. C was lacking them in the beginning, yet another design flaw of this language (took like twenty years to be fixed!). Tinkering a boolean type with integers is not just a conceptual mistake, it is ...
Let's say I have a Operating System with 4KB page size, but I need to allocate 8kb of memory for all the variables. Does the Process get new page (second one) or does the current page table simply get bigger?
If a process needs more RAM, does the Page size simply get bigger or does it get a new page?
|computer-architecture|operating-systems|memory-management|cpu|virtual-memory|
Consider a domain on a unit grid such that the grid nodes hold a point with probability $\frac12$. We construct a Euclidean minimum spanning tree on these points. How could we compute the probability that an edge of the tree is of unit length (so it joins two immediate grid neighbors) ?
Edge length in an EMST
|computational-geometry|probability-theory|minimum-spanning-tree|
It gets a new page. The page size is an operating system constant, and therefore - will not change. The [page size](https://en.wikipedia.org/wiki/Page_(computer_memory)) determines how "big" are individual chunks of memory. So, for example, if your page size is 4K, and your program needs 5K bytes, then your oper...
Consider a domain on a unit grid such that the grid nodes hold a point with probability $\frac12$. We construct a Euclidean minimum spanning tree on these points. How could we compute the probability that an edge of the tree is of unit length (so it joins two immediate grid neighbors) ? [![enter image description...
Consider a domain on a unit grid such that the grid nodes hold a point with probability $\frac12$. We construct a Euclidean minimum spanning tree on these points. How could we compute the probability that an edge of the tree is of unit length (so it joins two immediate grid neighbors) ? [![enter image description...
Consider a domain on a unit grid such that the grid nodes hold a point with probability $\frac12$. We construct a Euclidean minimum spanning tree on these points. How could we compute the probability that an edge of the tree is of unit length (so it joins two immediate grid neighbors) ? [![enter image description...
A quad-edge is a well-known data structure used to represent planar subdivisions or polyhedra. https://en.wikipedia.org/wiki/Quad-edge The procedure to enumerate the edges works by recursively visiting edges, then the next edge starting from the same origin and the next edge after reversal. A flag is used to mark th...
Enumeration of the vertices in a quad-edge structure
|data-structures|computational-geometry|
A quad-edge is a well-known data structure used to represent planar subdivisions or polyhedra. https://en.wikipedia.org/wiki/Quad-edge The procedure to enumerate the edges works by recursively visiting edges, and for every edge, the next edge starting from the same origin and the next edge after reversal. A flag is ...
null
null
null
null
In *A Simple Yet Fast Algorithm for the Closest-Pair Problem Using Sorted Projections on Multi-Dimensions*, Mehmet E. Dalkılıç and Serkan Ergun present algorithm *QuickCP* for finding the closest pair, discussing the planar case more often than other *Multi-Dimensions*. #### Algoritm 1 $\text{QuickCP}(P)$ ---- ...
Closest Pair of Points: QuickCP termination check
|computational-geometry|termination|
I'm looking for implementations of approximation algorithms (or algorithms that would be meaningful to implement for use in practice) for the minimum-cost multicommodity flow problem as defined in e.g. Section 2.1 of > Andrew V. Goldberg, Jeffrey D. Oldham, Serge Plotkin & Cliff Stein *An Implementation of a Combina...
State of the art implementations of minimum-cost multicommodity flow approximation algorithms
|algorithms|graphs|optimization|approximation|network-flow|
I trying to understand where, as a programmer in situations where it can be good to do a NP-complete reduction to prove that a problem is NP-complete, why is it good to do that as a programmer? I don't understand.
Why is proving something is NP-complete useful, and where can I use it?
null
I'm looking for implementations of approximation algorithms (or algorithms that would be meaningful to implement for use in practice) for the minimum-cost multicommodity flow problem as defined in e.g. Section 2.1 of > Andrew V. Goldberg, Jeffrey D. Oldham, Serge Plotkin & Cliff Stein *An Implementation of a Combina...
null
null
The reason is that C, by design, is a really simple language that provides operations closely aligned with what machine code of machines like the PDP11 offered. While I'm not familiar with PDP11 machine code I bet you there is a test for zero, an AND operation on registers, and conditional jumps available. On that l...
The reason is that C, by design, is a really simple language that provides operations closely aligned with what machine code of machines like the PDP11 offered. You posted the question in the *computer science* stack exchange, but computer science is not what C was designed for or from which it came. C is the creation ...
The reason is that C, by design, is a really simple language that provides operations closely aligned with what machine code of machines like the PDP11 offered. You posted the question in the *computer science* stack exchange, but computer science is not what C was designed for or from which it came. C is the creation ...
Edit: After re-reading the question and wovano's comment I htink my answer below misses the point because the suggestion to return the non-zero operand or zero if there isn't any would not be overly complicated or abstract if the operands stayed restricted to scalar types. I let the answer stand because I still think i...
I am trying to build a parser for lambda expressions. I have implemented a capture-avoiding substitution using the algorithm below (```e[d/x]``` means replace ```x``` by ```d``` in ```e```) [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/wactl.jpg We also know that ```(\x.e)(d) = e[d...
Lambda beta-reductions
|lambda-calculus|
An operator can be described in terms of three things: * The accepted range of values (type) of each of its operands * Its behaviour * The possible values (type) of its result The simplest "or" operator is defined as having two operands and a result all with values "true" or "false", i.e. a "boolean" type. The ...
null
I am trying to build a parser for lambda expressions. I have implemented a capture-avoiding substitution using the algorithm below ($e[d/x]$ means replace $x$ by $d$ in $e$) > $x[d/x] = d$ > > $y[d/x] = y$ if $x\neq y$ > > $(e_1 e_2)[d/x] = (e_1[d/x) (e_2[d/x])$ > > $(\lambda x.e')[d/x] = \lambda x.e'$ > > $...
An operator can be described in terms of three things: * The accepted range of values (type) of each of its operands * Its behaviour * The possible values (type) of its result The simplest "or" operator is defined as having two operands and a result all with values "true" or "false", i.e. a "boolean" type. The ...
Boolean types and Boolean expressions are the crux of the logical formalism and the latter is ubiquitous in programming. C was lacking them in the beginning, yet another design flaw of this language (took like twenty years to be fixed!). Tinkering a boolean type with integers is not just a conceptual mistake, it is ...
null
The `||` and `&&` operators in Ruby are closer to [basic process algebra](https://en.wikipedia.org/wiki/Algebra_of_communicating_processes) composition operators than to boolean connectives. The languages just happen to use the same symbols for these two different sorts of operators due to the lack of glyphs on the key...
An operator can be described in terms of three things: * The accepted range of values (type) of each of its operands * Its behaviour * The possible values (type) of its result The simplest "or" operator is defined as having two operands and a result all with values "true" or "false", i.e. a "boolean" type. The ...
The `||` and `&&` operators in Ruby are closer to [basic process algebra](https://en.wikipedia.org/wiki/Algebra_of_communicating_processes) composition operators than to boolean connectives. The languages just happen to use the same symbols for these two different sorts of operators due to the lack of glyphs on the key...
I have an algorithm with running time that satisfies $$ T(n) \leq n + \frac{1}{n}\sum^{n-1}_{i=0}(T(i) + T(n-i)),$$ and $T(0) = 0$. I was able to show that $T(n) = \mathcal O(n\log n)$ with a leading constant $c > 4$. I modified this algorithm such that the recursion for $T(n)$ now satisfies $$ T(n) \leq 3 \log n ...
I believe the word "combinator" in your first statement of Böhm's theorem means a *closed* λ-term, i.e. one which has no free variables (as is the case [here](https://cs.stackexchange.com/a/68971/154866) for instance); this is consistent with the fact that the statement at the end of your question mentions *closed* nor...
null
C is fastest because there is nothing *preventing* it from being the fastest. A CPU always runs machine language. When writing a "fast" program, your goal is to give the CPU the fastest machine language to accomplish the task. In C, it is usually possible to write something that translates into fast machine langu...
The operand of `if`, `while`, etc. isn't limited to integer types, but will also work with floating-point or pointer types. For a value x of any integer, floating-point, or pointer type, `if(x)` is equivalent to `if ((x) != 0)`, with the literal zero being interpreted as a value of `x`'s type. Making a construct like...
$y$ is a sum of the constants $\log_b\frac{2^k}{2^k-1}$, precomputed to a certain accuracy. These terms are summed until the value of $x$ is exhausted, i.e. (if I am right) the number of bits of $x$. So the total error is the error on the sum, itself bounded by $m$ times the accuracy, for $m$ terms.
Edit: After re-reading the question and wovano's comment I think my answer below misses the point because the suggestion to return the non-zero operand or zero if there isn't any would not be overly complicated or abstract if the operands stayed restricted to scalar types. I let the answer stand because I still think i...
I have found that when drawing two trees having different structures! We can get the same in-order sequence and pre-order sequence. But haven't found if two different binary trees can have an identical post-order sequence.
Can two different binary trees can have identical post-order sequence
|algorithms|trees|binary-trees|
I have found that when drawing two trees having different structures! We can get the same in-order sequence and pre-order sequence. But haven't found if two different binary trees can have an identical post-order sequence. Is it possible?
I have found that when drawing two trees having different structures, we can get the same in-order sequence and pre-order sequence. But I haven't found if two different binary trees can have an identical post-order sequence. Is it possible?
You have missed one important note. The rule is such > For each production $A→α$ of the grammar, do the following: > For each terminal $a$ in $FIRST(A)$, add $A→α;$ to $M[A,a]$ that is we only consider the elements in first set which is contributed by the production $A→α$ which here is $F→\{id\}$ , so ...
You have missed one important note. The rule is such > For each production $A→α$ of the grammar, do the following: > For each terminal $a$ in $FIRST(A)$, add $A→α;$ to $M[A,a]$ that is we only consider the elements in first set which is contributed by the production $A→α$ which here is $F→(E)$ , so for...
The `||` and `&&` operators in Ruby are closer to [basic process algebra](https://en.wikipedia.org/wiki/Algebra_of_communicating_processes) composition operators than to boolean connectives. The languages just happen to use the same symbols for these two different sorts of operators due to the lack of glyphs on the key...
If one defines a "task" as a mapping between possible inputs a program might receive, and the set of possible outputs that would be acceptable for each such input, different languages will be able to process different tasks more or less efficiently. This will be especially true if one recognizes a task X as being a mo...
Some architectures support multiple page sizes. For example x86 supports 4kB, 2MB (512\*4kB) and 1GB (512\*2MB) because of its hierarchical page table design. MIPS supports any power of two within a certain range, because of its software TLB design. An operating system *should* allocate the largest page that it can ...
This is probably a computer science history question. Is there an algorithm which was originally invented to solve a contrived problem but later found practical use?
Is there an algorithm which was originally invented to solve a contrived problem but later found practical use?
|algorithms|history|
null
# Yes If we allow nodes with 1 child to have that child in either position and consider the resulting trees distinct, the smallest such pair of trees has 2 nodes. Tree 1 with traversal [b, a]: ``` a b ``` Tree 2 with traversal [b, a]: ``` a b ``` This is a somewhat unsatisfying answer, b...
null
Consider this version of the halting problem: given an input Turing machine $T$, decide whether $T$ halts on empty input. You can assume that $T$ is a valid description of a TM. This problem is known to be undecidable. My answer in [your other question](https://cs.stackexchange.com/questions/154852/can-you-solve-the...
The images in [Does a simple photograph contain more information than a complex painting? - Signal Processing Stack Exchange](https://dsp.stackexchange.com/questions/41592/does-a-simple-photograph-contain-more-information-than-a-complex-painting) aren't the originals, they have been processed by imgur, are .png files,...