instruction
stringlengths
0
29.8k
⌀
First of all, the IEEE 745 16-bit format has: - 1 bit for the sign. - 5 bits (not 4) for the **biased** exponent. The bias is $15$. - 10 bits for the mantissa. The leading $1$ is **implicit** (not explicit). The calculation is incorrect since $(29.375)_2 = (11101.011)_2 = (1.1101011)_2 \cdot 2^4$ (and not $2^3$...
null
First of all, the IEEE 745 16-bit format has: - 1 bit for the sign. - 5 bits (not 4) for the **biased** exponent. The bias is $15$. - 10 bits for the mantissa. The leading $1$ is **implicit** (not explicit). The calculation is incorrect since $(29.375)_2 = (11101.011)_2 = (1.1101011)_2 \cdot 2^4$ (and not $2^3$...
null
null
The following question was asked by our professor in exam:- Given a system with 4GB virtual address space and page size 4KB and total physical RAM of size 8KB. What will be the size of the page Table if each entry consumes 4 Bytes. Also the system allows upto 1024 processes to run concurrently. The answer is:- ...
Size of page Table entry
|operating-systems|paging|
Your strings can start with any number of 0's or 10's. These don't contain any 110. So we start with $(0 | 10)^*$. The remainder of the input mustn't contain any zeroes: If the remainder starts with no 1 or one 1, then that cannot be followed by a zero, because 0 or 10 would be part of $(0 | 10)^*$. If there are $n...
Your strings can start with any number of 0's or 10's. These don't contain any 110. So we start with $(0 | 10)^*$. The remainder of the input mustn't contain any zeroes: If the remainder starts with no 1 or one 1, then that cannot be followed by a zero, because 0 or 10 would be part of $(0 | 10)^*$. If there are $n...
null
null
In Skeina's book *Algorithm Design Manual, 3rd Edition*, it is claimed on page 45 that $$ mn - m^2 + m \in \Omega(mn) $$ where $m,n \geq 0$ and $m \leq n$. I claim that this is in fact false, with the following proof. Toward a contradiction, suppose otherwise. Then $$mn-m^2 + m \geq cmn$$ where $m,n > N_{0}$ fo...
Possible Mistake in Skiena's Algorithm Design Manual
|algorithms|algorithm-analysis|asymptotics|big-o-notation|
You are totally right, though I think there is an easier proof: if $m = n$, then $mn-m^2 +m= m\notin \Omega(m^2)$. However, since the analysis is done when searching for a worst case, you could just add a condition $2m\leqslant n$ for the analysis to be correct. But there is indeed a mistake in the analysis by Sk...
The thing that confuses me here is that i've seen a similar example where $L=\{a^nb^m : 2m\leq n\leq 4m\}$ where the CFG was straight forward: $$ S\rightarrow aSbb\\ S\rightarrow aSbbb\\S\rightarrow aSbbbb\\S\rightarrow \epsilon $$ however, in this example I cant get my mind out of the "just go for the simple app...
Context free grammar for $L=\{a^nb^m : 2m<n<4m\}$
|context-free|formal-grammars|
No. The grammar you propose is not correct. For example it generates $\varepsilon$, which is not in the language. In fact, no word generated by your grammar is in the language. To see this notice that the generated words have at least as many $b$s than $a$s, yet all words in the language have more $a$s than $b$s.
Yes. It should be 4 only. $4\times n+1 \leqslant 20 $ Maximum possible value of n is 4
We note that a process P i can be prevented from entering the critical section only if it is stuck in the while loop with the condition flag[j] == true and turn == j ; this loop is the only one possible. If P j is not ready to enter the critical section, then flag[j] == false , and P i can enter its critical section. I...
The thing that confuses me here is that i've seen a similar example where $L=\{a^nb^m : 2m\leq n\leq 4m\}$ where the CFG was straight forward: $$ S\rightarrow aSbb\\ S\rightarrow aSbbb\\S\rightarrow aSbbbb\\S\rightarrow \epsilon $$ however, in this example I cant get my mind out of the "just go for the simple app...
The problem with your (new) solution is that you force $n$ to be equal to $3m$. That means that your grammar generates words that are in $L = \{a^nb^m\mid 2m < n < 4m\}$, but words in $L$ like $aaaaabb$ cannot be generated by your grammar. You can use the example grammar to construct the wanted grammar by noting the...
Essentially in your example: The correct sequence of description would be - 1. Reader 1 arrives 2. Reader 1 starts reading 3. Writer 1 arrives and starts waiting 4. Reader 1 completes 4. Writer 1 starts writing 5. Reader 2 arrives and starts waiting So, here is no contradiction.
In Skiena's book *Algorithm Design Manual, 3rd Edition*, it is claimed on page 45 that $$ mn - m^2 + m \in \Omega(mn) $$ where $m,n \geq 0$ and $m \leq n$. I claim that this is in fact false, with the following proof. Toward a contradiction, suppose otherwise. Then $$mn-m^2 + m \geq cmn$$ where $m,n > N_{0}$ fo...
null
It will work but generally we cant take the assumption that N is known beforehand.
{"OriginalQuestionIds":[19176],"Voters":[{"Id":755,"DisplayName":"D.W.","BindingReason":{"GoldTagBadge":"complexity-theory"}}]}
Starvation Free Solution assuming FIFO Waiting Queue ```c wait(mutex); wait(Tiger_Mutex); tiger_count++; if(tiger_count==1); wait(pond) signal(mutex); signal(Tiger_Mutex); drink_water(); wait(Tiger_Mutex); tiger_count--; if(tiger_count==0) signal(pond) signal(Tiger_Mutex); ``` All mutex initiali...
Let $T$ be a rooted, finitely branching tree, with values from $A$ in its nodes; $T(j)$ is the value of a node called $j$. $A$ is a commutative monoid. The "bottom-up scan tree" of $T$ is a rooted tree $T^\ast$ isomorphic to $T$, such that if $j$ is a leaf of $T$, $T(j)=T^\ast(j)$, and otherwise $T^\ast(j) = \sum_{i\le...
Parallel prefix sum/scan on trees
|trees|parallel-computing|
null
The progress condition of critical section problem is not satisfied here.
OS would generally trap these type of process and core would be dumped.
Addition is not a good example for this because it does need both of its inputs. Laziness comes into play for functions whose output may not depend on all of the input. An example of laziness that can be found in virtually all mainstream programming languages is the boolean operator `&&` (and its sibling `||`). Conv...
public class SortAlgorithm { public static void sort(int[] A) { quickLevel(A, 0, A.length - 1); } private static void mergeLevel(int[] A, int l, int r) { if (l < r) { int m = (l + r) / 2; quickLevel(A, l, m); quickLevel(A, m + 1, r); ...
what is the complexity of this problem
|algorithms|recurrence-relation|recursion|big-o-notation|
public class SortAlgorithm { public static void sort(int[] A) { quickLevel(A, 0, A.length - 1); } private static void mergeLevel(int[] A, int l, int r) { if (l < r) { int m = (l + r) / 2; quickLevel(A, l, m); quickLevel(A, m + 1, r); ...
null
null
null
> You have $n$ events on your calendar, defined as intervals with a start time $s_i$ and a finish time $f_i$. The events might overlap, and you want to attend all the events, so you are going to create $k$ clones of yourself to achieve this. You want to minimize the number of clones you need, $k$. A clone can attend a ...
I was just reading [this][1] question regarding the difference between **environment** and **memory**. However, the textbook in question, *Essentials of Programming Languages*, third edition, by Friedman and Wand, also has chapter **4 State**, which, as it says, discussed the concept of **state**. But, as far as I can ...
What is the precise difference between state and environment and memory?
|programming-languages|static-analysis|
How to find a "short" walk that visits all vertices of a strongly connected directed graph
null
Very informally: An **environment** is a set of pairs (variable+value) that are accessible to a particular object/process during its execution. A **memory** is a set of "locations" in which an object/process can store information. Usually a location is associated with a variable and the value of the variable is...
Very informally: An **environment** is a set of pairs (variable+value) that are accessible to a particular object/process during its execution. A **memory** is a set of "locations" in which an object/process can read/store information. Usually a location is associated with a variable and the value of the variab...
Very informally: An **environment** is a set of pairs (variable+value) that are accessible to a particular object/process during its execution. A **memory** is a set of "locations" in which an object/process can read/store information. Usually a location is associated with a variable and the value of the variab...
null
It took me a while to figure out what this circuit does: It takes 5 inputs and produces 3 outputs. (So why is it called a 4-2 compressor and not a 5-3 compressor?) One output is the sum with a value of 1, and two carry bits with a value of 2. If the sum of the inputs is 2 or 3, one of the two carries must be set, and o...
public class SortAlgorithm { public static void sort(int[] A) { quickLevel(A, 0, A.length - 1); } private static void mergeLevel(int[] A, int l, int r) { if (l < r) { int m = (l + r) / 2; quickLevel(A, l, m); quickLevel(A, m + 1, r); ...
Very informally: An **environment** is a set of pairs (variable+value) that are accessible to a particular object/process during its execution. A **memory** is a set of "locations" in which an object/process can read/store information. Usually a location is associated with a variable and the value of the variab...
The language is: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/kDA3w.gif I'm trying to use reduction $\overline{HP} \leq L$, but I just can't think of a way to do so. Any help would be appreciated!
Is that a TM is not in RE?
|turing-machines|reductions|halting-problem|
(This may just be a terminology clarification question.) [Wikipedia says][1] > A language usually has at least one implementation in the form of a compiler or interpreter, allowing programs written in the language to be executed. And reading the [page on programming language implementations][2]: > In compu...
Is a language *engine* the same as a language *implementation*?
|compilers|interpreters|
Let $M(n)$ be the runtime of mergeLevel on an input of size $n$, and let $Q$ be the runtime of quickLevel on an input of size $n$. By inspecting the code, we see that $M(n) = 2Q(\frac{n}{2}) + n$ and $Q(n) \leq n + \max_{1 \leq i < n} M(n - i) + M(i)$. We can then just substitute, and henceforth ignore $M$: $$Q(n...
Is that language is not in RE?
The machine would go in an infinite loop if there is at least one state that it visits an infinite number of times (By pigeon-hole principle). **Hint:** Dovetailing
**Hint**: given a Turing machine $M$ and a word $w$ over $M$'s alphabet, consider a machine $T$, that on the empty word simulates the run of $M$ on $w$. Can you force $T$ to visit a state infinitly often if the simulation does not halt? Note that ofcourse there is such a state but we do not know it in advacnce to outpu...
I'm trying to use reduction $\overline{HP} \leq L$, but I just can't think of a way to do so. Any help would be appreciated!
Is $\{\langle \langle M\rangle, q\rangle\mid M(\varepsilon)$ enters state $q$ infinite times$\}$ not in RE?
what is the complexity of this sorting algorithm?
Maybe _**hypnosis**_, as used by Raymond Chen to describe a closely related set of bugs? > It’s like saying, “I am a bad guy from a 1960’s spy movie. I have successfully hypnotized the victim into obeying all of my commands, while nevertheless behaving perfectly normally. I tell the victim to go to the bank, withdra...
**Hint**: given a Turing machine $M$ and a word $w$ over $M$'s alphabet, consider a machine $T$, that on the empty word simulates the run of $M$ on $w$. Can you force $T$ to visit a state infinitly often if the simulation does not halt? Note that ofcourse there is such a state but we do not know it in advacnce to outpu...
I got it. Using reduction $\overline{HP} \leq L$ with $f\left ( \left ( \left \langle M \right \rangle ,x \right ) \right ) = \left ( \left \langle M_x \right \rangle ,q\right )$ where $M_x$ is a TM which simulates M on input x, but between every two steps, it goes into state q. If $M_x$ halts, reject. This means...
I believe you can consider state and environment to be the same thing. The difference is mostly when writing logical deductions. The environment is the context that makes a given proposition true and may be a just a part of the global state. What memory introduces is **aliasing**; $A[i] = x$ may be falsified by a prece...
null
I am trying to understand various types of virtualization techniques. The concept of Hardware virtualization/Virtual machine was simple enough. However, I am struggling to understand the concept of storage virtualization. One definition I have found >grouping the physical storage from multiple network storage dev...
How does storage virtualization help?
|storage|
I am interested in the following algorithmic problem: Given a strongly connected directed graph $G$, I want a "short" (see below for what I mean by short) walk that starts with an arbitrary vertex $s$ and contains all vertices of $G$. Deciding if such a walk can be a path (i.e. no repeated vertices) is a well known...
null
A Turing Machine can be converted into a Turing Machine that has a specific input coded into it's description. This Turing Machine can then be run on empty input. Can we do the same for PDAs or DFAs? I am familiar with models of computation such as Conway's Game of Life where the rules are fixed and the entire compu...
Hardwiring input in DFAs and PDAs
|finite-automata|pushdown-automata|computation-models|
Trying to improve my algorithms I bumped into a problem which I can summarise like this: > You are given a list of enemy bases you want to attack. Each base $i$ > requires a minimum number of soldiers $s_i$ to be conquered, will take out a > certain number $b_i$ of the soldiers who attack and will require a certai...
Finding optimal sequence of attacks to minimize number of soldiers needed
|algorithms|optimization|greedy-algorithms|
Yes. You can easily build a PDA or DFA that immediately halts and rejects (regardless of its input); and you can easily build one that immediately halts and accepts (regardless of its input). Those are the only two cases you need, so the answer to your question is yes.
Just a quick question about regular languages and which NFAs accept them: If I were to draw an NFA that accepts a particular regular language, does that mean the NFA can only accept strings in that language or can the NFA accept every string in that language and some extra ones? For example, for the regular languag...
NFAs that accept a regular language
|regular-languages|regular-expressions|nondeterminism|
I've never heard of the phrase "language engine" before, so I don't think you need to worry about knowing that phrase. Perhaps it is used in certain communities, such as browsers. From context, it sounds like a Javascript engine is a subsystem of a browser that provides a Javascript interpreter/JIT plus interfaces to...
The language of an NFA $A$, denoted $L(A)$, is the set of words $w$ such that there is an accepting run of $A$ on $w$. Hence, when we claim that an NFA $A$ recognizes a language $L$, we mean that $L(A) = L$, and by that we mean equality of sets, that is, we have two sided containment: (1) $L(A)\subseteq L$: every w...
We have $16$ words of given length, let's say $W_1,...,W_{16}$ and I want to make an one dimensional matrix that will contain all the possible sums of $W_i$'s, for example: $W_1,W_2,...,W_{16}$ $W_1+W_2,W_1+W_3,...,W_1+W_{16}$ $W_2+W_3,...,W_2+W_{16}$ and so on, all the pair sums... then all the thre...
null
Good evening! I'm actually doing an internship at the Archives Nationales of France and I encountered a situation I wanted to solve using graphs... # I. The dusty situation We want to optimize the arrangement of books of my library according to their height in order to minimize their archive cost. The height and ...
null
|correctness-proof|
null
I was reading CLRS about BFS and DFS, and the algorithms presented therein, which I take to be somewhat standard, construct a forest with DFS that includes all the nodes, whereas BFS only constructs a tree from a chosen node $s$, and leaves out all the other nodes that are not reachable from $s$. It seems BFS can be...
null