instruction
stringlengths
0
29.8k
⌀
an interesting case study in this area is [Perl](http://en.wikipedia.org/wiki/Perl) vs [Ruby](http://en.wikipedia.org/wiki/Ruby_language) (and [Python](http://en.wikipedia.org/wiki/Python_language)). Perl is a scripting language developed in early 90s that added much capability compared to prior Unix based scripting la...
an interesting case study in this area is [Perl](http://en.wikipedia.org/wiki/Perl) vs [Ruby](http://en.wikipedia.org/wiki/Ruby_language) (and [Python](http://en.wikipedia.org/wiki/Python_language)). Perl is a scripting language developed in early 90s that added much capability compared to prior Unix based scripting la...
Suppose we have a set $A$ of pairs $(a,b)$ such that $a$ and $b$ are real numbers defined in the interval $[c,d]$. Assume no two values are identical. For $(a,b)$, if $a > b$, the range is $[a,d] \cup [c,b]$; otherwise, it is $[a,b]$. What is the most efficient algorithm to find the smallest subset $B \subseteq A$ such...
Finding the minimum subset within a cycle
|algorithms|
null
null
I know that **Translation look aside buffer** is used for address translation in paging to achieve better performance. I came across term called **Look Ahead buffer** in a document which said it implements Temporal locality. I tried searching for **Look Ahead buffer's** but could not get any significant data. ...
Look Ahead buffer vs Translation Look aside buffer
|operating-systems|paging|virtual-memory|
I have a question if I have my k=300 and my loop is look like this : for( int x = 0 ; x<n ; x--){ for(int y=0 ; y<k; y++){ is this still O(n^2)? if no why? Thank you :)
time complexity of Big O
|complexity-theory|time-complexity|
null
Assuming that you meant <code>x++</code> rather than <code>x--</code>, the complexity is $\Theta(nk)$. Since $k = 300$, you can simplify that to $\Theta(n)$. As Ran G. mentions, since $n = O(n^2)$, then your loop is also $O(n^2)$. It's also $O(2^n)$. But the tight analysis is $\Theta(n)$.
Using Kaveh's reduction in [this related question][1], we only have to solve the case where the given intervals cover the entire circle $[c,d]$. Here's an algorithm that almost calculates the optimum, in $O(n\log n)$. Replace each interval $[a,d] \cup [c,b]$ by the two intervals $[a,d],[c,b]$, and now solve the orig...
I do not know the exact definitions of TLBs and look-ahead buffers, but here is what I understand about them. TLBs help make translations from virtual to physical addresses quicker via caching. So, you can see how the TLB is implementing temporal locality (any kind of caching is implementing temporal locality) in so...
null
Very long time ago I attempted to do symbolic differentiations. While my code sufficed to help me solve a particular problem, I got thereby the conviction that implementing a good efficient computer algebra system must be at least as hard as writing a good compiler for a programming language. (Think e.g. of doing integ...
Very long time ago I attempted to do symbolic differentiations. While my code sufficed to help me solve a particular problem, I got thereby the conviction that implementing a good efficient computer algebra system must be at least as hard as writing a good compiler for a programming language. (Think e.g. of doing integ...
I have a question if I have my $k=300$ and my loop is like this : for( int x = 0 ; x<n ; x--){ for(int y=0 ; y<k; y++){ ... } } Is this still $O(n^2)$? If no, why? Thank you :)
Big O time complexity
|time-complexity|landau-notation|
null
null
Studying Quick-Find and Quick-Union heuristic I've found clear that: - with quick find trees and a union based on the size of the trees we can make a union in $T_{am}=O(log(n))$ - with quick find trees and a union based on the rank of the trees we can make a find in $T(n)=O(log(n))$ But I read that using quick...
quick union and heuristic by size
|algorithms|heuristics|
Studying Quick-Find and Quick-Union heuristic I've found clear that: - with quick find trees and a union based on the size of the trees we can make a union in $T_{am}(n)=O(log(n))$ - with quick find trees and a union based on the rank of the trees we can make a find in $T(n)=O(log(n))$ But I read that using qu...
|context-free|formal-grammars|proof-techniques|ambiguity|
Studying Quick-Find and Quick-Union heuristic I've found clear that: - with quick find trees and a union based on the size of the trees we can make a union in $T_{am}(n)=O(log(n))$ - with quick find trees and a union based on the rank of the trees we can make a find in $T(n)=O(log(n))$ But I read that using qu...
Studying Quick-Find and Quick-Union heuristic I've found clear that: - with quick find trees and a union based on the size of the trees we can make a union in $T_{am}(n)=O(\log(n))$ - with quick find trees and a union based on the rank of the trees we can make a find in $T(n)=O(\log(n))$ But I read that using ...
Quick union and heuristic by size
null
Your algorithm is **incorrect**. I assume you know how to compute the suffix array and the LCP array of a string, that is, their efficient implementation. As has been pointed out in the comments, you should try to understand what each component is, and why it works. First of all, is the suffix array ($SA$) of a stri...
**Task**: Design a 2 bit comparator. Input: 2x 2 bit (I take it as 2 2-bit values, let them be unsigned for simplicity) Output: 1 if result input1>input2 is true, 0 otherwise Develop truth table and derive circuits. **The problem**: I'm completely new to this so I have not even a idea where where to look ...
Creating a logical circuit
|logic|circuits|
null
We want to tile $M*M$-square using two types of tiles: $1*1$-square tile and $2*2$-square tile. Let us define a function $f(n)$ that gives the size of largest uniquely tillable square using $n$ $1*1$-squares and any number of $2*2$-squares. Is this function computable? What is the algorithm?
Unique tilings of squares
|computability|
Well, as the problem asks you to make a truth table, you should first make one (this is generally a good idea even if not asked explicitly). For your question, you can say assign two bits to input1, say $a$ and $b$, and two bits to the input2, say $x$ and $y$. Then you might say that if $a = 1$ and $b = 0$, input 1 is ...
**Task**: Design a 2 bit comparator. Input: 2x 2 bit (I take it as 2 2-bit values, let them be unsigned for simplicity) Output: 1 if result input1>input2 is true, 0 otherwise Develop truth table and derive circuits. **The problem**: I'm completely new to this so I have not even a idea where where to look ...
There is a methodology for implementing logical [Combinational circuit][1] suppose your Boolean function is $f(x_1,x_2,...,x_n)=(y_1,y_2,...,y_m)$ in which $x_i,y_i \in \{0,1\}$ 1) First make a [Truth Table][2] 2) Then write each $y_j$ base on $(x_1, x_2,..., x_n)$ using [CNF][3] or [DNF][4] 3) Then use [Qu...
It's known that - $ \forall f(n) \geq log (n) \space NSPACE( f (n)) =coNSPACE( f (n))$ What about cases which $ \forall f(n) < log (n)$ ? Does it not equal or un-known ?
About $ \forall f(n) \geq log (n) \space NSPACE( f (n)) =coNSPACE( f (n))$
|complexity-theory|space-complexity|
I think something like the algorithm you cite should indeed work if a character that is not part of the character set is used as a separator, and the suffix/prefix arrays are built to _exclude_ all strings that contain the separator, probably the intention of the designer. this is basically equivalent to building suffi...
Here's an argument to prove my speculation in comments that no such unique tilings exist for any non-square $n\gt 5$. Firstly, as noted by Sasho in comments, $n$ must be restricted, because no such tilings exist if $n\equiv2$ or $3\pmod 4$. If $n$ is a perfect square $n=k^2$ then obviously the $k\times k$ square is u...
Here's an argument to prove my speculation in comments that no such unique tilings exist for any non-square $n\gt 5$. Firstly, as noted by Sasho in comments, $n$ must be restricted, because no such tilings exist if $n\equiv2$ or $3\pmod 4$. If $n$ is a perfect square $n=k^2$ then obviously the $k\times k$ square is u...
It has been proved that any space bound in **Ω(log n)**, the space hierarchy collapses to the **second level**. The following are the references: N. Immerman "**Nondeterministic space is closed under complementation**". SIAM Journal on Computing, 17:935–938, 1988. R. Szelepcs´enyi "**The method of forced enumer...
It has been shown that the space hierarchy for any sublogarithmic bound in **Ω(log log n)-- o(log n)** is infinite. Also it has been proved that any space bound in **Ω(log n)**, the space hierarchy collapses to the **second level**. The following are the references: N. Immerman "**Nondeterministic space is closed un...
null
[Immerman–Szelepcsényi][1] theorem works under logarithmic reduction. Sublogarithmic space classes has different reductions. The TMs working within **sublogarithmic space cannot even record the the length of the input**. It has been shown that the space hierarchy for any sublogarithmic bound in **Ω(log log n)-- o(log ...
Look at the coin change problem. Solutions are known which will give all results. If you have a problem with it, I can provide some code. See http://www.algorithmist.com/index.php/Coin_Change for example
I've got confusion in the fallowing section of a book .Here we taking about FCFS Scheduling .I feel that calculation table is incorrect in the book .Because at time 7 P3 got completed ,it's turnaround time should be 7-3 because third process arrival time is 3 so why they took 1? remember turn around time = t(process co...
process scheduling confusion
|scheduling|
The dynamic programming algorithm can be adapted to give all solutions. You create a table $A$. The cell $A_{k,w}$ contains enough information to enumerate all subsets of $\{w_1,\ldots,w_k\}$ summing to $w$. When $k = 0$, this is trivial. Given $A_{k-1,\cdot}$, $A_{k,w}$ points at the two cells $A_{k-1,w},A_{k-1,w-w_k}...
Does $NSPACE( f (n)) =coNSPACE( f (n))$ hold for $ f(n) \geq log (n) $?
It's known that for $f(n) \geq \log n$, $\mathsf{NSPACE}(f(n)) = \mathsf{coNSPACE}(f(n))$. What if $f(n)<\log n$? Are they also equal?
null
I'm currently reading a book in algorithms and complexity. At the moment I', reading about computable and non-computable functions, and my book states that there are many more functions that are non-computable than computable, in fact the majority is non-computable it says. In some sense I can intuitively accept that b...
More non-computable functions than computable ones
|computability|
The are countably many Turing machines (algorithms). Therefore there are only countably many computable functions. In other words, there is a correspondence between computable functions and the set of natural numbers $\mathbb{N}$. On the other hand, the number of functions uncountable. In fact the number of function...
I'm currently reading a book in algorithms and complexity. At the moment I'm, reading about computable and non-computable functions, and my book states that there are many more functions that are non-computable than computable, in fact the majority is non-computable it says. In some sense I can intuitively accept that ...
Why are there more non-computable functions than computable ones?
|computability|turing-machines|
This [page][1] about Knuth-Moriss-Pratt Algorithm compared to Boyer-Moore describes a possible case where BM suffers from small skip distance while KMP could perform better. I'm looking for a good example(text,pattern) that can clearly demonstrate this case. [1]: http://www.cs.utexas.edu/~moore/best-ideas/str...
An example where Knuth-Morris-Pratt Algorithm is slower than BM?
|algorithms|substrings|matching|
null
An example where Knuth-Morris-Pratt Algorithm is faster than BM?
The Floyd-Warshall algorithm is defined for k from 1 to |V| for i from 1 to |V| for j from 1 to |V| if dist[i][k] + dist[k][j] < dist[i][j] then dist[i][j] ← dist[i][k] + dist[k][j] next[i][j] ← k Why doesn't it work if I sim...
Why don't Floyd-Warshall algorithm work if I put k in the innermost loop
|graphs|shortest-path|
I've got a confusion in the following section of a book. Here we taking about FCFS Scheduling. I feel that calculation table is incorrect in the book. Because P3 got completed at time 7, it's turnaround time should be 7-3 because third process arrival time is 3 so why they take 1? Remember turn around time = t(process ...
Process scheduling confusion
null
I have a question about the regular operation 'star' in computational theory. IF A is { good , bad } A* = { epsilon , good, bad , goodgood, goodbad, badgood , ..... } what is the exact "regular operation" means then ? Can we use * operation only for regular language ? I don`t think so. L = {0^n1^n | n >=...
STAR operation in CS theory
|automata|
The operation you refer to (Kleene star) is an operation on _languages_ (sets of strings). The language doesn't have to be regular at all to apply it. It's relation to regular languages is that it is one of the operations (with concatenatin and union) that define regular languages starting from the empty language, the ...
The $^*$ is an operator that takes a language (not only regular languages) $L$ and produces a new language $L^*$ called the Kleene closure of $L$. Definition of $L^*$ == $$L^*=\bigcup_{i\in \mathbb{N}_0}L^i=L^0\cup L^1\cup L^2\dots$$ Where, $L^0=\{\epsilon\}$ and $L^n=LL^{n-1}$ for $n\gt0$
You can certainly apply the *[Kleene star][1]* operation on any set, however the *regular languages* are _closed_ under taking the Kleene star. This means that if a language $L$ is regular, so is $L^*$. [1]: http://en.wikipedia.org/wiki/Kleene_star
The $^*$ is an operator that takes a language (not only regular languages) $L$ and produces a new language $L^*$ called the Kleene closure of $L$. A language is a set of strings over a finite alphabet (alphabets are commonly denoted by $\Sigma$). Definition of $L^*$ == $$L^*=\bigcup_{i\in \mathbb{N}_0}L^i=L^0\cu...
The Floyd-Warshall algorithm is defined for k from 1 to |V| for i from 1 to |V| for j from 1 to |V| if dist[i][k] + dist[k][j] < dist[i][j] then dist[i][j] ← dist[i][k] + dist[k][j] Why doesn't it work if I simply use for i from 1 to...
I have a question about the regular operation 'star' in computational theory. IF $A$ is $\{ good , bad \}$ then $A^* = \{ \varepsilon , good, bad , goodgood, goodbad, badgood , \dots \}$ What is the exact "regular operation" mean then ? Can we use $^*$ operation only for regular language ? I don't think so....
Star operation in CS theory
|formal-languages|
This [page][1] about Knuth-Moriss-Pratt Algorithm compared to Boyer-Moore describes a possible case where the Boyer-Moore algorithm suffers from small skip distance while KMP could perform better. I'm looking for a good example (text,pattern) that can clearly demonstrate this case. [1]: http://www.cs.utexas...
An example where Knuth-Morris-Pratt Algorithm is faster than Boyer-Moore?
|algorithms|graphs|shortest-path|
I molded my problem as the following game (it is a [congestion game][1] with varying price): $N$ players share resources $E$, $S_i$ is the strategy space of player $i$ which is in $2^E$ (where $2^E$ is the power set of resources). $P_e^i$ is the price of resource $e \in E$ considering player $i$. **The price o...
Congestion Game with Varying Price
The Floyd-Warshall algorithm is defined as follows: for k from 1 to |V| for i from 1 to |V| for j from 1 to |V| if dist[i][k] + dist[k][j] < dist[i][j] then dist[i][j] ← dist[i][k] + dist[k][j] Why doesn't it work if I simply use for...