instruction stringlengths 0 29.8k ⌀ |
|---|
No, the intuition doesn't really scale very well, especially not if you want the optimal solution.
The problem is known as Independent Set and is not only NP-complete, but even W[1]-complete.
There are heuristics you can use, e.g., pick the smallest degree neighbor into your solution, delete the neighborhood, and... |
I think I have developed a logic circuit which by using combinational logic and flip flops learns to perform the XNOR logic between 2 bits.It is a kind of state machine. Suppose we built a computer made of blocks which use a built in neural network (such as mine logic circuit).Wouldnt that save a lot of memory and let... |
null |
# The problem #
I'm arranging a "gift swap" for Christmas with N people involved (N > 2).
I want to create an algorithm that generate the pairing gifter->giftee so that:
1. everyone receives a gift
2. no one sends gift to themselves
3. no pair end in a "gift-closed loop" (person 1 sends gift to person 2, ... |
Randomizing pairing in "gift swawp" |
|algorithms|sorting| |
No, the intuition doesn't really scale very well, especially not if you want the optimal solution.
The problem is known as Independent Set and is not only NP-complete, but even W[1]-complete.
You can try the following _greedy algorithm_: pick the smallest degree neighbor into your solution, delete the neighborhoo... |
null |
null |
What is the reason for this behavior? Usually, in other programming languages, it is either 4/8 bytes, if I am correct. |
Why boolean value in Python is 24/28 bytes? |
|data-structures|python| |
null |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]} |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
Shuffle the numbers $0,1,2,\dots,n-1$ into a random order. Then each person finds their place in this order and gives a gift to the next person in this order. This meets all of your requirements, and introduces plenty of randomness.
For instance, the sequence $1,0,3,2$ means that 1 gives to 0, 0 gives to 3, 3 give... |
In layered architecture, the operating system is broken into a number of layers (levels). The bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface. Each layer is implemented only with operations provided by lower-level layers. The layers are selected so that each uses functions (operation... |
A question about layered architecture in OS |
|operating-systems| |
null |
In layered architecture, the operating system is broken into a number of layers (levels). The bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface. Each layer is implemented only with operations provided by lower-level layers. The layers are selected so that each uses functions (operation... |
Worth mentioning is what POWER and PowerPC do: These processors have a special register intended for returning from a call. There is an instruction BL (Branch and Link) which jumps to the address of a subroutine, and leaves the address of the instruction after the BL instruction in the "Link" register. The function tha... |
null |
null |
null |
null |
I am trying to come up with a grammar for arithmetic expressions with the following order of operations:
1. Parenthesis
2. Factorials
3. Exponents
4. Functions / unary plus and minus
5. Juxtaposition (implied multiplication)
6. Multiplication and division
7. Addition and subtraction
8. Comma separated... |
How need help to specify a grammar for arithmetic expressions |
|context-free|formal-grammars|parsers| |
null |
Consider this variant of multiset covering problem.
Input: a collection of sets $S = \{s_1, s_2, \ldots, s_n\}$ and a universal set $U$, in which $s_k \subseteq U$ and $s_k \neq \emptyset$ for all $k$.
The problem is, given an non-empty multiset $M$ containing elements from $U$, we are allowed to pick at most o... |
Is this variant of multiset covering problem NP-hard? |
|np-complete|np-hard|sets|subset-sum| |
null |
null |
I am trying to come up with a grammar for arithmetic expressions with the following order of operations:
1. Parentheses
2. Factorials
3. Exponents
4. Functions / unary plus and minus
5. Juxtaposition (implied multiplication)
6. Multiplication and division
7. Addition and subtraction
8. Comma separated... |
I am trying to come up with a grammar for arithmetic expressions with the following order of operations:
1. Parentheses
2. Factorials
3. Exponents
4. Functions / unary plus and minus
5. Juxtaposition (implied multiplication)
6. Multiplication and division
7. Addition and subtraction
8. Comma separated... |
null |
I have list $[1, 2, \ldots, T]$. I want to create a collection of subsets, such that:
1. each element belongs to a small number of subsets
2. each prefix is a union of small number of subsets (these subsets can intersect, but they must exactly cover the prefix)
For a given collection of subsets, let $F$ and $... |
Data structure for prefix covering |
|data-structures|binary-trees|information-theory|coding-theory|set-cover| |
I have a list $[1, 2, \ldots, T]$. I want to create a collection of subsets, such that:
1. each element belongs to a small number of subsets
2. each prefix is a union of small number of subsets (these subsets can intersect, but they must exactly cover the prefix)
For a given collection of subsets, let $F$ and... |
null |
A boolean value can be represented with just one bit, but are usually
four or eight bytes long in most statically typed languages because
dealing with values smaller than the register size (four or eight
bytes) can be inconvenient. But Python is object-oriented and
dynamically typed, meaning that every value is an ... |
null |
null |
I've been trying to design an in-program programming language. Like any programming language, the input source code must go through various stages:
1. Divide the source code into tokens. (Tokenizer)
2. Parse the tokens into an abstract syntax tree (Parser)
3. Either interpret or compile the program etc.
With the ... |
Mixfix-parser: finding associated tokens on a list |
|algorithms|data-structures|parsers|lexical-analysis| |
null |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
null |
null |
null |
I was going through the proof that DNF-SAT can be solved in polynomial time. The strategy was to go through all clauses, find a clause that doesn't contain both x and x' for any variable x and then output the satisfying assignment. The input size for this problem is the number of variables (say n). My doubt is that if... |
Number of clauses in SAT problems |
|algorithms|satisfiability| |
null |
null |
> In computational complexity theory, decision problems are typically defined as formal languages, and complexity classes are defined as the sets of the formal languages that can be parsed by machines with limited computational power.
https://en.wikipedia.org/wiki/Formal_language
Can the problem of function also ... |
Do function problems have an interpretation in terms of formal languages? |
|formal-languages|decision-problem| |
null |
The proof of $HALT$'s undecidability usually goes like this: we assume the existence of a halting decider and incorporate it into a machine $D$ that takes a TM as input, runs it on its own encoding and does the "opposite" action. We then notice $D(D)$ has a contradicting behavior and conclude a halting decider cannot e... |
Do proofs of $HALT$'s undecidability make it clear that it's practically relevant? |
|computability|halting-problem| |
I'm taking a course in graph algorithms. I've just implemented recognition of chordal graphs for an assignment.
I'm wondering: what are the use cases for [chordal graphs](https://en.wikipedia.org/wiki/Chordal_graph)?
In other words, what are the chordal graphs one can obtain from studying other computational proble... |
What are the practical use cases for chordal graphs? |
|algorithms|graphs| |
Chordal graphs - what are the use cases? |
null |
I was trying to understand the proof of MIP is inside NEXP. I was referring to Rutger's university scribes ([link][1]). They define MIP as a class with exponential proof, but that is not the definition I am familiar with. It is much easier to understand why that definition would be in NEXP, but I am unclear on how havi... |
How to prove MIP is in NEXP |
|complexity-classes|nondeterminism|interactive-proof-systems| |
Suppose I have a list of numbers, say $L$, that grows every day when a new batch of numbers get added to it every night. Right now, say the list is of size $M$, with the daily batch size is of the order $O(n)$ with $M>>n,$ so tomorrow the list will roughly have $M + O(n)$ numbers.
Based on this list $L$, I also mai... |
Optimal algorithm to select unique values from a daily-growing list |
|algorithms|algorithm-analysis|optimization| |
null |
null |
I have been reading this paper [https://arxiv.org/abs/1910.11519][1] on private learning.
In the proof of lemma 3.3. they claim that
$$
2\left(\frac{2e n_\text{pub}}{d}\right)^{2d}e^{-\alpha n_\text{pub}/4}
$$
is upper bounded by $\beta$ via standard manipulation when $n_\text{pub}=O\left(\frac{d\log(1/\alpha)+\lo... |
Upper bound via standard manipulation in proof of semi-private learning |
|algorithms|asymptotics|machine-learning|upper-bound|differential-privacy| |
null |
The second statement (limited to size $\le 2^{2^{100}}$) is true. That problem is decidable: there exists an algorithm to decide it. There are only $2^{2^{101}}$ different problem instances, which is finite, so there exists an algorithm that has all answers for each problem instance hard-coded into it. I couldn't wr... |
null |
null |
Conside [Geometric progression][1]
$1+2+4+8+...+n=2n-1$.
So time complexity is $O(n)$.
[1]: https://en.wikipedia.org/wiki/Geometric_progression |
For this question ([154. Find Minimum in Rotated Sorted Array II
](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)), I have a solution:
```
def findMin(self, nums: List[int]) -> int:
n = len(nums)
left, right = 0, n - 1
while left < right:
mid ... |
Finding minimum in a descending rotated sorted array with duplicates |
|arrays|binary-search| |
The proof of $HALT$'s undecidability usually goes like this: we assume the existence of a halting decider and incorporate it into a machine $D$ that takes a TM as input, runs it on its own encoding and does the "opposite" action. We then notice $D(D)$ has a contradicting behavior and conclude a halting decider cannot e... |
null |
null |
Given a boolean function it can always be represented by a family of circuits.
**Query 1:** Is it true that, for any integer $N$ and for all $I_{in}$ such that $I_{in} \leq 2N$
There exists a circuit of size $N$ with $I_{in}$ input bits such that this same logic cannot be created with a smaller circuit.
**Qu... |
Circuit Complexity Query regarding the minimum circuit size and input size range |
|complexity-theory| |
The proof of $HALT$'s undecidability usually goes like this: we assume the existence of a halting decider and incorporate it into a machine $D$ that takes a TM as input, runs it on its own encoding and does the "opposite" action. We then notice $D(D)$ has a contradicting behavior and conclude a halting decider cannot e... |
null |
This is related to my previous question: [Do proofs of $HALT$'s undecidability make it clear that it's practically relevant?](https://cs.stackexchange.com/questions/162470/do-proofs-of-halts-undecidability-make-it-clear-that-its-practically-relevan)
I made a mistake of leaving something implicit when I asked it; namel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.