instruction stringlengths 0 29.8k ⌀ |
|---|
I have a confusion related the Lemma 22.1 in Cormen Leiserson Rivest Stein's Introduction to Algorithm book,
Here it is written that delta(s,v) <= delta(s,u) +1 ,where s,u,v are the vertices of a graph G
My question is why <= is used ? Won't that be = only ? I am learning Algorithms and Data Structures.
[![Image ... |
Sign confusion in a BFS lemma |
|algorithms|graphs|graph-traversal| |
I would argue that there is one very specific requirement to defeat undefined behaviour: that the programming language designers control the hardware design.
Undefined behaviour exists notionally to allow variation in compiler implementation, but that is desirable primarily when different compilers target different ... |
Consider the graph $G = (V,E)$ with $V = \{s,u,v\}$ and $E =\{ (s,u), (s,v), (u,v) \}$. You have:
$$
\delta(s,v) = 1 < 1+1 = \delta(s,u) + 1.
$$ |
null |
|complexity-theory|np|probabilistic-algorithms|probabilistic-turing-machines| |
I asked ChatGPT to give me the difference between unrecognizable and undecidable languages, and this what it gave me:
- Unrecognizable languages can be accepted by a Turing machine, but the machine may not always halt on inputs outside the language.
- Undecidable languages cannot be decided by a Turing machine for ... |
Is ChatGPT wrong about the definition of unrecognizable and undecidable languages? |
|formal-languages|turing-machines|computability|undecidability|computation-models| |
null |
null |
In the book **Transactional information systems: theory, algorithms, and the practice of concurrency control and recovery** there is a theorem stating that Gen(2PL) ⊂ OCSR. Can some one help to guide on how to prove this
i.e; Prove that the histories produced by the basic two-phase locking protocol are Order Perserv... |
Proof that 2 phase locking produces order preserving Conflict serializable schedules |
|correctness-proof|database-theory|database-concurrency|transactions| |
I tried to implement the algorithm in c++.
Here is the link [Fractional knapsack in linear time][link]
[link]: https://gist.github.com/hmasum52/8852276d3b831d5ff3f1601bf7e73bdf |
I understand depth first search on a graph, but I'm having difficulty understanding what it means to do depth first search on *only certain edges*. If given an undirected graph, with 2 types of edges, ordinary edges, and *required* edges, then apparently according to the resource below it's possible to do depth first ... |
Meaning of Depth First Search on certain edges? |
|depth-first-search| |
I just finished watching both parts of Herb Sutter's 2012 C++ and Beyond talk about atomics. In it [he mentions][1] that they initially shipped with a bug where the atomic reference count type only guarded the delete behavior with `release` semantics when actually it needs to be `acq_rel`, but to me it seems like actua... |
Implementing an atomic reference count where only the last one drops with acquire semantics |
|synchronization|rust| |
null |
I just finished watching both parts of Herb Sutter's 2012 C++ and Beyond talk about atomics. In it [he mentions][1] that they initially shipped with a bug where the atomic reference count type only guarded the delete behavior with `release` semantics when actually it needs to be `acq_rel`, but to me it seems like actua... |
null |
[![enter image description here][1]][1]
from the [book][2], Speech and Language Processing (3rd ed. draft)
I understand conditioning on `<s>` will give context about the **first** word.
From the formula above, aren't we computing
`P(i want english food </s> | <s>)`, instead of `P(<s> i want english food </s... |
n-gram model: why conditioning on the start symbol <s>? |
|natural-language-processing| |
Meta Complexity
==
MCSP is one of the two signature problems in the subfield of [meta-complexity][1]. You could say that meta-complexity itself is on the bleeding edge of the P=NP problem. Since the full problem is so difficult to resolve, we are forced to attack it from many angles. Impagliazzo described [5 Worlds][... |
null |
null |
null |
Word size determines the amount of memory that can be addressed. For example, if we have 4GB of RAM, then the word size should be 32 bits
log2(4GB) = 31.89 bits, or 32 bits approximately
word size to address 4GB should be >= 32 bits
So, it means in |
ChatGPT is not capable of being “right” or “wrong” about anything. It is however capable of producing very plausible sounding nonsense about just any subject. Never trust anything it says. |
A simple method: Calculate the array B = A xor k. Sort arrays A and B and count the common entries. Time is O(n log n) with n array elements.
This works because (x xor y) = k iff x = (y xor k). So it wouldn’t help for “find all pairs with a product equal to k”. |
null |
With your small numbers, you just create an array that counts how often each number turns up, say f[i] = number of array elements equal to I. Then for query K, you add up f[i] * f[i xor k] for all i. So if all values are less than M = 2^n, then you need max(M, N) steps to fill the array f, and Q * M steps for all queri... |
With your small numbers, you just create an array that counts how often each number turns up, say f[i] = number of array elements equal to I. Then for query K, you add up f[i] * f[i xor k] for all i. So if all values are less than M = 2^n, then you need max(M, N) steps to fill the array f, and Q * M steps for all queri... |
With your small numbers, you just create an array that counts how often each number turns up, say f[i] = number of array elements equal to I. Then for query K, you add up f[i] * f[i xor k] for all i. So if all values are less than M = 2^n, then you need max(M, N) steps to fill the array f, and Q * M steps for all queri... |
There is a simple reduction to 3XOR when you have large numbers, so it's unlikely there is an efficient solution (faster than the $O(NQ)$ which can be achieved with a hash table).
In a bit more detail, if the array and the queries are the same, if any of the queries, say $c$, have a non-zero value then you know ther... |
null |
Let us look at the following 2 cases:
1. We say a *binary search* implementation in a `sorted array` of size `n` has a time complexity of Big-Oh($\log n$). In detail, Big-Oh ($\log_{2} n$) because binary search halves the input space with each iteration.
2. In a recursive code block as below, We say that the t... |
Does the base component affect Logarithmic and Exponential Runtimes in Time Complexity (Big-Oh) of an algorithm? |
|algorithms|time-complexity| |
I came across this question presented in a past exam. I can see why the language is not context free (you can't know what the first w is, hence you are not able to duplicate it, I hope it makes sense), but i would like a more formal way to explain it.
I don't really know where to start, if anyone could give me some ad... |
prove that the language L = { ww | w ∈ {a,b}* } is not context free |
|formal-languages|context-free|proof-techniques| |
The basis of logarithm and the basis of an exponential are very different.
By logarithm basis change formula we have:
$$\log_a n=\frac{\log_c n}{\log_c a} \, $$
where $\log_c a$ is a constant (independent on $n$). Thus $O(\log_a n)=O(\log_c n)$.
For exponentials it is not the case:
$$4^n=(2\cdot 2)^n=2^n \cd... |
The basis of logarithm and the basis of an exponential are very different.
By logarithm basis change formula we have:
$$\log_a n=\frac{\log_c n}{\log_c a} \, $$
where $\log_c a$ is a constant (independent on $n$). Thus $O(\log_a n)=O(\log_c n)$.
For exponentials it is not the case:
$$4^n=(2\cdot 2)^n=2^n \cd... |
The basis of logarithm and the basis of an exponential are very different.
By logarithm basis change formula we have:
$$\log_a n=\frac{\log_c n}{\log_c a} \, $$
where $\log_c a$ is a constant (independent on $n$). Thus $O(\log_a n)=O(\log_c n)$.
For exponentials it is not the case:
$$4^n=(2\cdot 2)^n=2^n \cd... |
Why is the Program counter(PC) 12 bits and not 24 bits in IAS computer system? PC is said to have next - instruction pair and an instruction has 12 bit adress and 20 bit opcode, so if it's a pair it should store 24 bits , right ? |
Why is the Program counter(PC) 12 bits and not 24 bits in IAS computer system? |
|computer-architecture| |
It should be because the PC needs only to point to the memory address of the next instruction's address field, which has a size of 12 bits. The instruction pair is located in consecutive memory addresses, thus the PC does not need to store a full 24-bit value for the next instruction pair |
In his book "Foundations of Computing", professor Allison shows an example of *"language of equal numbers of as, bs, and cs, but in any order"*, formally: $L = \{ w \in \{a,b,c\}^*\ |\ |w|_a=|w|_b=|w|_c \}$, where $|w|_a$ denotes the number of $a$s in a word $w$. This language is a variant of the language $L_1 = \{ a^n... |
Language of equal numbers of as, bs, cs in any order not context-sensitive? |
|formal-languages|formal-grammars|context-sensitive|linear-bounded-automata| |
null |
{"OriginalQuestionIds":[265],"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
Starting from the C/C++ languages, ruling out all undefined behavior would be very hard. But if you're designing a language from scratch, it's not difficult at all to rule out undefined behavior. Many languages -- including type-safe compiled languages, and typically interpreted/dynamic languages -- have no such thing ... |
null |
null |
In his book "Foundations of Computing", professor Allison shows an example of *"language of equal numbers of as, bs, and cs, but in any order"*, formally: $L = \{ w \in \{a,b,c\}^*\ |\ |w|_a=|w|_b=|w|_c \}$, where $|w|_a$ denotes the number of $a$s in a word $w$. This language is a variant of the language $L_1 = \{ a^n... |
I am working on an LRA Theory solver for SymPy, an open source python library for symbolic computations. You can find my work [here](https://github.com/sympy/sympy/pull/25544). Currently I'm trying to optimize it to run faster.
My implementation is based off of Bruno Dutertre's and Leonardo de Moura's paper "A Fast ... |
A Fast Linear-Arithmetic Solver: How can Gaussian elimination be used to simplify matrix A? |
|satisfiability|smt-solvers| |
I need to implement simple search on Python package names and I'm struggling with ranking the results. Considered Levenshtein distance, but it would give too low ranking for matches which contain the search term exactly but have a long extra prefix or suffix.
I was thinking of applying Levenshtein to each substring ... |
Any good text similarity algorithms for substrings? |
|search-algorithms| |
Any text similarity algorithms for substrings? |
The logarithms in different bases are proportional to each other, and in complexity analysis a constant factor is unimportant. Hence
$$O(\log_a(n))=O\left(\frac{\log(n)}{\log(a)}\right)=O(\log(n)).$$
But such a rule does not hold for exponentials, there is no constant such that
$$a^n=c\,e^n.$$
----------
... |
The logarithms in different bases are proportional to each other, and in complexity analysis a constant factor is unimportant. Hence
$$O(\log_a(n))=O\left(\frac{\log(n)}{\log(a)}\right)=O(\log(n)).$$
But such a rule does not hold for exponentials, there is no constant such that
$$a^n=c\,e^n.$$
----------
... |
null |
null |
The idea here is that if you have a solution for $x$, $s_1$, and $s_2$, then from this you can find $y$ and $z$.
The way you can solve this is to solve the linear system:
$$\begin{eqnarray*}
y + 0z & = & s_1 - x\\
2y - z & = & s_2 - x\end{eqnarray*}$$
Which has the solution:
$$\begin{eqnarray*}
y & = & s... |
null |
I would like to know if there are any computational complexity classes where multiple provers interact with a verifier, but the provers work against each other.
For example, suppose it is a decision problem $A$. The verifier has to check if $x \in A$. There are two provers, $P_0, P_1$. $P_0$ tries to convince the v... |
Multi-prover Interactive Proofs where the provers are working against each other |
|complexity-theory|interactive-proof-systems| |
null |
null |
You understand that $n=2^b$ numbers are stored at addresses $0$ to $n-1=2^b$.
What matters in this discussion is that the word size is a $\Theta(\log(n))$ function. |
[![enter image description here][1]][1]
from the [book][2], Speech and Language Processing (3rd ed. draft)
I understand conditioning on `<s>` will give context about the **first** word.
From the formula above, aren't we computing
`P(i want english food </s> | <s>)`, instead of `P(<s> i want english food </s... |
null |
I have found two definitions of delta reduction:
1. [Barry Watson][1] defines it as the result of applying a primitive computation to terms in normal forms
2. But in [Coq][2] they define it as the substitution of a variable in a local context for its definition.
Although I wouldn't be entirely surprised if on... |
What exactly is delta reduction? |
|lambda-calculus| |
I am looking for an implementation for any of the methods to enumerate all vertices of a convex polyhedron defined by $Ax \leq b$
I have found some papers that talk about the problem, for example [this one][1] seems like a good lead. However, it is described at a very abstract level, to facilitate proving correctnes... |
Implementation of algorithm to enumerate all vertices of a convex polyhedron defined as linear inequalities? |
|algorithms|optimization|computational-geometry|convex-hull| |
Even for the canonical example of a semiring, $\mathbb N$, solving linear equations is hard; in a sense, NP-hard.
See 0-1 Knapsack Problem, and Integer Knapsack Problem (Papadimitriou and Steiglitz, page 376). |
null |
null |
I am trying to find an easy to follow resource on implementing any (reasonable) algorithm to find a V-represnetation of a polytope from its h-representation. I only need this to work for $\mathbb{R}^3$
I implemented one which is very silly. Compute all possible intersections of 3 planes among all the half spaces. T... |
Getting a V-representation from an H-Representation of a polytope |
|graphs|computational-geometry|discrete-mathematics|linear-programming|linear-algebra| |
Assume I have $n$ random variables $x$ which need to obey a set of inequality constraints that are linear and can be written as $Ax \leq 0$. Is there a method to sample effectively from these for large $n$, say $n > 10^3$? The first few that are sampled are e.g. from a uniform or exponential distribution, but those con... |
Constrained random sampling by inequalities |
|sampling|markov-chains|monte-carlo| |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.