instruction stringlengths 0 29.8k ⌀ |
|---|
To resolve $$T(n)=T(\tilde{a}n)+n$$
you can apply the Master
Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)):
the recurrence:
\begin{equation}
T(n)
= \begin{cases}
a T(n / b) + f(n) & n > 1 \\
T_1 & n = 1
... |
**Check if these 2 regular expressions are equivalent:**
$R_1 = (a+b)^*(aa+bb)$
$R_2 = (a+b)^*aa+a^*bb+b^+b$
**My approach:**
We check if both of these expressions generate the same set of strings. Meaning that any string that can be generated by $R_1$ can also be generated by $R_2$, and vice versa.
$... |
Check if these 2 regular expressions are equivalent |
|regular-languages|regular-expressions| |
To resolve $$T(n)=T(\tilde{a}n)+n$$
you can apply the Master
Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)):
the recurrence:
\begin{equation}
T(n)
= \begin{cases}
a T(n / b) + f(n) & n > 1 \\
T_1 & n = 1
... |
It is known that: ${\sf BQP} \subseteq {\sf PSPACE}$ and ${\sf PH} \subseteq {\sf PSPACE}$. If tomorrow its proven that ${\sf PH} = {\sf PSPACE}$ it would also imply ${\sf BQP} \subseteq {\sf PH}$.
**Query:** Since, it is also widely believed that ${\sf NP} \not\subseteq {\sf BQP}$. So where does this leave us in t... |
$BQP$ vs $NP$ in the unlikely scenario of $PH=PSPACE$ |
|complexity-theory|time-complexity| |
null |
I'm reading *Type Theory and Formal Proof* by Nederpelt and Geuvers. Chapter 3 is about $\lambda 2$ and $\Pi$-Types (aka System F, I think?) and the derivation rule for 2nd order abstraction seems to forbid "shadowing" of the type variable; i.e. in context $\Gamma \equiv \alpha : *$ it is not possible to derive a term ... |
Is shadowing of the type variable allowed in System F second order abstraction? |
|lambda-calculus|type-theory| |
null |
The stable algorithm has to run in O(n) time and must call the following unstable algorithm at least once.
```
def unstablesort(l):
return selectionsort(shuffled(l)) # shuffled(l) returns list l randomized
```
This is apparently an easy question but frankly I don't know where to start. |
How do I make a stable, O(n) sorting algorithm that uses an unstable algorithm as a subroutine |
|algorithms|sorting| |
Here's a dynamic programming solution to the problem. To address the aside, we score candidate solutions by the number of edges between two internal nodes that represent a violated precedence ordering (so for example if $+$ has lower precedence than $\times$ then $(1+2)+(3\times 4)$ has a cost of 0 and $1+((2+3)\times ... |
Here's a dynamic programming solution to the problem. To address the aside, we score candidate solutions by the number of edges between two internal nodes that represent a violated precedence ordering (so for example if $+$ has lower precedence than $\times$ then $(1+2)+(3\times 4)$ has a cost of 0 and $1+((2+3)\times ... |
The stable algorithm has to run in O(n) time and must call the following unstable algorithm at least once.
EDIT: Calling unstablesort() is free (costs 0 operations).
```
def unstablesort(l):
return selectionsort(shuffled(l)) # shuffled(l) returns list l randomized
```
This is apparently an easy question but... |
How do I make a stable sorting algorithm that uses an unstable algorithm as a subroutine |
**Hint:**
Unstable sorting shuffles the data in an unrecoverable way (because identical keys are... identical), so you must somehow save the initial position information. |
I'm reading *Type Theory and Formal Proof* by Nederpelt and Geuvers. Chapter 3 is about $\lambda 2$ and $\Pi$-Types (aka System F, I think?) and the derivation rule for 2nd order abstraction seems to forbid "shadowing" of the type variable; i.e. in context $\Gamma \equiv \alpha : *$ it is not possible to derive a term ... |
Given an undirected graph with nonnegative edge weights and a partition of the vertex
set into terminals and Steiner vertices, the Steniner tree problem consists in finding a
minimum weight tree in the graph that contains all terminals and any subset of the
Steiner vertices.
The metric steiner tree problem is whe... |
Does there always exist an optimal solution to the metric steiner tree problem which doesn't contain any steiner nodes? |
|optimization|trees| |
null |
No. The problem is that a single Steiner vertex can be involved in multiple of these shortcut operations. In the first shortcut operation, the total weight of the edges decreases (at the cost of disconnecting the tree), but not necessarily in later shortcut operations, as then you are shortcutting a path of which some ... |
|optimization|trees|computational-geometry| |
Steiner nodes give more freedom to make shortcuts so cannot lead to worse solutions. And it is easy to find examples where they give better solutions.
In fact, Steiner points have been introduced just for that purpose. |
Steiner nodes give more freedom to make shortcuts so they cannot lead to worse solutions. And it is easy to find examples where they give better solutions.
In fact, Steiner points have been introduced just for that purpose. |
null |
null |
The answer to the question: **Is there a Lossless Data compression method/algorithm that is independent of repetitive pattern (redundancy)?**
Is: **Yes**
The probability of each symbol is used, the order of the symbol is not.
Also know as an Order-0 Markov chain, are used to encode data to reduces the number... |
null |
I want to sort a set of items, where some comparisons are expensive and others are cheap. What is an algorithm that will minimize the worse-case number of expensive comparisons?
For instance, I want to rank sports players (assuming performance is completely deterministic, i.e. a game between two players will always ... |
Optimal worse-case sorting algorithm when some comparisons are cheap |
|sorting| |
I know that formally the time compliexity of an algorithm is measured in the length of the input, which in binary would be the number of bits required to encode the input.
The problem that I have with this definition is that wouldn't this definition make a lot of seemingly obvious poly-time algorithms involving numb... |
Measuring time complexity in the length of the input v/s in the magnitude of the input |
|complexity-theory|time-complexity|algorithm-analysis|runtime-analysis| |
A general principle that may help:
- Deterministically-defined language classes (e.g., Regular, Turing-decidable), are typically closed under union, intersection, and complement.
- Nondeterministically-defined language classes (e.g., Context Free, Turing-recognizable) are typically closed under union, but not interse... |
null |
You're not missing anything -- you are correct!
> Consider a loop that prints Hello World $n$ times, where $n$ is an integer, then by the same procedure as above, this algorithm would also be exponential time in the length of the input $n$.
Correct. This *is* an exponential time algorithm.
If it helps, remembe... |
You're not missing anything -- you are correct!
> Consider a loop that prints Hello World $n$ times, where $n$ is an integer, then by the same procedure as above, this algorithm would also be exponential time in the length of the input $n$.
Correct. This *is* an exponential time algorithm.
If it helps, remembe... |
Just because two variables have the same name doesn't mean they're the same variable. Shadowing happens when two variables have the same name in overlapping contexts. It's potentially confusing so we try to avoid that. Fortunately, given a term with shadowing, we can always construct an alpha-equivalent term that has n... |
null |
null |
null |
I am currently making a 2 tape turing machine for a language that has a binary palindrome (ex: L = {x is over {0,1} | x is a palindrome }. I can assume that the tape is only infinite in one way (the right side). and when using 2 tapes, the first one contains the input, the other is empty, and both heads start at the b... |
How do i determine when I am at the left most character of a turing machine tape? |
|turing-machines| |
You're not missing anything -- you are correct!
> Consider a loop that prints Hello World $n$ times, where $n$ is an integer, then by the same procedure as above, this algorithm would also be exponential time in the length of the input $n$.
Correct. This *is* an exponential time algorithm.
If it helps, remembe... |
null |
I'm having a bad time understanding how multiple concepts work simultaneously for achieving linking/loading correctly an executable: the first two objects of those are
From the very beginning loading/linking is basically the art of putting another layer of abstraction over concrete memory addresses to achieve using ... |
Executable linking/loading workflow |
|operating-systems|compilers|virtual-memory| |
You can actually simply assume that the Turing Machine will not move passed the leftmost symbol on the tape if the tape is infinite only on the right. So, you can just say that it will move its head to the left until you reach leftmost cell of the tape.
In case you don't want this you can begin by shifting the cont... |
null |
I'm having a bad time understanding how multiple concepts work simultaneously for achieving linking/loading correctly an executable.
From the very beginning loading/linking is basically the art of putting another layer of abstraction over concrete memory addresses to achieve using the same piece of code over multipl... |
There's a huge number of questions here, so I'm going to go through what I think the central question is, and hope that addresses what you wanted to know.
Executable files are typically loaded at a known virtual address, but DSOs (dynamic shared objects, think `.dll` on Windows or `.so` on Unix) typically are not.
... |
There's a huge number of questions here, so I'm going to go through what I think the central question is, and try to come up with a reasonably self-contained answer that, I hope, addresses what you wanted to know.
Here's the important point: Executable files are typically loaded at a known virtual address, but DSOs ... |
There's a huge number of questions here, so I'm going to go through what I think the central question is, and try to come up with a reasonably self-contained answer that, I hope, addresses what you wanted to know.
Here's the important point: Executable files are typically loaded at a known virtual address, but DSOs ... |
I'm having a bad time understanding how multiple concepts work simultaneously for achieving linking/loading correctly an executable.
From the very beginning loading/linking is basically the art of putting another layer of abstraction over concrete memory addresses to achieve using the same piece of code over multipl... |
I'm having a bad time understanding how multiple concepts work simultaneously for achieving linking/loading correctly an executable.
From the very beginning loading/linking is basically the art of putting another layer of abstraction over concrete memory addresses to achieve using the same piece of code over multipl... |
null |
I'm a programmer, let's start by that. The question may sound really broad, and in fact it is. I'll list some things that I know, and some other things I've doubts about under the form of questions.
My current understanding is the following:
You have a CPU. This CPU can have multiple cores. Each core runs in pa... |
I Don't Understand Nothing About Operating Systems even After reading books |
|operating-systems|cpu| |
Virtual memory is transparent to your questioning. Every execution unit (process) sees the whole virtual space as flat and is unaware of the actual underlying storage in different memory levels.
A linker can perform static relocation, i.e. assign the addresses that must be used by the loader. It organizes the global... |
@CalebStanford's answer is excellent, but just to add one point:
There is a distinction between how many _operations_ are needed and how many _bits_ are needed (more for each number of many digits), and the latter introduces an extra $O(\log n)$ factor because$$\sum_{i=1}^bi2^{i-1}\sim b2^b\sim n\log_2n$$for $2^{n-1... |
You can actually simply assume that the Turing Machine will not move passed the leftmost symbol on the tape if the tape is infinite only on the right. So, you can just say that it will move its head to the left until you reach leftmost cell of the tape. See for example, Sipser's description in Introduction to the Theor... |
First off: an OS is nothing magical. It's code like yours or mine. I've written one (a small one), you can too. Waste of time though, since Linux already exists and it does more than you or I could write.
You have a CPU. It runs instructions. It doesn't know about processes. It doesn't even know about functions. Or ... |
You're not missing anything -- you are correct!
> Consider a loop that prints Hello World $n$ times, where $n$ is an integer, then by the same procedure as above, this algorithm would also be exponential time in the length of the input $n$.
Correct. This *is* an exponential time algorithm.
If it helps, remembe... |
A hash-table seems a good option. As the keys are long, collisions should be minimized. So don't fear to be generous on the number of buckets (low fill factor).
Unless your strings have long prefixes in common, a sequential search among the colliding strings will not be very costly (early termination in case of mism... |
Are there languages that can be parsed by an LR(k) parser but not by an LL(k′) parser for any k′? |
Equivalence of LR(k) and LL(k′) parsers |
|formal-languages|formal-grammars|parsers| |
First off: an OS is nothing magical. It's code like yours or mine. I've written one (a small one), you can too. Waste of time though, since Linux already exists and it does more than you or I could write.
You have a CPU. It runs instructions. It doesn't know about processes. It doesn't even know about functions. Or ... |
Yes, the approach is correct, but there are some mistakes:
1. Statements such as
- $R_1$ ends with $aa$ – can be generated by $R_2 = (a+b)^*aa$
are a bit sloppy. What you mean to say is:
- $R_2$ is the union of 3 expressions, $R_{2,1}, R_{2,2}, R_{2,3}$
- $R_1$ can be written as the union ... |
Let $S = \{P_1, P_2, ..., P_m\}$ be a set of convex polygons in $\mathbb R^2$ with a total of $n$ vertices. Polygons may have non-empty pairwise intersection. A convex polygon is called *stabbed* by a line, if there is a non-empty intersection between them. A set $L$ of lines is called *stabbing set* for the set $S$, i... |
Minimum stabbing problem for a set of convex polygons |
|optimization|computational-geometry|polygons| |
I have been working the last 8 years in try to convert from base n to base m without artihmetical operations.
My hypothesis is that by the same way that is possible convert bases without division (see the tables bellow.) based in a literal conversion you can create an equivalence table that allow this direct transl... |
|turing-machines|pumping-lemma|base-conversion| |
I have been working the last 8 years in try to convert from base n to base m without artihmetical operations.
My hypothesis is that by the same way that is possible convert bases without division (see the tables bellow.) based in a literal conversion.
Can you create an equivalence table that allow this direct tr... |
|formal-languages|formal-grammars|parsers|lr-k| |
Yes, $\{a^i b^j c \mid i \ge j \ge 0\}$ can be parsed by a $LR(0)$ parser but not by any $LL(k')$ parser for any $k'$. See https://cs.stackexchange.com/q/118458/755.
See also https://stackoverflow.com/q/36652221/781723 and https://cs.stackexchange.com/q/43/755. |
I want to sort a set of items, where some comparisons are expensive and others are cheap. What is an algorithm that will minimize the worse-case number of expensive comparisons?
For instance, I want to rank sports players (assuming performance is completely deterministic, i.e. a game between two players will always ... |
I was recently sorting a large list of names - I just ended up sorting it in Python, but it inspired in me the following question. If we're given a list $L$ of $n$ numbers, but can only see $k$ contiguous elements at a time and can shift a group of elements at once, what would be the fastest way to sort this list?
I... |
Algorithms for sorting under some restrictions |
|algorithms|time-complexity|sorting|efficiency| |
Your problem amounts to finding a [linear extension](https://en.wikipedia.org/wiki/Linear_extension) of a given partial order, using the minimum number of comparisons between two elements. @Tassle [highlights](https://cs.stackexchange.com/questions/159695/optimal-worse-case-sorting-algorithm-when-some-comparisons-are-... |
null |
The various temporal logics are particularly suitable for the specification and verification of concurrent computer programs. Are there logics that are particularly suitable for the specification and verification of multi-agent and distributed systems and algorithms? Or are the temporal logics used as-is for these purp... |
Logics for multi-agent and distributed systems and algorithms |
|distributed-systems|concurrency|temporal-logic| |
In my textbook "AI: A Modern Approach" it states that we **expand** a node to **generate** it's children.
So I understand the definition of those two words as:
Expand - Generate/create all the new children nodes of a particular node
Generating - A (child) node is generated when its parent is expanded
Now, whe... |
Goal-testing when node is "Generated" vs when node is "Expanded" contradiction (breadth-first search) |
|breadth-first-search| |
There are two good answers already, but there are two points that weren't touched on. One is that of **output-polynomial time**. A lot of theoretical CS concerns itself purely with *decision* problems, where the output is just a single bit; these are *languages* Sometimes instead you want a whole many-bit output, like ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.