instruction stringlengths 0 29.8k ⌀ |
|---|
Consider the following sketch of a parsing strategy at your own risk.
Instead of reading the input only from one end, we read from both sides and look for matching rules. We can do this in recursive descent style; in a call to $A()$, find prefix $w$ and suffix $v$ to the input such that there is a rule $A \to wBv$, ... |
Consider the following sketch of a parsing strategy at your own risk.
Instead of reading the input only from one end, we read from both sides and look for matching rules. We can do this in recursive descent style; in a call to $A()$, find prefix $w$ and suffix $v$ to the input such that there is a rule $A \to wBv$, ... |
If the graph is directed this is rather complex, [here is some paper][1] claiming faster results in the dense case than using algorithms for all-pairs shortest paths.
However my main point is about the case the graph is *not* directed and with non-negative weigths, I heard of a nice trick several times:
1. Pick ... |
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.
I'm implementing the following algorithm:
procedur... |
Implementing the GSAT algorithm - How to select which literal to flip? |
|algorithms|gsat|satisfiability|3-sat|sat| |
> Isn't the maximum number of satisfied clauses what we're looking for?
Yes, we're looking for an assignment that satisfies the maximum number of clauses (that is all of them, preferably). And to that end we ask ourselves "Which single variable will bring us closest to this goal when flipping it?" and then flip it.
... |
In theory, we care for the asymptotic behaviour, and describe classes of problems and algorithms based on their asymptotic behaviour. The keyword here is *asymptotic*. $O(n^{80})$ is faster than $O(n^{\log n})$ asymptotically, i.e., starting from $n > 1208925819614629174706176$ (which by the way is called: septillion!)... |
Is there an *algorithmic* approach to identify that dates given in a paragraph correlate to particular events (phrases) in the paragraph?
Example, consider the following paragraph:
> In June 1970, the great leader took the oath. But it was only after May 1972, post the death of the Minister of State, that he took... |
Identifying events related to dates in a paragraph |
|algorithms|natural-language-processing| |
There is a reduction in Sipser's book "Introduction to the theory of computation" on page 286 from 3SAT to Hamiltonian path problem.
> Is there a simpler reduction?
By simpler I mean a reduction that would be easier to understand (for students).
> Is there a reduction that uses linear number of variables?
... |
Easy reduction from 3SAT to Hamiltonian path problem |
|complexity-theory|np-hard| |
In the Stable Matching Problem, it states 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.
From what I read, an unstable match occurs when $m$ and $f$ prefer each other to their current partners.
I ... |
Stability for couples in the Stable Matching Problem |
|combinatorics| |
[Two-level scheduling](http://en.wikipedia.org/wiki/Two-level_scheduling) 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.
I find no other mention of two-level scheduling ... |
Are two-level schedulers only useful to manage swapping? |
|scheduling|operating-systems| |
Yes, it is stable. It doesn't need to assign the optimal choices for both sides. To break a marriage you need two willing parties, unhappiness of one side in a marriage doesn't make it unstable here. |
In a round-robin scheduler, adding a process multiple times to the process list is a cheap way to give it higher priority.
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 maintaining a s... |
Round-robin scheduling: allow listing a process multiple times? |
|scheduling|operating-systems| |
In a round-robin scheduler, adding a process multiple times to the process list is a cheap way to give it higher priority.
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 maintaining a s... |
[Two-level scheduling](http://en.wikipedia.org/wiki/Two-level_scheduling) 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.
I find no other mention of two-level scheduling ... |
Consider an embedded filesystem that does little more than store files in a hierarchical directory structure. This filesystem does not allow any kind of hard link or soft link, so every file has a unique name. Is there any benefit to storing a link to the directory itself and to its parent in the on-disk data structure... |
Why store self and parent links (. and ..) in a directory entry? |
|operating-systems|filesystems| |
I have been working on dynamic programming in a general setting 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 [Cormen, Leiserson et al: "Introduction to Algorithms"](http://mitpress.mit.edu/catalog/i... |
You get fewer special cases. In many situations, a program may handle ".." as it handles any other directory name. |
Consider an embedded filesystem that does little more than store files in a hierarchical directory structure. This filesystem does not allow any kind of hard link or soft link, so every file has a unique name. Is there any benefit to storing a link to the directory itself and to its parent in the on-disk data structure... |
|operating-systems|filesystems| |
Having links to the parent directory makes good sense to me. If you didn't have them, you would always need to work with a whole list of directories. So, for example, `/home/svick/Documents/` would have to be represented as `{ /, /home/, /home/svick/, /home/svick/Documents }`. If you didn't do that, you wouldn't be abl... |
<sup>(**note**: the full desciption is a bit complex, and has several subtleties which I prefered to ignore. The following is merely the high-level ideas for the QTM model)</sup>
When defining a Quantum Turing machine (QTM), one would like to have a simple model, similar to the classical TM (that is, a finite state ... |
|algorithms|data-mining|natural-language-processing| |
In programming languages, closures are a popular and often desired feature. [Wikipedia](https://en.wikipedia.org/wiki/Closure_%28computer_science%29) says (emphasis mine):
> In computer science, a closure (...) is a **function together with a referencing environment** for the non-local variables of that function. A ... |
Problems Implementing Closures in Non-functional Settings |
|programming-languages|semantics| |
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 metadat... |
I don't see a reason to implement `.` and `..` on either level. However, if you target embedded systems any layer you can *save* may be dollars earned, so it might make sense to try and implement everything as low as possible.
As for the general need of `.` and `..`, how would you express relative paths without them... |
There are plenty of other examples of dynamic programming algorithms that don't fit your pattern at all.
* The longest increasing subsequence problem requires only a one-dimensional table.
* There are several natural dynamic programming algorithms whose tables require three or even more dimensions. For example: ... |
I have been working on dynamic programming in a general setting 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 [Cormen, Leiserson et al: "Introduction to Algorithms"](http://mitpress.mit.edu/catalog/i... |
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 [Cormen, Leiserson et al: "Introduction to Algorithms"](http://mitpress.mit.edu/catalog/item/default.asp?ttype... |
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:
expr ::= LiteralInteger
| ( expr )
| expr + expr
| expr * expr
I... |
Parsing arbitrary context-free grammars, mostly short snippets |
|parsers| |
Probably the ideal algorithm for your needs is [Generalized LL parsing][1], or GLL. This is a very new algorithm (the paper was published in 2010). In a way, it is the Earley algorithm augmented with a graph structured stack (GSS), and using LL(1) lookahead.
The algorithm is quite similar to plain old LL(1), except ... |
Scheduling is an optimisation problem. Its goal is to order a set of tasks so that some objective function (e.g. makespan) is minimised. The set of constraints is crucial; in particular, there is a large body of research covering online variants. |
null |
The class of regular languages is a fundamental and simple class. It corresponds to the languages (equivalently) accepted by finite automata, generated by left-linear grammars and described by regular expressions. |
null |
We can look at how closures are implemented in C#. The scale of the transformations the C# compiler performs makes it clear that their way of implementing closures is quite a lot of work. There may be easier ways to implement closures, but I'd think the C# compiler team would be aware of this.
Consider the following... |
May I direct you to the [Funarg problem wikipedia page](https://en.wikipedia.org/wiki/Funarg_problem)? At least this is how the compiler people used to reference the closure implementing problem.
> So a closure is essentially a (anonymous?) function value which can use variables outside of its own scope. In my exper... |
We can look at how closures are implemented in C#. The scale of the transformations the C# compiler performs makes it clear that their way of implementing closures is quite a lot of work. There may be easier ways to implement closures, but I'd think the C# compiler team would be aware of this.
Consider the following... |
May I direct you to the [Funarg problem wikipedia page](https://en.wikipedia.org/wiki/Funarg_problem)? At least this is how the compiler people used to reference the closure implementing problem.
> So a closure is essentially a (anonymous?) function value which can use variables outside of its own scope. In my exper... |
{"Voters":[{"Id":39,"DisplayName":"Gilles"},{"Id":29,"DisplayName":"svick"},{"Id":27,"DisplayName":"Rebecca Chernoff"}]} |
{"Voters":[{"Id":20,"DisplayName":"J.D."},{"Id":27,"DisplayName":"Rebecca Chernoff"}]} |
I know its a silly example, but I think a simple iterative problem like
> Find the sum of the numbers in a square matrix
might qualify. The the traditional "for each row for each column" kinda looks like your case 3. |
|formal-languages|parsers|compilers| |
To answer part of your question. The formalism described by [Morrisett and Harper][1] covers big- and small-step semantics of higher-order polymorphic languages containing closures. There are papers before these providing the kinds of semantics you are looking for. Look, for example, at [the SECD machine][2]. Adding mu... |
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?
Here is a bunch of more specific questions:
1. What kind of algorithms will have their time complexity changed, by how much?
2. What would be the basic idea for the encoding; ho... |
Influence of the dimention of cellular automata on complexity classes |
|complexity-theory|time-complexity|cellular-automata| |
[Reflection][1] 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 (hence) Scala. Functional languages such as LISP and Scheme also support a good reflect framework.... |
Reflection for Concurrency |
|concurrency|reflection| |
Influence of the dimension of cellular automata on complexity classes |
null |
According to [Immerman][1], the complexity class associated with [SQL][2] queries is exactly the class of *safe queries* in $\mathsf{Q(FO(COUNT))}$ (first-order queries plus counting operator).
Is there an extension of SQL (implemented and used in the industry) which captures polynomial time computable queries (and... |
[Reflection][1] 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 (hence) Scala. Functional languages such as LISP and Scheme also support a good reflect framework.... |
Reflection on Concurrency |
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:
expr ::= LiteralInteger
| ( expr )
| expr + expr
| expr * expr
I... |
|programming-languages|semantics|concurrency|reflection| |
You get fewer special cases. In many situations, VFS may handle ".." as it handles any other directory name. |
The only reason I can imagine is the following scenario:
1. An original implementation of a file system existed with the same directory format but the notions of file paths and subdirectories was not considered at that time (See [The PDP-7 Unix file system][1]).
2. Then people thought that path resolution and s... |
The only reason I can imagine is the following scenario:
1. An original implementation of a file system existed with the same directory format but the notions of file paths and subdirectories was not considered at that time (See [The PDP-7 Unix file system][1]).
2. Then people thought that path resolution and s... |
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 chang... |
Analyzing a modified version of the card-game "War" |
|algorithms|optimization|game| |
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)$).
Under what assumptions can hash ... |
(When) is hash table lookup O(1)? |
|time-complexity|data-structures|hash-tables| |
A perfect hash function will result in O(1) worst case lookup.
Moreover, if the maximum number of collisions possible is O(1), then hash table lookup can be said to be O(1) in the worst case. If the expected number of collisions is O(1), then the hash table lookup can be said to be O(1) in the average case. |
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?
I am particularly interested in complex type-checking algorithms that were implemented in widely known strongly static typed lan... |
A _perfect hash function_ can be defined as an injective function from a set $S$ to a subset of the integers $\{0, 1, 2, ..., n\}$. If a perfect hash function exists for your data and storage needs, you can easily get $O(1)$ behavior. For instance, you can get $O(1)$ performance from a hash table for the following task... |
Here is an idea that sounds absolutely convincing to me and might therefore be absolutely wrong in a dumb way.
Consider the following scenario. We have two nodes $N_1$ and $N_2$ with clocks $C_1$ and $C_2$, respectively. For sake of simplicity, let us assume that the clocks run with the same speed; we denote their d... |
A perfect hash function will result in $\cal{O}(1)$ worst case lookup.
Moreover, if the maximum number of collisions possible is $\cal{O}(1)$, then hash table lookup can be said to be $\cal{O}(1)$ in the worst case. If the expected number of collisions is $\cal{O}(1)$, then the hash table lookup can be said to be $... |
[Reflection][1] 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 (hence) Scala. Functional languages such as LISP and Scheme also support a good reflect framework.... |
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?
I am particularly interested in complex type-checking algorithms that were implemented in widely known strongly static typed lan... |
A _perfect hash function_ can be defined as an injective function from a set $S$ to a subset of the integers $\{0, 1, 2, ..., n\}$. If a perfect hash function exists for your data and storage needs, you can easily get $O(1)$ behavior. For instance, you can get $O(1)$ performance from a hash table for the following task... |
There are two settings under which you can get O(1) worst-case times.
1. If your setup is static, then FKS hashing will get you worst-case O(1) guarantees. But as you indicated, your setting isn't static.
2. If you use Cuckoo hashing, then queries and deletes are O(1) worst-case, but insertion is only O(1) expec... |
I will explain pieces of this article: [Simulating 3D Cellular Automata with 2D
Cellular Automata][1].
Let's start by the encoding of the grid, a function $t:\mathbb Z^3 → \mathbb Z^2$. Intuitively $t$ can't preserves the distance because the number of cells at a distance less than $R$ from the origin won't be the ... |
According to [Immerman][1], the complexity class associated with [SQL][2] queries is exactly the class of *safe queries* in $\mathsf{Q(FO(COUNT))}$ (first-order queries plus counting operator): SQL captures safe queries. (In other words, all SQL queries have a complexity in $\mathsf{Q(FO(COUNT))}$, and all problems in ... |
{"Voters":[{"Id":68,"DisplayName":"Stéphane Gimenez"},{"Id":46,"DisplayName":"sepp2k"},{"Id":98,"DisplayName":"Raphael"},{"Id":31,"DisplayName":"Dave Clarke"},{"Id":39,"DisplayName":"Gilles"}]} |
From Wikipedia:
1NF: The table faithfully represents a relation and has no repeating groups.
2NF: Non-prime attributes are non functionally dependent on a proper subset of a candidate key.
3NF: Non-prime attributes are non-transitively dependent on every candidate key in the table.
BCNF: Every non-trivial f... |
Since you ask for a algorithmic approach, I will be as stubborn as an algorithm. I'm sorry to treat this question like this, but since it doesn't seem like a complex theoretical problem, I will synthesize the possible approaches.
Question: can you give me a algorithmic definition of a date and of particular event?
... |
According to [Immerman][1], the complexity class associated with [SQL][2] queries is exactly the class of *safe queries* in $\mathsf{Q(FO(COUNT))}$ (first-order queries plus counting operator): SQL captures safe queries. (In other words, all SQL queries have a complexity in $\mathsf{Q(FO(COUNT))}$, and all problems in ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.