instruction stringlengths 0 29.8k ⌀ |
|---|
In the [wikipedia page for the NP-intermediate complexity class][1], the following observation is made:
> Under the assumption that P ≠ NP, Ladner explicitly constructs a problem in NPI, although this problem is artificial and otherwise uninteresting. It is an open question whether any "natural" problem has the same... |
null |
In the [wikipedia page for the NP-intermediate complexity class][1], the following observation is made:
> Under the assumption that P ≠ NP, Ladner explicitly constructs a problem in NPI, although this problem is artificial and otherwise uninteresting. It is an open question whether any "natural" problem has the same... |
I came across this thread looking to validate if the solution I came up with with when my kids wanted to play a game requiring a die but one could not be found.
Take three coins and write numbers like this:
| | Coin 1 | Coin 2 | Coin 3 |
| ---- | ------ | ------ | ------ |
| Head | 2 | 0 | 0 ... |
In the [wikipedia page for the NP-intermediate complexity class][1], the following observation is made:
> Under the assumption that P ≠ NP, Ladner explicitly constructs a problem in NPI, although this problem is artificial and otherwise uninteresting. It is an open question whether any "natural" problem has the same... |
In a 2 by n grid there is a character in each cell. A path can start at any cell and then you can move to right or down. This way each path will denote a string written by characters on cells visited in visiting order. I wanna try finding efficient methods for pattern searching queries (number of paths resulting a stri... |
Use case of for string matching in a 2 by n grid |
|algorithms|data-structures|strings|string-matching| |
I have to find 2 efficient ways to sort 1000 exams according to the students' last names and give the complexity. The task has to be divided between m teachers.
I think one efficient way is to give each teacher a range of letters, for example one teacher has to sort the exams with the last names from A to D, the other... |
For grammar
$$
S \rightarrow Sa | b
$$
The following represents the $LR(0)$ itemset and its finite automata. *(ignore the $ symbol)*
[![FA of LR0 Itemsets][1]][1]
[1]: https://i.stack.imgur.com/EGaBo.png
If every state is final state of the above $FA$, it would recognise $\{\epsilon, b, S, Sa \}$ , hence... |
Well it is very much possible to sort using some non transitive comparer. But it depends on what non transitivity means for you. For situation **A > B && B > C** there are 3 possible scenarios:
- A > C (that's transitivity)
- A >= C (soft non transitivity)
- A and C in any relation (hard non transitivity)
If... |
null |
|algorithms|data-structures|strings|string-matching|research| |
The order of the loops in the Floyd-Warshall algorithm is crucial. The algorithm works by progressively improving an estimate of the shortest path between every pair of vertices by considering each vertex as a possible intermediate step on the path.
If you change the order of the loops such that k (the intermediate ... |
I know that there is another topic about this question. But my question is ore specific to a certain algorithm that I wrote and I'd like to know more about it's complexity (since I am not good in this subject).
Here is my algorithm with inputs $a$, which is an integer and $n$, which is an odd natural. And right afte... |
Except in some special cases where $d$ is very small, I don't think there is any algorithm whose running time is noticeably better than $\mathcal{O}(n^2)$ (ignoring the dependence on $d$). In particular, I suspect one can prove a reduction showing that you can't do better than $\mathcal{O}(n^{2-\epsilon})$ unless the ... |
I'm curious about how much complexity is introduced to an algorithm while it's being debugged. Is there a general theory for optimal debugging algorithms and theoretically optimal debugging performance?
The curiosity is a consequence of the following question: If I mean debugging to be the process of making informat... |
Influence of debugging on runtime complexity |
|complexity-theory| |
As requested, I am posting my edit to the question above as an answer:
> I have just realized that what I'm asking for is fundamentally impossible. Two unsigned 64-bit integers when summed together cannot represent the full space of an unsigned 128-bit integer. This should have been obvious to me, but I got lost in ... |
Unfortunately I suspect this is not the sort of problem that theoretical running time analysis will be very useful for adding much insight on.
Theoretical analysis is very useful when there are algorithmic techniques that make a major difference in scaling (e.g., $O(n)$ vs $O(n^2)$). Theoretical running time analys... |
I think there is a reasonably succinct proof in Schrijver (1986) "Theory of Linear and Integer Programming". |
null |
Use case for string matching in a 2 by n grid |
null |
1. Is there an n>2, for which A has no winning strategy? To determine if there is an n>2 for which A has no winning strategy, we can analyze the rules of the game. Player A's goal is to select a number mi such that mi divides the sum of all previous numbers mk (where k < i). This means that Player A wants to select a n... |
In general, sorting algorithms rely on the transitive property of the comparison function to correctly order elements. Transitivity ensures that if A is less than B and B is less than C, then A must be less than C. This property guarantees that the sorting algorithm can consistently compare and order elements.
Howev... |
The paper ["On the Complexity of Integer Programming" from Papadimitriou][1] has a very compact (2 and a half pages counting from abstract) proof.
It only needs the common knowledge about dual programs and linear algebra, but might be a bit terse.
[1]: https://lara.epfl.ch/w/_media/papadimitriou81complexityi... |
I can provide a solution to your problem by discussing a general approach to implementing N-input-gates using smaller N-input-gates.
To start, let's consider the case where we want to implement an N-input-gate using only 2-input-gates. One approach is to break down the N-input-gate into smaller sub-gates, such as AN... |
Assume that a matrix $M\in [0;1]^{n\times d}$ is given, i.e., all values in the matrix are in the range 0 to 1. I would like to compute the following function for all rows of $M$:
$$
f(m_1,m_2,...,m_d)=\frac{1}{n}\sum_{i=1}^{n} \begin{cases}1 \quad \text {if} \quad M[i,j] \le m_j \text{for all} j\\
0\quad \text{el... |
What data structure would be optimal in terms of time and space for the following usecase:
Given information about rectangles in the form of- {rectangle_id,left_bottom_corner_x, left_bottom_corner_y, right_top_corner_x, right_top_corner_y}.
I need to use a structure which will answer the following querie... |
I found an algorithm for determining if a binary tree is height-balanced.
It Gets the height of left and right subtrees using dfs traversal. Return true if the difference between heights is not more than 1 and left and right subtrees are balanced, otherwise return false.
algorithm code:
```
/* CPP program to ch... |
Time Complexity: Determining if a binary tree is balanced |
|binary-search-trees|avl-trees| |
I found an algorithm for determining if a binary tree is height-balanced.
It Gets the height of left and right subtrees using dfs traversal. Return true if the difference between heights is not more than 1 and left and right subtrees are balanced, otherwise return false.
algorithm code:
```
/* CPP program to ch... |
In the [wikipedia page for the NP-intermediate complexity class][1], the following observation is made:
> Under the assumption that P ≠ NP, Ladner explicitly constructs a problem in NPI, although this problem is artificial and otherwise uninteresting. It is an open question whether any "natural" problem has the same... |
Is this an example of a natural, strictly NP-intermediate language (assuming EXP ≠ NEXP)? |
I know that there is another topic about this question. But my question is ore specific to a certain algorithm that I wrote and I'd like to know more about it's complexity (since I am not good in this subject).
Here is my algorithm with inputs $a$, which is an integer and $n$, which is an odd natural. And right afte... |
In the [wikipedia page for the NP-intermediate complexity class][1], the following observation is made:
> Under the assumption that P ≠ NP, Ladner explicitly constructs a problem in NPI, although this problem is artificial and otherwise uninteresting. It is an open question whether any "natural" problem has the same... |
As you have seen in other sources, the proof that there exists a witness with polynomial size does not exactly fit inside the margin, so to speak. The proof I know of (from the book I mention below) depends heavily on the mathematics of linear inequalities and polyhedra, and I expect this to be the case for most proofs... |
null |
null |
null |
|runtime-analysis|binary-search-trees|avl-trees| |
Determining if a binary tree is balanced runs in $O(n)$, since we only need to traverse each node once, and moving from one node to another requires $O(1)$ moves.
However, since your code calculates height from scratch repeatedly, it runs in $O(n^2)$. |
null |
The pseudocode came from Wikipedia and the explanation is in Wikipedia as well. The recurrence is
$dist(i, j, k) = min(dist(i,j,k-1),\ dist(i,k,k-1) + dist(k,j,k-1))$ with the base case $dist(i, j, 0) = w(i, j)$. There is only one way we can achieve this iteratively, by calculating all cases of $k-1$ before calculatin... |
I'm looking for a data structure that would allow storing samples (in O(1)) from a data stream in a fixed-size buffer while the stream length isn't known in advance.
Once the buffer size is exhausted it should start overwriting previous elements in a staggered manner, retroactively reducing the sampling rate of the ... |
A data structure for an allocation-free dynamic sample rate buffer |
|data-structures|sampling|storage| |
I am using the GraphBLAS C API (https://graphblas.org/) which provides an interface for performing mathematical operations on sparse matrices. Given an adjacency matrix $\mathbf{A}: \mathbb{R}^{n \times n}$, I would like to remove duplicate rows from the matrix. Instead of implementing this in the standard $\mathcal{O}... |
Mathematical operation for removing duplicate rows in a matrix |
|graphs|matrices|linear-algebra|sparse-matrices| |
I am using the GraphBLAS C API (https://graphblas.org/) which provides an interface for performing mathematical operations on sparse matrices. Given an adjacency matrix $\mathbf{A}: \mathbb{R}^{n \times n}$, I would like to remove duplicate rows from the matrix. Instead of implementing this in the standard $\mathcal{O}... |
The best name I can think of is derandomized or deterministic [reservoir sampling](https://en.wikipedia.org/wiki/Reservoir_sampling). I don't know of any ready-made implementations. |
null |
Great observation and question! There is no contradiction, but you have to get into the details. I'll explain why below. Also, as it happens, something very similar to your example has been noted before.
Details
=======
I interpret Wikipedia as saying: it is an open question whether there is any natural probl... |
A more efficient approach is to hash each row, insert them into a hash table, and find duplicates in that way. The running time will be $O(n^2)$.
You can implement something like this using only linear algebra operations. In particular, pick a random column vector $v$. Multiply using your BLAS API to obtain the p... |
I haven't checked carefully, but the running time is most likely $\mathcal{O}(\log \max(a,n))$ iterations, or $\mathcal{O}((\log \max(a,n)) \cdot (\log n)^2)$ bit-operations. In the special case where $a \le n$, we can describe this as $\mathcal{O}(\log n)$ iterations or $\mathcal{O}((\log n)^3)$ bit-operations. Good... |
Here is my algorithm with inputs $a$, which is an integer and $n$, which is an odd natural. Is $\mathcal{O}(n)$ the time complexity of this algorithm?
[![algorithm][1]][1]
My thoughts:
The if-cases in the lines $1$ up to $20$ and $32$ up to $37$ are checked in $\mathcal{O}(1)$.
In lines $21$ and $22$, the ... |
Suppose I want to introduce a new family of types $B(a)$, where $a:A$ into a type theory using inference rules. First of all, my understanding is that $B:A\to U$, where $U$ is some universe. So my first question is: should I necessarily introduce the universe $U$ before introducing the family $B(a)$?
And secondly, ... |
About introducing a family of types into a type theory with inference rules |
|logic|type-theory|dependent-types| |
null |
I was wondering if a variation of the bin packing problem where the 'size' of a bin is calculated as the product of item sizes in a bin instead of their sum is NP-hard. It seems like it must be, but I don't know how to prove it.
More formally, the problem is as follows:
Given a list of positive integer item sizes... |
NP-hardness of a variation of the bin packing problem |
|algorithms|reductions|np-hard| |
The bin packing problem is [strongly NP-hard](https://en.wikipedia.org/wiki/Bin_packing_problem#Hardness_of_bin_packing). That means that even if the sizes are given in unary, the problem is still NP-hard.
In your case, your product-bin packing is equivalent to sum-bin packing, using $\log a_i$ and $\log x$ as sizes... |
null |
null |
null |
I have the following two resuts taken from the book "The Classical Decision Problem".
[![enter image description here][1]][1]
[![enter image description here][2]][2]
How does Corollary 6.3.28 follow? How can I derive PSPACE-hardness from non-membership in $NSPACE(cn / \log(n))$?
[1]: https://i.stack.img... |
What does a problem not in $NSPACE(cn / \log(n))$ tell me? |
null |
At first I thought it is obvious, since the `NOP` instruction does not have any operand, we say it is zero-operand instruction. But then looking on the zero-operand instruction,
But looking after the definition I am confused to classify the instruction into $n$-operand category. [ref](https://www.geeksforgeeks.org/c... |
How many operands does the NOP instruction have? |
|computer-architecture|instruction-set| |
At first I thought it is obvious, since the `NOP` instruction does not have any operand, we say it is zero-operand instruction. But then looking on the zero-operand instruction,
But looking after the definition I am confused to classify the instruction into $n$-operand category, where $n \in \{0, 1, 2, 3\}$ [ref](ht... |
I have a function $f$ such that is the sum of big O terms, such as
$$f=\left[\sum_{i=1}^x \frac{1}{i}\right] +O\left(\frac{\ln^4 x}{x}\right)+O\left(\frac{\ln^4 x-1}{x-1}\right)+O\left(\frac{\ln^4 x-2}{x-2}\right)+\ldots$$
where $x$ is a positive integer. Am I correct in that I can simply write
$$f=\left[\su... |
null |
At first I thought it is obvious, since the `NOP` instruction does not have any operand, we say it is zero-operand instruction. But then looking on the zero-operand instruction,
But looking after the definition I am confused to classify the instruction into $n$-operand category, where $n \in \{0, 1, 2, 3\}$ [ref](ht... |
I think that your confusion stems from the fact that the "definition" for 0-operand instruction is sloppily written.
A 0-operand instruction is not **required** to operate on some data or register. What the definition is trying to say is that **if** such an instruction operates on data/registers **then** the addres... |
A 0-operand instruction is simply an instruction that takes no operand.
As a result, if such an instruction changes some data either in memory or in some register, the corresponding address or register name is implicitly determined by the instruction itself at time of execution (e.g., the affected memory location mig... |
I have researched multiple solutions to the convex hull problem, but I am afraid I don't really understand some of them. For example, Graham's scan is a bit confusing as it is not very clear if the n given points are sorted at the start of the algorithm or not. And if they are, how and why? I guess I don't really know ... |
What are solutions to the convex hull problem? |
|algorithms|time-complexity|computational-geometry|divide-and-conquer| |
(Given a graph $G$ with $|V|=n,|E|=m, max(c(a,b))=C$ and with integer capacities)
Dinic's algorithm with scaling is defined the following way:
1. set $\Delta = C$;
2. run Dinic's algorithm, only allowing augmenting $\geq\Delta$ at a time (at any point, if edge we're looking at in the created DAG is $<\Delta$, dele... |
There is an exercise in a [book][1] about finite automata that I couldn't solve:
Prove that if $L \subseteq b^{\*}$ isn't regular then $M = a^+L^+b^*$ isn't regular either, using the fact that REG is closed under inverse morphism (paraphrase).
I think one obvious approach would be to find a Language $L'$ and morh... |
Prove that if $L \subseteq b^{\*}$ isn't regular then $M = a^+L^+b^*$ isn't regular |
|formal-languages|regular-languages|theory| |
There is an exercise in a [book][1] about finite automata that I couldn't solve:
Prove that if $L \subseteq b^*$ isn't regular then $M = a^+L^+b^*$ isn't regular either, using the fact that REG is closed under inverse morphism (paraphrase).
I think one obvious approach would be to find a Language $L'$ and morhpis... |
Prove that if $L \subseteq b^*$ isn't regular then $M = a^+L^+b^*$ isn't regular |
null |
What method(s) could be used to solve this? I am still new to this stuff and would appreciate detailed justification for every step as well as some intuition and the examination of all possible viable methods to go about this, not just one. Thanks. |
What is the "big theta" order of the solution of T_n = T_(n/2) + log n, n > 0? |
|time-complexity|asymptotics|recursion|master-theorem| |
There is an exercise in a [book][1] about finite automata that I couldn't solve:
Prove that if $L \subseteq b^*$ isn't regular then $M = a^+L \cup b^*$ isn't regular either, using the fact that REG is closed under inverse morphism (paraphrase).
I think one obvious approach would be to find a Language $L'$ and mor... |
Prove that if $L \subseteq b^*$ isn't regular then $M = a^+L \cup b^*$ isn't regular |
There is an exercise in a [book][1] about finite automata that I couldn't solve:
Prove that if $L \subseteq b^*$ isn't regular then $M = a^+L \cup b^*$ isn't regular either, using the fact that REG is closed under inverse morphism (paraphrase).
I think one obvious approach would be to find a Language $L'$ and mor... |
Assume towards a contradiction that $M = a^+ L \cup b^*$ is regular.
Then $M' = M \cap a^*b^* = a^+ L$ is also regular (since it is the intersection of regular languages), [and so is](https://en.wikipedia.org/wiki/Quotient_of_a_formal_language) $a^* \setminus M' = L$, which contradicts the fact that $L$ is not regula... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.