id
int64
1
141k
title
stringlengths
15
150
body
stringlengths
43
35.6k
tags
stringlengths
1
118
label
int64
0
1
2
Does the 'difference' operation add expressiveness to a query language that already includes 'join'?
<p>The set difference operator (e.g., <code>EXCEPT</code> in some SQL variants) is one of the many fundamental operators of relational algebra. However, there are some databases that do not support the set difference operator directly, but which support <code>LEFT JOIN</code> (a kind of outer join), and in practice thi...
database theory relational algebra finite model theory
1
3
Why is quicksort better than other sorting algorithms in practice?
<p>In a standard algorithms course we are taught that <strong>quicksort</strong> is <span class="math-container">$O(n \log n)$</span> on average and <span class="math-container">$O(n^2)$</span> in the worst case. At the same time, other sorting algorithms are studied which are <span class="math-container">$O(n \log n)$...
algorithms sorting
1
5
Does cooperative scheduling suspend processes when they perform an I/O operation?
<p>Many operating systems references say that with cooperative (as opposed to preemptive) multitasking, a process keeps the CPU until it explicitly voluntarily suspends itself. If a running process performs an I/O request that cannot be immediately satisfied (e.g., requests a key stroke that is not yet available), doe...
operating systems process scheduling
1
7
Which method is preferred for storing large geometric objects in a quadtree?
<p>When placing geometric objects in a quadtree (or octree), you can place objects that are larger than a single node in a few ways:</p>&#xA;&#xA;<ol>&#xA;<li>Placing the object's reference in every leaf for which it is contained</li>&#xA;<li>Placing the object's reference in the deepest node for which it is fully cont...
graphics data structures computational geometry
0
11
Generating Combinations from a set of pairs without repetition of elements
<p>I have a set of pairs. Each pair is of the form (x,y) such that x,y belong to integers from the range <code>[0,n)</code>.</p>&#xA;&#xA;<p>So, if the n is 4, then I have the following pairs:</p>&#xA;&#xA;<pre><code>(0,1) (0,2) (0,3)&#xA;(1,2) (1,3) &#xA;(2,3) &#xA;</code></pre>&#xA;&#xA;<p>I already have the pairs. N...
algorithms
1
14
What is the significance of context-sensitive (Type 1) languages?
<p>Seeing that in the <a href="http://en.wikipedia.org/wiki/Chomsky_hierarchy">Chomsky Hierarchy</a> Type 3 languages can be recognised by a state machine with no external memory (i.e., a finite automaton), Type 2 by a state machine with a <em>single</em> stack (i.e. a push-down automaton) and Type 0 by a state machine...
formal languages applied theory computability automata formal grammars
1
20
Evaluating the average time complexity of a given bubblesort algorithm.
<p>Considering this pseudo-code of a bubblesort:</p>&#xA;&#xA;<pre><code>FOR i := 0 TO arraylength(list) STEP 1 &#xA; switched := false&#xA; FOR j := 0 TO arraylength(list)-(i+1) STEP 1&#xA; IF list[j] &gt; list[j + 1] THEN&#xA; switch(list,j,j+1)&#xA; switched := true&#xA; EN...
algorithms time complexity sorting average case
1
27
Clever memory management with constant time operations?
<p>Let's consider a memory segment (whose size can grow or shrink, like a file, when needed) on which you can perform two basic memory allocation operations involving fixed size blocks:</p>&#xA;&#xA;<ul>&#xA;<li>allocation of one block</li>&#xA;<li>freeing a previously allocated block which is not used anymore.</li>&#...
time complexity memory allocation operating systems
1
33
Rice's theorem for non-semantic properties
<p><a href="http://en.wikipedia.org/wiki/Rice%27s_theorem">Rice's theorem</a> tell us that the only <em>semantic</em> properties of <a href="http://en.wikipedia.org/wiki/Turing_machines">Turing Machines</a> (i.e. the properties of the function computed by the machine) that we can decide are the two trivial properties (...
computability undecidability
1
43
Language theoretic comparison of LL and LR grammars
<p>People often say that <a href="https://en.wikipedia.org/wiki/LR_parser">LR(k)</a> parsers are more powerful than <a href="https://en.wikipedia.org/wiki/LL_parser">LL(k)</a> parsers. These statements are vague most of the time; in particular, should we compare the classes for a fixed $k$ or the union over all $k$? So...
formal languages formal grammars parsers reference question
1
57
How does one know which notation of time complexity analysis to use?
<p>In most introductory algorithm classes, notations like $O$ (Big O) and $\Theta$ are introduced, and a student would typically learn to use one of these to find the time complexity.</p>&#xA;&#xA;<p>However, there are other notations, such as $o$, $\Omega$ and $\omega$. Are there any specific scenarios where one notat...
algorithms terminology asymptotics landau notation reference question
1
62
Characterization of lambda-terms that have union types
<p>Many textbooks cover intersection types in the lambda-calculus. The typing rules for intersection can be defined as follows (on top of the simply typed lambda-calculus with subtyping):</p>&#xA;&#xA;<p>$$&#xD;&#xA;\dfrac{\Gamma \vdash M : T_1 \quad \Gamma \vdash M : T_2}&#xD;&#xA; {\Gamma \vdash M : T_1 \wedge T...
lambda calculus type theory logic
1
72
Random Sudoku generator
<p>I want to generate a completely random <a href="http://en.wikipedia.org/wiki/Sudoku">Sudoku</a>.</p>&#xA;&#xA;<p>Define a Sudoku grid as a $9\times9$ grid of integers between $1$ and $9$ where some elements can be omitted. A grid is a valid puzzle if there is a <strong>unique</strong> way to complete it to match the...
algorithms randomness sudoku
0
73
Which kind of branch prediction is more important?
<p>I have observed that there are two different types of states in branch prediction.</p>&#xA;&#xA;<ol>&#xA;<li><p>In superscalar execution, where the branch prediction is very important, and it is mainly in execution delay rather than fetch delay.</p></li>&#xA;<li><p>In the instruction pipeline, where the fetching is ...
cpu pipelines computer architecture
1
74
Is Smoothed Analysis used outside academia?
<p>Did the <a href="http://en.wikipedia.org/wiki/Smoothed_analysis">smoothed analysis</a> find its way into main stream analysis of algorithms? Is it common for algorithm designers to apply smoothed analysis to their algorithms?</p>&#xA;
algorithms complexity theory algorithm analysis
1
75
Time spent on requirement and its effect on project success and development time
<p>Is there any evidence suggesting that time spent on writing up, or thinking about the requirements will have any effect on the development time? Study done by Standish (1995) suggests that incomplete requirements partially (13.1%) contributed to the failure of the projects. Are there any studies done which show that...
software engineering
0
78
Natural candidates for the hierarchy inside NPI
<p>Let's assume that $\mathsf{P} \neq \mathsf{NP}$. $\mathsf{NPI}$ is the class of problems in $\mathsf{NP}$ which are neither in $\mathsf{P}$ nor in $\mathsf{NP}$-hard. You can find a list of problems conjectured to be $\mathsf{NPI}$ <a href="https://cstheory.stackexchange.com/questions/79/problems-between-p-and-npc/"...
complexity theory np hard
0
81
Applying the graph mining algorithm Leap Search in an unlabeled setting
<p>I am reading <a href="http://www.google.ch/url?sa=t&amp;rct=j&amp;q=leap%20search&amp;source=web&amp;cd=5&amp;ved=0CE8QFjAE&amp;url=http://dl.acm.org/ft_gateway.cfm?id=1376662&amp;type=pdf&amp;ei=sSVXT569JYjkiAL2hLyiCw&amp;usg=AFQjCNEOkxyk31CeifLNr72Cv_it7IATbg&amp;cad=rja">Mining Significant Graph Patterns by Leap ...
data mining
0
102
Is there any nongeneral CFG parsing algorithm that recognises EPAL?
<p>EPAL, the language of even palindromes, is defined as the language generated by the following unambiguous context-free grammar:</p>&#xA;<blockquote>&#xA;<p><span class="math-container">$S \rightarrow a a$</span></p>&#xA;<p><span class="math-container">$S \rightarrow b b$</span></p>&#xA;<p><span class="math-container...
formal languages formal grammars parsers
1
103
Clock synchronization in a network with asymmetric delays
<p>Assume a computer has a precise clock which is not initialized. That is, the time on the computer's clock is the real time plus some constant offset. The computer has a network connection and we want to use that connection to determine the constant offset $B$.</p>&#xA;&#xA;<p>The simple method is that the computer s...
clocks distributed systems computer networks
0
104
Recursive definitions over an inductive type with nested components
<p>Consider an inductive type which has some recursive occurrences in a nested, but strictly positive location. For example, trees with finite branching with nodes using a generic list data structure to store the children.</p>&#xA;&#xA;<pre><code>Inductive LTree : Set := Node : list LTree -&gt; LTree.&#xA;</code></pre>...
logic coq type theory recursion proof assistants
0
105
Algorithm to test whether a binary tree is a search tree and count complete branches
<p>I need to create a recursive algorithm to see if a binary tree is a binary search tree as well as count how many complete branches are there (a parent node with both left and right children nodes) with an assumed global counting variable. This is an assignment for my data structures class. </p>&#xA;&#xA;<p>So far I ...
algorithms recursion trees
1
108
Equivalence of Büchi automata and linear $\mu$-calculus
<p>It's a known fact that every LTL formula can be expressed by a Büchi $\omega$-automaton. But, apparently, Büchi automata are a more powerful, expressive model. I've heard somewhere that Büchi automata are equivalent to linear-time $\mu$-calculus (that is, $\mu$-calculus with usual fixpoints and only one temporal ope...
logic automata formal methods linear temporal logic buchi automata
0
109
Are there inherently ambiguous and deterministic context-free languages?
<p>Let us call a context-free language deterministic if and only if it can be accepted by a deterministic push-down automaton, and nondeterministic otherwise.</p>&#xA;&#xA;<p>Let us call a context-free language inherently ambiguous if and only if all context-free grammars which generate the language are ambiguous, and ...
formal languages automata formal grammars pushdown automata
1
110
Determining capabilities of a min-heap (or other exotic) state machines
<p><em>See the end of this post for some clarification on the definition(s) of min-heap automata.</em></p>&#xA;&#xA;<p>One can imagine using a variety of data structures for storing information for use by state machines. For instance, push-down automata store information in a stack, and Turing machines use a tape. Stat...
formal languages automata
1
118
Are there improvements on Dana Angluin's algorithm for learning regular sets
<p>In her 1987 seminal paper Dana Angluin presents a polynomial time algorithm for learning a DFA from membership queries and theory queries (counterexamples to a proposed DFA).</p>&#xA;<p>She shows that if you are trying to learn a minimal DFA with <span class="math-container">$n$</span> states, and your largest count...
algorithms learning theory machine learning
1
119
How fundamental are matroids and greedoids in algorithm design?
<p>Initially, <a href="http://en.wikipedia.org/wiki/Matroid" rel="nofollow noreferrer">matroids</a> were introduced to generalize the notions of linear independence of a collection of subsets $E$ over some ground set $I$. Certain problems that contain this structure permit greedy algorithms to find optimal solutions. T...
algorithms optimization combinatorics greedy algorithms matroids
1
122
What Is The Complexity of Implementing a Particle Filter?
<p>In a <a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=4S-sx5_cmLU#!" rel="noreferrer">video</a> discussing the merits of <a href="http://en.wikipedia.org/wiki/Particle_filter" rel="noreferrer">particle filters</a> for localization, it was implied that there is some ambiguity about the complexity c...
computational geometry knowledge representation reasoning statistics
1
125
How to define quantum Turing machines?
<p>In quantum computation, what is the equivalent model of a Turing machine? &#xA;It is quite clear to me how quantum <strong>circuits</strong> can be constructed out of quantum gates, but how can we define a quantum Turing machine (QTM) that can actually benefit from quantum effects, namely, perform on high-dimensiona...
quantum computing turing machines computation models
1
129
Do subqueries add expressive power to SQL queries?
<p>Does SQL need subqueries?</p>&#xA;&#xA;<p>Imagine a sufficiently generalized implementation of the structured query language for relation databases. Since the structure of the canonical SQL <code>SELECT</code> statement is actually pretty important for this to make sense, I don't appeal directly to relational algeb...
database theory relational algebra
1
130
What are the conditions for a NFA for its equivalent DFA to be maximal in size?
<p>We know that DFAs are equivalent to NFAs in expressiveness power; there is also a known algorithm for converting NFAs to DFAs (unfortunately I do now know the inventor of that algorithm), which in worst case gives us $2^S$ states, if our NFA had $S$ states.</p>&#xA;&#xA;<p>My question is: what is determining the wor...
formal languages automata regular languages finite automata nondeterminism
1
134
Analyzing load balancing schemes to minimize overall execution time
<p>Suppose that a certain parallel application uses a master-slave design to process a large number of workloads. Each workload takes some number of cycles to complete; the number of cycles any given workload will take is given by a known random variable $X$. Assume that there are $n$ such workloads and $m$ equivalent ...
scheduling distributed systems parallel computing
1
135
Extension of SQL capturing $\mathsf{P}$
<p>According to <a href="http://books.google.ca/books?id=kWSZ0OWnupkC&amp;pg=PA224#v=onepage&amp;q&amp;f=false">Immerman</a>, the complexity class associated with <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> queries is exactly the class of <em>safe queries</em> in $\mathsf{Q(FO(COUNT))}$ (first-order queries plus...
database theory complexity theory finite model theory descriptive complexity
0
138
Natural occurrences of monads that make use of the category-theoretical framework
<p>Today, a talk by Henning Kerstan ("Trace Semantics for Probabilistic Transition Systems") confronted me with category theory for the first time. He has built a theoretical framework for describing probablistic transition systems and their behaviour in a general way, i.e. with uncountably infinite state sets and diff...
applied theory category theory
1
143
Is this finite graph problem decidable? What factors make a problem decidable?
<p>I want to know if the following problem is decidable and how to find out. Every problem I see I can say "yes" or "no" to it, so are most problems and algorithms decidable except a few (which is provided <a href="http://en.wikipedia.org/wiki/List_of_undecidable_problems">here</a>)?</p>&#xA;&#xA;<blockquote>&#xA; <p>...
algorithms computability graphs undecidability
1
146
Equivalence of Kolmogorov-Complexity definitions
<p>There are many ways to define the <a href="https://en.wikipedia.org/wiki/Kolmogorov_complexity">Kolmogorov-Complexity</a>, and usually, all these definitions they are equivalent up to an additive constant. That is if $K_1$ and $K_2$ are kolmogorov complexity functions (defined via different languages or models), the...
computability kolmogorov complexity
1
148
Type-checking algorithms
<p>I am starting a personal bibliographic research on type-checking algorithms and want some tips. What are the most commonly used type-checking algorithms, strategies and general techniques?</p>&#xA;&#xA;<p>I am particularly interested in complex type-checking algorithms that were implemented in widely known strongly ...
algorithms programming languages reference request type checking
1
149
Analysis of and references for Koch-snowflake-like (and other exotic) network topologies
<p>In computer networking and high-performance cluster computer design, network topology refers to the design of the way in which nodes are connected by links to form a communication network. Common network topologies include the mesh, torus, ring, star, tree, etc. These topologies can be studied analytically to determ...
computer networks network topology
0
151
How to determine if a database schema violates one of the less known normal forms?
<p>In database normalization, 1NF (no multivalued attributes), 2NF (all non-PK attributes depending only on PK attributes) and 3NF (all non-PK attributes depending on all of the PK attributes) are widely known. The 4NF (no part of the PK depending on other part of the PK) is less known, but still reasonably known.</p>&...
database theory databases
0
154
Is there an equivalent of van Emde Boas trees for ropes?
<p>Someone I know is planning on implementing a text editor in the near future, which prompted me to think about what kind of data structures are fast for a text editor. The most used structures are apparently <a href="http://en.wikipedia.org/wiki/Rope_%28computer_science%29">ropes</a> or <a href="http://en.wikipedia.o...
data structures
1
155
Ratio of decidable problems
<p>Consider decision problems stated in some “reasonable” formal language. Let's say formulae in higher-order Peano arithmetic with one free variable as a frame of reference, but I'm equally interested in other models of computation: Diophantine equations, word problems from rewriting rules using Turing machines, etc. ...
computability undecidability
0
156
A sufficient and necessary condition about regularity of a language
<blockquote>&#xA; <p>Which of the following statements is correct? </p>&#xA; &#xA; <ol>&#xA; <li>sufficient and necessary conditions about regularity of a language exist but not discovered yet.</li>&#xA; <li><p>There's no sufficient and necessary condition about regularity of a&#xA; language.</p></li>&#xA; <li...
formal languages regular languages
1
163
Minimum number of clues to fully specify any sudoku?
<p>We know from <a href="http://arxiv.org/abs/1201.0749" rel="nofollow">this paper</a> that there does not exist a puzzle that can be solved starting with 16 or fewer clues, but it implies that there does exist a puzzle that can be solved from 17 clues. Can all valid sudoku puzzles be specified in 17 clues? If not, wha...
sudoku combinatorics
0
164
What are the possible sets of word lengths in a regular language?
<p>Given a language $L$, define the length set of $L$ as the set of lengths of words in $L$:&#xA;$$\mathrm{LS}(L) = \{|u| \mid u \in L \}$$</p>&#xA;&#xA;<p>Which sets of integers can be the length set of a regular language?</p>&#xA;
formal languages computability regular languages finite automata
1
165
Efficient encoding of sudoku puzzles
<p>Specifying any arbitrary 9x9 grid requires giving the position and value of each square. A naïve encoding for this might give 81 (x, y, value) triplets, requiring 4 bits for each x, y, and value (1-9 = 9 values = 4 bits) for a total of 81x4x3 = 972 bits. By numbering each square, one can reduce the positional inform...
combinatorics modelling information theory sudoku
0
168
Efficient compression of unlabeled trees
<p>Consider unlabeled, rooted binary trees. We can <em>compress</em> such trees: whenever there are pointers to subtrees $T$ and $T'$ with $T = T'$ (interpreting $=$ as structural equality), we store (w.l.o.g.) $T$ and replace all pointers to $T'$ with pointers to $T$. See <a href="https://cs.stackexchange.com/a/177/98...
algorithms data structures trees binary trees
1
178
Is there a "natural" undecidable language?
<p>Is there any "natural" language which is undecidable?</p>&#xA;&#xA;<p>by "natural" I mean a language defined directly by properties of strings, and not via machines and their equivalent. In other words, if the language looks like&#xA;$$ L = \{ \langle M \rangle \mid \ldots \}$$&#xA;where $M$ is a TM, DFA (or regular...
formal languages automata computability undecidability
1
192
How to come up with the runtime of algorithms?
<p>I've not gone much deep into CS. So, please forgive me if the question is not good or out of scope for this site.</p>&#xA;&#xA;<p>I've seen in many sites and books, the big-O notations like $O(n)$ which tell the time taken by an algorithm. I've read a few articles about it, but I'm still not able to understand how d...
algorithms algorithm analysis runtime analysis reference question
0
194
The time complexity of finding the diameter of a graph
<blockquote>&#xA; <p>What is the time complexity of finding the diameter of a graph&#xA; $G=(V,E)$?</p>&#xA; &#xA; <ul>&#xA; <li>${O}(|V|^2)$</li>&#xA; <li>${O}(|V|^2+|V| \cdot |E|)$</li>&#xA; <li>${O}(|V|^2\cdot |E|)$</li>&#xA; <li>${O}(|V|\cdot |E|^2)$</li>&#xA; </ul>&#xA;</blockquote>&#xA;&#xA;<p>The diamet...
algorithms time complexity graphs
1
196
A Case Distinction on Dynamic Programming: Example Needed!
<p>I have been working on dynamic programming for some time. The canonical way to evaluate a dynamic programming recursion is by creating a table of all necessary values and filling it row by row. See for example <a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=11866" rel="nofollow noreferrer">...
algorithms dynamic programming
0
206
Is an infinite union of context-free languages always context-free?
<p>Let $L_1$, $L_2$, $L_3$, $\dots$ be an infinite sequence of context-free languages, each of&#xA;which is defined over a common alphabet $Σ$. Let $L$ be the infinite union of $L_1$, $L_2$, $L_3$, $\dots $;&#xA;i.e., $L = L_1 \cup L_2 \cup L_3 \cup \dots $. </p>&#xA;&#xA;<p>Is it always the case that $L$ is a context-fre...
formal languages context free closure properties
1
210
Why polynomial time is called "efficient"?
<p>Why in computer science any complexity which is at most polynomial is considered efficient?</p>&#xA;&#xA;<p>For any practical application<sup>(a)</sup>, algorithms with complexity $n^{\log n}$ are way faster than algorithms that run in time, say, $n^{80}$, but the first is considered inefficient while the latter is ...
algorithms complexity theory terminology efficiency
1
219
Implementing the GSAT algorithm - How to select which literal to flip?
<p>The GSAT algorithm is, for the most part, straight forward: You get a formula in conjunctive normal form and flip the literals of the clauses until you find a solution that satisfies the formula or you reach the max_tries/max_flips limit and find no solution.</p>&#xA;&#xA;<p>I'm implementing the following algorithm:...
algorithms satisfiability 3 sat
1
221
Identifying events related to dates in a paragraph
<p>Is there an <s><em>algorithmic</em></s> approach to identify that dates given in a paragraph correlate to particular events (phrases) in the paragraph?</p>&#xA;<p>Example, consider the following paragraph:</p>&#xA;<blockquote>&#xA;<p>In June 1970, the great leader took the oath. But it was only after May 1972, post ...
algorithms data mining natural language processing
1
222
Easy reduction from 3SAT to Hamiltonian path problem
<p>There is a reduction in Sipser's book "Introduction to the theory of computation" on page 286 from 3SAT to Hamiltonian path problem. </p>&#xA;&#xA;<blockquote>&#xA; <p>Is there a simpler reduction?</p>&#xA;</blockquote>&#xA;&#xA;<p>By simpler I mean a reduction that would be easier to understand (for students).</p>...
complexity theory np hard
1
223
Stability for couples in the Stable Matching Problem
<p>In the <a href="http://en.wikipedia.org/wiki/Stable_marriage_problem" rel="nofollow">Stable Matching Problem</a>, it is stated that there can exist cases where the $m$ list of men can be content with their decisions, yet the list of $f$ cannot when the algorithm is run with men's proposals.</p>&#xA;&#xA;<p>From what...
combinatorics
1
224
Are two-level schedulers only useful to manage swapping?
<p><a href="http://en.wikipedia.org/wiki/Two-level_scheduling">Two-level scheduling</a> is useful when a system is running more processes than fit in RAM: a lower-level scheduler switches between resident processes, and a higher-level scheduler swaps groups of processes in and out.</p>&#xA;&#xA;<p>I find no other menti...
operating systems process scheduling
0
226
Round-robin scheduling: allow listing a process multiple times?
<p>In a round-robin scheduler, adding a process multiple times to the process list is a cheap way to give it higher priority.</p>&#xA;&#xA;<p>I wonder how practical an approach this might be. What benefit does it have over other techniques such as giving the process a longer time slice (benefit: less switching time) or...
operating systems process scheduling
1
227
Why store self and parent links (. and ..) in a directory entry?
<p>Consider an filesystem targeted at some embedded devices that does little more than store files in a hierarchical directory structure. This filesystem lacks many of the operations you may be used to in systems such as unix and Windows (for example, its access permissions are completely different and not tied to meta...
operating systems filesystems
0
231
Problems Implementing Closures in Non-functional Settings
<p>In programming languages, closures are a popular and often desired feature. <a href="https://en.wikipedia.org/wiki/Closure_%28computer_science%29">Wikipedia</a> says (emphasis mine):</p>&#xA;&#xA;<blockquote>&#xA; <p>In computer science, a closure (...) is a <strong>function together with a referencing environment<...
programming languages semantics
1
234
Parsing arbitrary context-free grammars, mostly short snippets
<p>I want to parse user-defined domain specific languages. These languages are typically close to mathematical notations (I am not parsing a natural language). Users define their DSL in a BNF notation, like this:</p>&#xA;&#xA;<pre><code>expr ::= LiteralInteger&#xA; | ( expr )&#xA; | expr + expr&#xA; |...
formal languages parsers compilers
1
245
Influence of the dimension of cellular automata on complexity classes
<p>Let's take as an example the 3d → 2d reduction: What's the cost of simulating a 3d cellular automaton by a 2d cellular automaton?</p>&#xA;&#xA;<p>Here is a bunch of more specific questions:</p>&#xA;&#xA;<ol>&#xA;<li><p>What kind of algorithms will have their time complexity changed, by how much?</p></li>&#xA;<li><p>...
complexity theory time complexity cellular automata
1
246
Reflection on Concurrency
<p><a href="http://en.wikipedia.org/wiki/Reflection_%28computer_programming%29" rel="nofollow">Reflection</a> is a common mechanism for accessing and changing the structure of a program at run-time, found in many dynamic programming languages such as Smalltalk, Ruby and Python, and in impoverished form in Java and (hen...
programming languages semantics concurrency reflection
1
248
Analyzing a modified version of the card-game "War"
<p>A simple game usually played by children, the game of War is played by two people using a standard deck of 52 playing cards. Initially, the deck is shuffled and all cards are dealt two the two players, so that each have 26 random cards in a random order. We will assume that players are allowed to examine (but not ch...
algorithms optimization
1
249
(When) is hash table lookup O(1)?
<p>It is often said that hash table lookup operates in constant time: you compute the hash value, which gives you an index for an array lookup. Yet this ignores collisions; in the worst case, every item happens to land in the same bucket and the lookup time becomes linear ($\Theta(n)$).</p>&#xA;&#xA;<p>Are there condit...
algorithm analysis data structures runtime analysis hash tables
0
256
Are today's massive parallel processing units able to run cellular automata efficiently?
<p>I wonder whether the massively parallel computation units provided in graphic cards nowadays (one that is programmable in <a href="http://en.wikipedia.org/wiki/OpenCL">OpenCL</a>, for example) are good enough to simulate 1D cellular automata (or maybe 2D cellular automata?) efficiently.</p>&#xA;&#xA;<p>If we choose ...
computer architecture parallel computing cellular automata
0
257
How is a JIT compiler different from an ordinary compiler?
<p>There's been a lot of hype about JIT compilers for languages like Java, Ruby, and Python. How are JIT compilers different from C/C++ compilers, and why are the compilers written for Java, Ruby or Python called JIT compilers, while C/C++ compilers are just called compilers?</p>&#xA;
compilers
1
258
Is it possible to solve the halting problem if you have a constrained or a predictable input?
<p>The halting problem cannot be solved in the general case. It is possible to come up with defined rules that restrict allowed inputs and can the halting problem be solved for that special case?</p>&#xA;&#xA;<p>For example, it seems likely that a language that does not allow loops for instance, would be very easy to t...
computability undecidability software engineering formal methods
0
261
How to determine likely connections in a social network?
<p>I am curious in determining an approach to tackling a "suggested friends" algorithm.</p>&#xA;&#xA;<p><a href="http://facebook.com" rel="nofollow noreferrer">Facebook</a> has a feature in which it will recommended individuals to you which it thinks you may be acquainted with. These users normally (excluding the edge ...
algorithms machine learning modelling social networks
1
265
How to prove that a language is not context-free?
<p>We learned about the class of context-free languages $\mathrm{CFL}$. It is characterised by both <a href="https://en.wikipedia.org/wiki/Context-free_grammar">context-free grammars</a> and <a href="https://en.wikipedia.org/wiki/Pushdown_automata">pushdown automata</a> so it is easy to show that a given language is co...
formal languages context free proof techniques reference question
1
266
Why are the total functions not enumerable?
<p>We learned about the concept of enumerations of functions. In practice, they correspond to programming languages.</p>&#xA;&#xA;<p>In a passing remark, the professor mentioned that the class of all total functions (i.e. the functions that always terminate for every input) is <em>not</em> enumerable. That would mean t...
computability semi decidability enumeration
1
269
Why would anyone want CISC?
<p>In our computer systems lecture we were introduced to the MIPS processor. It was (re)developed over the course of the term and has in fact been quite easy to understand. It uses a <a href="https://en.wikipedia.org/wiki/Reduced_instruction_set_computing">RISC</a> design, that is its elementary commands are regularly ...
computer architecture
1
270
Hash tables versus binary trees
<p>When implementing a dictionary ('I want to look up customer data by their customer IDs'), the typical data structures used are hash tables and binary search trees. I know for instance that the C++ STL library implements dictionaries (they call them maps) using (balanced) binary search trees, and the .NET framework u...
algorithms data structures binary trees hash tables
1
271
Is there an abstract machine that can capture power consumption?
<p>When reporting algorithmic complexity of an algorithm, one assumes the underlying computations are performed on some abstract machine (e.g. RAM) that approximates a modern CPU. Such models allow us to report time and space complexity of algorithms. Now, with the spread out of <a href="http://en.wikipedia.org/wiki/GP...
complexity theory computer architecture power consumption machine models
1
273
Decidable non-context-sensitive languages
<p>It is arguable that most languages created to describe everyday problems are context-sensitives. In the other hand, it is possible and not hard to find some languages that are not recursive or even not recursively-enumerable.</p>&#xA;&#xA;<p>Between these two types are the recursive non-context-sensitive languages. ...
formal languages complexity theory formal grammars
1
285
Decidability of prefix language
<p>At the midterm there was a variant of the following question:</p>&#xA;&#xA;<blockquote>&#xA; <p>For a decidable $L$ define $$\text{Pref}(L) = \{ x \mid \exists y \text{ s.t. } xy \in L\}$$&#xA; Show that $\text{Pref}(L)$ is not necessarily decidable.</p>&#xA;</blockquote>&#xA;&#xA;<p>But if I choose $L=\Sigma^*$ ...
computability undecidability
1
286
Proving the security of Nisan-Wigderson pseudo-random number generator
<p>Let <span class="math-container">$\cal{S}=\{S_i\}_{1\leq i\leq n}$</span> be a partial <span class="math-container">$(m,k)$</span>-design and <span class="math-container">$f: \{0,1\}^m \to \{0,1\}$</span> be a Boolean function. The Nisan-Wigderson generator <span class="math-container">$G_f: \{0,1\}^l \to \{0,1\}^n$...
cryptography pseudo random generators
1
288
How is the loop invariant obtained in this square root bound finding algorithm?
<p><em>Originally on <a href="https://math.stackexchange.com/questions/74453/how-is-the-loop-invarient-obtained-in-this-square-root-bound-finding-algorithm">math.SE</a> but unanswered there.</em></p>&#xA;&#xA;<p>Consider the following algorithm.</p>&#xA;&#xA;<pre><code>u := 0&#xA;v := n+1;&#xA;while ( (u + 1) is not eq...
algorithms loop invariants correctness proof
0
289
Universality of the Toffoli gate
<p>Regarding the quantum <a href="https://en.wikipedia.org/wiki/Toffoli_gate">Toffoli gate</a>:</p>&#xA;&#xA;<ol>&#xA;<li>is it <em>classicaly</em> universal, and if so, why?</li>&#xA;<li>is it <em>quantumly</em> universal, and why?</li>&#xA;</ol>&#xA;
quantum computing circuits turing completeness
1
290
Understanding $\text{handle}$ in parsing problem
<p><em>Originally <a href="https://math.stackexchange.com/questions/22614/help-understand-texthandle-in-parsing-problem">https://math.stackexchange.com/questions/22614/help-understand-texthandle-in-parsing-problem</a> but unaswered there</em></p>&#xA;&#xA;<p>The BNF is defined as followed:</p>&#xA;&#xA;<pre><code>S -&g...
formal languages compilers parsers
0
294
Strategies for becoming unstuck in understanding TCS
<p>I am a graduate student taking a course in theory of computation and I have serious trouble producing content once I'm asked to. I'm able to follow the textbook (Introduction to the Theory of Computation by Michael Sipser) and lectures; however when asked to prove something or come up with a formal description of a ...
computability education intuition
0
298
Graph searching: Breadth-first vs. depth-first
<p>When searching graphs, there are two easy algorithms: <strong>breadth-first</strong> and <strong>depth-first</strong> (Usually done by adding all adjactent graph nodes to a queue (breadth-first) or stack (depth-first)).</p>&#xA;&#xA;<p>Now, are there any advantages of one over another?</p>&#xA;&#xA;<p>The ones I cou...
algorithms graphs search algorithms graph traversal
0
302
ML function of type 'a -> 'b
<p>Our professor asked us to think of a function in OCaml that has the type</p>&#xA;&#xA;<pre><code>'a -&gt; 'b&#xA;</code></pre>&#xA;&#xA;<p>i.e. a function of one argument that could be anything, and that can return a different anything.</p>&#xA;&#xA;<p>I thought of using <code>raise</code> in a function that ignores...
programming languages typing functional programming
1
307
Show that { xy ∣ |x| = |y|, x ≠ y } is context-free
<p>I remember coming across the following question about a language that supposedly is context-free, but I was unable to find a proof of the fact. Have I perhaps misremembered the question?</p>&#xA;&#xA;<p>Anyway, here's the question:</p>&#xA;&#xA;<blockquote>&#xA; <p>Show that the language $L = \{xy \mid |x| = |y|, x...
formal languages context free
1
310
Decision problem such that any algorithm admits an exponentially faster algorithm
<p>In Hromkovič's <a href="http://www.ite.ethz.ch/publications/buch/index_EN">Algorithmics for Hard Problems</a> (2nd edition) there is this theorem (2.3.3.3, page 117):</p>&#xA;&#xA;<blockquote>&#xA; <p>There is a (decidable) decision problem $P$ such that for every algorithm $A$ that solves $P$ there is another algo...
complexity theory
1
311
Deriving the regular expression for C-style /**/ comments
<p>I'm working on a parser for a C-style language, and for that parser I need the regular expression that matches C-style /**/ comments. Now, I've found this expression on the web:</p>&#xA;&#xA;<pre><code>/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*]*\*/&#xA;</code></pre>&#xA;&#xA;<p>However, as you can see, this is a rather m...
compilers parsers regular languages
1
315
Are all context-free and regular languages efficiently decidable?
<p>I came across this figure which shows that context-free and regular languages are (proper) subsets of efficient problems (supposedly $\mathrm{P}$). I perfectly understand that efficient problems are a subset of all decidable problems because we can solve them but it could take a very long time. </p>&#xA;&#xA;<p>Why ...
formal languages regular languages context free efficiency
0
318
Are all system calls blocking?
<p>I was reading <a href="http://www.eecg.toronto.edu/~livio/papers/flexsc-osdi10.pdf">an article</a> that describes the switch between user-space and kernel-space that happens upon a system call. The article says </p>&#xA;&#xA;<blockquote>&#xA; <p>An application expects the completion of the system call before resumi...
operating systems os kernel
1
323
Which instruction yields atomicity in this expression that makes the result 2?
<p>I am reading about atomicity and came across the following scenario</p>&#xA;&#xA;<pre><code>int x = y = z = 0;&#xA;&#xA;Thread 1 Thread 2&#xA;--------- --------&#xA;x = y + z y = 1&#xA; z = 2&#xA;</code></pre>&#xA;&#xA;<p>Which gives the following sets of output</p>&#xA;&#xA;<p>$$\b...
operating systems programming languages concurrency
1
326
Distinguishing between uppercase and lowercase letters in the "move-to-front" method
<p>Is it not necessary to encode both the uppercase and lowercase letter while encoding a message with the <a href="http://en.wikipedia.org/wiki/Move-to-front_transform" rel="nofollow">move-to-front transform</a>? From an old computer science course exam, the problem was to encode <code>Matt_ate_the_mat</code> starting...
combinatorics data compression
1
329
Do you get DFS if you change the queue to a stack in a BFS implementation?
<p>Here is the standard pseudocode for breadth first search:</p>&#xA;&#xA;<pre><code>{ seen(x) is false for all x at this point }&#xA;push(q, x0)&#xA;seen(x0) := true&#xA;while (!empty(q))&#xA; x := pop(q)&#xA; visit(x)&#xA; for each y reachable from x by one edge&#xA; if not seen(y)&#xA; push(q, y)&#xA; ...
algorithms graphs
1
332
In-place algorithm for interleaving an array
<p>You are given an array of $2n$ elements </p>&#xA;&#xA;<p>$$a_1, a_2, \dots, a_n, b_1, b_2, \dots b_n$$</p>&#xA;&#xA;<p>The task is to interleave the array, using an in-place algorithm such that the resulting array looks like</p>&#xA;&#xA;<p>$$b_1, a_1, b_2, a_2, \dots , b_n, a_n$$</p>&#xA;&#xA;<p>If the in-place req...
algorithms arrays permutations in place
1
335
What is the height of an empty BST when using it in context for balancing?
<p>Suppose the datatype for a BST is defined as follows (in SML)</p>&#xA;<pre><code>datatype 'a bst_Tree =&#xA; Empty&#xA; | Node of (int * 'a) * 'a bst_Tree * 'a bst_Tree;&#xA;</code></pre>&#xA;<p>So there are two cases one in which the BST is <code>Empty</code> or it can have a (key,value) as well as two children.<...
algorithms data structures terminology
1
341
ML functions from polymorphic lists to polymorphic lists
<p>I'm learning programming in ML (OCaml), and earlier I asked about <a href="https://cs.stackexchange.com/questions/302/ml-function-of-type-a-b">ML functions of type <code>'a -&gt; 'b</code></a>. Now I've been experimenting a bit with functions of type <code>'a list -&gt; 'b list</code>. There are some obvious simple ...
programming languages typing functional programming
1
342
Not all Red-Black trees are balanced?
<p>Intuitively, &quot;balanced trees&quot; should be trees where left and right sub-trees at each node must have &quot;approximately the same&quot; number of nodes.</p>&#xA;<p>Of course, when we talk about red-black trees*(see definition at the end) being balanced, we actually mean that they are <em>height</em> balance...
data structures binary trees search trees
1
349
Why is encrypting with the same one-time-pad not good?
<p>To encrypt a message $m_1$ with a one-time-pad key $k$ you do&#xA;$Enc(m_1,k) = m_1 \oplus k$. </p>&#xA;&#xA;<p>If you use the same $k$ to encrypt a different message $m_2$ you get&#xA;$Enc(m_2,k) = m_2 \oplus k$, and if you perform Xor of the two ciphertext you get&#xA;$$( m_1 \oplus k) \oplus ( m_2 \oplus k) = m_1...
cryptography information theory encryption
1
350
What is an intuitive way to explain and understand De Morgan's Law?
<p>De Morgan's Law is often introduced in an introductory mathematics for computer science course, and I often see it as a way to turn statements from AND to OR by negating terms.</p>&#xA;&#xA;<p>Is there a more intuitive explanation for why this works rather than just remembering truth tables? To me this is like using...
logic discrete mathematics didactics
1
356
Why hasn't there been an encryption algorithm that is based on the known NP-Hard problems?
<p>Most of today's encryption, such as the RSA, relies on the integer factorization, which is not believed to be a NP-hard problem, but it belongs to BQP, which makes it vulnerable to quantum computers. I wonder, why has there not been an encryption algorithm which is based on an known NP-hard problem. It sounds (at le...
complexity theory np hard encryption cryptography
1
358
How to verify number with Bob without Eve knowing?
<p>You need to check that your friend, Bob, has your correct phone number, but you cannot ask him directly. You must write the question on a card which and give it to Eve who will take the card to Bob and return the answer to you. What must you write on the card, besides the question, to ensure Bob can encode the messa...
algorithms cryptography
1
366
What goes wrong with sums of Landau terms?
<p>I wrote</p>&#xA;&#xA;<p>$\qquad \displaystyle \sum\limits_{i=1}^n \frac{1}{i} = \sum\limits_{i=1}^n \cal{O}(1) = \cal{O}(n)$</p>&#xA;&#xA;<p>but my friend says this is wrong. From the TCS cheat sheet I know that the sum is also called $H_n$ which has logarithmic growth in $n$. So my bound is not very sharp, but is s...
asymptotics landau notation
1