instruction stringlengths 0 29.8k ⌀ |
|---|
Let $\phi = c_1 \wedge c_2 \wedge \dots c_m$ be a 3-SAT formula on $n$ variables $x_1, \dots, x_n$, where $c_i$ is the $i$-th clause.
Assume w.l.o.g. that no clause contains both a literal and its complement (these clauses are always true and can be removed).
The set $S$ contains one string $s_i$ of length $n$ for ... |
null |
I was asking ChatGPT local history questions, because I knew many of the answers and could test the robot. But lots of details were wrong and while it can write citations, it won't disclose its training data i.e., I can't see its blind spots. |
As far as we know, what does GPT-4's training data look like? |
|neural-networks| |
Working on logic design in class, and I'm trying to figure out how to write a specific logic function [and by write, I mean something along the lines of (x NOR y) OR (a NOR b), for example]
It asks to assume 2 variables, X and Y, both of which consist of 3 bits (x2,x1,x0, and y2,y1,y0). I need to write a logic funct... |
I just had an algorithms exam and had the following problem:
Supposed there are $n$ workers and $n$ objects. Each worker has a strength, $s_i$ and each object has a weight $w_i$. Each worker needs to be assigned to an object, and they can only be assigned to a specific object $w_i$ if $s_i \ge w_i$. There are also $k$... |
Workers with certain strength carrying boxes. (Greedy) |
|algorithms|greedy-algorithms| |
Is there such a variation? Yes, you have defined one. Can it be considered as a knapsack problem? As far as I know, there is no formal definition of what counts as a "knapsack problem", so that's a matter of opinion and up to you. |
Your proof is correct. There is no maximal decidable set. Yes, your conclusion is right, there is no optimal termination decider, as you can always come up with another one that detects one more terminating program. It's like noting that there is no largest number: for any number you name, I can always name one that... |
null |
null |
null |
OpenAI does not fully disclose what the training set was. This is a space where there is heavy competition, and I imagine they probably view these details as part of their competitive advantage. What is known about GPT-3 and GPT-4 are disclosed in papers from the authors.
The GPT-4 paper says:
> "GPT-4 is a Tra... |
null |
null |
OpenAI does not fully disclose what the training set was. This is a space where there is heavy competition, and I imagine they probably view these details as part of their competitive advantage. What is known about GPT-3 and GPT-4 are disclosed in papers from the authors.
The GPT-4 paper says:
> "GPT-4 is a Tra... |
null |
Where are these number patterns, Octal and Hex, being used? I read [this](https://cs.stackexchange.com/questions/19963/why-octal-and-hexadecimal-computers-use-binary-and-humans-decimals) but I want to know where they are used in programming? |
Uses of Hex and Octal numbers in programming |
|number-formats|numeral-representations| |
Where are these number patterns, Octal and Hex, being used? I read [this](https://cs.stackexchange.com/questions/19963/why-octal-and-hexadecimal-computers-use-binary-and-humans-decimals) but I want to know where they are used in programming. |
AVL is BST by definition of AVL.
However, its self-balancing mechanism can be applied to any binary tree. |
Let n be an integer. How can I write finite automata for the language L? \
L = {W∈{$0,1,2$}*| The $n_{th}$ from last letter in w is $0$}.\
(Please suggest answers; not hints.)
**Attempt**\
Using Regex, I could write it as $[012]*0[012](n - 1)$ - replacing n - 1 with the actual integer value. But I'm not sure of a... |
Designing a DFA with nth character condition for any integer n |
|formal-languages|regular-languages|automata| |
The octal and hexadecimal bases are not useful by themselves but are needed as a compact and readable representation of binary numbers. For instance, writing $\text{AB00CDFF}$ is more convenient than $10101011000000001100110111111111$.
So the question moves to the usefulness of binary numbers: these enter into play ... |
It is possible to prove that such a DFA would always have at least $3^n$ states (the idea of the proof is given [here](https://cs.stackexchange.com/a/144995/79440), but for a two-letters alphabet).
This bound can be reached: consider $A = (Q, \delta, q_0, F)$ where:
- $Q = \Sigma^n$: to each state corresponds a un... |
If you have an elimination rule for tuples which introduce the left and right pair into the type checking context, what do you do if the type of one of the elements is quantified and has been Skolemized. Isn't it impossible to prevent the Skolem type from escaping its scope here? |
If you have an elimination rule for tuples which introduce the left and right pair into the type checking context, what do you do if the type of one of the elements is quantified and has been Skolemized. Isn't it impossible to prevent the Skolem type from escaping its scope here?
For example the sequent:
... |
I have been studying the SMA* algorithm and I am having trouble understanding the backup operation. Specifically, I don't understand why the f value of a child node should be the maximum of its own f value and its parent's f value, as described in various pseudocode implementations such as the one found on Wikipedia (h... |
Simplified Memory Bounded A* |
|graphs|search-algorithms|search-trees|heuristics|a-star-search| |
I am envisioning a priority queue that is a bit strange. It represents wanting to do a depth-first left-to-right walk of a tree, but allowing for parallel workers where there can be time between assigning a node to a worker and getting new child nodes back to explore, leaving the depth-first left-to-right property as a... |
null |
Let $f$ be a continuous real function on $[-1,1]$. The function is accessible via *queries*: for any $x$, the value of $f(x)$ can be computed in constant time.
If $f(-1)<0$ and $f(1)>0$, then by the intermediate value theorem, $f$ has a *zero* --- an $x \in [-1,1]$ for which $f(x)=0$. Suppose we want to find a zero a... |
Finding an approximate double-zero using binary search |
|algorithms|search-algorithms|binary-search|mathematical-analysis|real-numbers| |
While working with complexity classes, I've come along the definition of $DP$ (or $D^p$):
$$DP = \{L_1 \cap L_2 \mid L_1 \in NP \text{ and } L_2 \in coNP\}$$
I am interested in a different (and much shorter form) of describing this exact operation on class-level, rather than language-level
$$coNP\; ? \; NP = DP$$... |
Is there a common notation for describing this operation $coNP\; ? \; NP = DP$? |
|complexity-theory|notation| |
null |
I am not aware of any standard notation to represent this operation. You could invent your own notation, but make sure you define it in a self-contained way, so that readers understand what you mean by it. |
null |
null |
I won’t answer your question but tell you about one thing you need to check: Every time you assign a worker or a worker + pill, you waste some amount. Is it possible to get a better outcome by assigning a worker + pill to a task requiring 20 or 19 more strength so nothing of strength is wasted? If yes give an example. ... |
so I'm trying to write an algorithm in C to play the game of Reversi. I've already written in basic minimax algorithm yet I am not very satisfied with it. I want to implement alpha-beta pruning to my code to run at a higher depth. However, my code is only given 1 second to run and generate a move and I'm worrying that ... |
How do you stop an algorithm at a specific run time? |
|algorithms|runtime-analysis|pruning| |
null |
null |
Advanced Topics in Types and Programming Languages gives this rule section 2.2 gives this rule for dependent function application:
$$\frac{\Gamma \vdash t_1 : (\Pi x : S.T) \quad \Gamma \vdash t_2 : S}{\Gamma \vdash t_1 t_2 : [ x \mapsto t_2 ] }$$
In ["Modules Matter Most"](https://existentialtype.wordpress.c... |
What are the similarities and differences between dependent function application and ML functor application? |
|type-theory|functional-programming| |
Advanced Topics in Types and Programming Languages gives this rule section 2.2 gives this rule for dependent function application:
$$\frac{\Gamma \vdash t_1 : (\Pi x : S.T) \quad \Gamma \vdash t_2 : S}{\Gamma \vdash t_1 t_2 : [ x \mapsto t_2 ] }$$
In ["Modules Matter Most"](https://existentialtype.wordpress.c... |
As far as I know, it is not possible to achieve that exactly unless you are running a hard-real-time operating system (which neither Windows nor Linux are).
Anyway, you can obtain close to this behavior by one of two methods:
1. internal timing: choose one or more check points in your algorithms, that are frequen... |
When you implement alpha-beta pruning, it is important to try the best moves first. To do this, you evaluate one move and sort the moves from best to worst. Then you evaluate two moves, trying moves in the order you found by one move, and sort again. Then three moves and so on.
In C or C++ you can use the clock() f... |
Advanced Topics in Types and Programming Languages gives this rule section 2.2 gives this rule for dependent function application:
$$\frac{\Gamma \vdash t_1 : (\Pi x : S.T) \quad \Gamma \vdash t_2 : S}{\Gamma \vdash t_1 t_2 : [ x \mapsto t_2 ] }$$
In ["Modules Matter Most"](https://existentialtype.wordpress.c... |
When you implement alpha-beta pruning, it is important to try the best moves first. To do this, you evaluate one move and sort the moves from best to worst. Then you evaluate two moves, trying moves in the order you found by one move, and sort again. Then three moves and so on.
In C or C++ you can use the clock() f... |
As far as I know, it is not possible to achieve that exactly unless you are running a hard-real-time operating system (which neither Windows nor Linux are).
Anyway, you can obtain close to this behavior by one of two methods:
1. internal timing: choose one or more check points in your algorithms, that are frequen... |
In the theory of "[abstract families of languages][1]" one uses the notation $\mathcal K \land \mathcal L$ to denote the pairwise intersection of languages in $\mathcal K$ and $\mathcal L$, thus $\{\;K\cap L\mid K\in\mathcal K \text{ and } L\in\mathcal L\;\}$.
That theory is probably half a century old with work of ... |
null |
I just had an algorithms exam and had the following problem:
Supposed there are $n$ workers and $n$ objects. Each worker has a strength, $s_i$ and each object has a weight $w_i$. Each worker needs to be assigned to an object, and they can only be assigned to a specific object $w_i$ if $s_i \ge w_i$. There are also $k$... |
# Motivation
I want to draw pictures using indexed colors. As I have limited space for colors per-palette, I want to choose palettes in an intelligent fashion, based on the pictures I want to draw. The goal is to choose a palette so that I can draw as many pictures from a set of pictures I want to draw as possible.
... |
Finding the Optimal Palette for a Set of Images |
|algorithms|complexity-theory|time-complexity|optimization|greedy-algorithms| |
I recently read about pathfinding algorithms on grids. It seems two of the most popular are Lee's algorithm and Hadlock's algorithm. Other than the space optimizations that these algorithms employ, it seems to me like both these algorithms are basically just the same as BFS and A* search respectively.
In Hadlock's ... |
Difference between Hadlock's algorithm and A* search |
|search-algorithms| |
Can we create Xorshift generator, as Marsaglia in "Xorshift RNGs" does, using 64-bit numbers, but with period 2^96 or 2^128?
He proposed PRNG with period 2^96:
t=(xˆ(x<<3))ˆ(yˆ(y>>19))ˆ(zˆ(z<<6));x=y;y=z;return(z=t);
But this works on 32-bit ints, as I think. I can't generalize his work to create similar t... |
64-bit Xorshift with 2^96 or 2^128 period |
|pseudo-random-generators| |
Can we create Xorshift generator, as Marsaglia in "Xorshift RNGs" does, using 64-bit numbers, but with period 2^96 or 2^128?
He proposed PRNG with period 2^96:
t=(xˆ(x<<3))ˆ(yˆ(y>>19))ˆ(zˆ(z<<6));x=y;y=z;return(z=t);
But this works on 32-bit ints, as I think. I can't generalize his work to create similar t... |
If you only care about the period and not about randomness, use a 96-bit or 128-bit counter.
If you care about randomness, use any decent PRNG. It doesn't matter which you pick.
If you don't want it to repeat in your lifetime, a random 128-bit value from a decent PRNG is incredibly unlikely to ever repeat within... |
> check all the relevant nodes in the designated time.
You will never be able to check all the nodes. The whole point of iterative deepening is that you search just a part of the tree, and return the best answer you have so far once time runs out. There are therefore two different problems to consider:
1) Making ... |
The problem MATCHED is defined as follows: given an infinite set S of strings of arbitrary length over the alphabet {0, 1}, determine if there exists a character of length n over the alphabet {0, 1} such that for every string s ∈ S, s and w does not match.
My approach: TO prove MATCHED is in NP is easy. For NP Hard... |
Is Dijkstra's shortest-path graph algorithm used in cheapest airfare calculators like Expedia or CheapAir? |
Is Dijkstra's algorithm used in cheapest airfare calculators? |
|graphs|optimization|shortest-path| |
Visualizing the possibilities of a coin toss (instead of bits) helped me wrap my head around this issue, perhaps it might help you as well:
(A = heads, B = tails)
One coin (2 possibilities = 2 x 1; head or tail shown as A B):
A B
Two coins (4 possibilities = 2 x 2; AA = head & head, AB = head & tai... |
The problem is as follows:
> The input is an array $A$ of $n$ natural numbers such that:
>
> (1) if the maximum occurs in $A[p]$ for an index $p$, then $A[1..p] \leq A[p]$ and $A[p] \geq A[p+1..n]$;
>
> (2) if $A[i]=A[j]=x$ then $A[k]=x$ for $i \leq k \leq j$.
(Forgive me for the abuse of notation in (1), I m... |
What recurrence describes the time complexity of this algorithm? |
|algorithm-analysis|recurrence-relation|divide-and-conquer| |
The problem is as follows:
> The input is an array $A$ of $n$ natural numbers such that:
>
> (1) if the maximum occurs in $A[p]$ for an index $p$, then $A[1..p] \leq A[p]$ and $A[p] \geq A[p+1..n]$;
>
> (2) if $A[i]=A[j]=x$ then $A[k]=x$ for $i \leq k \leq j$.
(Forgive me for the abuse of notation in (1), I m... |
I am afraid that you did not think much about this issue.
Clearly, a single bit encodes two states, $0$ and $1$.
Then for two bits, if you claim that the number of states is four, then they must be $00, 01, 10, 11$ (another option would be just two states, $00$ and $11$.)
Now for three bits: the trivial option... |
I am afraid that you did not think much about this issue.
Clearly, a single bit encodes two states, $0$ and $1$.
Then for two bits, if you claim that the number of states is four, then they must be $00, 01, 10, 11$ (another option would be just two states, $00$ and $11$.)
Now for three bits: the trivial option... |
Consider a graph with $n$ nodes and $m = \mathcal{O}(n²)$ edges. The maximum capacity among all edges is denoted by $C$. The running time is given by: $\mathcal{O}(nmC)$
If I consider the input size in bits, it can be stated as: $\mathcal{O}(nlogn + m log n + m log C)$
Denote $v:=log n, b:= log C $.
Then it ... |
Ford-Fulkerson algorithm running in pseudo-polynomial time |
|algorithms|complexity-theory| |
I am afraid that you did not think much about this issue.
Clearly, a single bit encodes two states, $0$ and $1$.
Then for two bits, if you claim that the number of states is four, then they must be $00, 01, 10, 11$ (another option would be just two states, $00$ and $11$, or - why not - setting the bits from left ... |
The octal and hexadecimal bases are not useful by themselves but are needed as a compact and readable representation of binary numbers. For instance, writing $\text{AB00CDFF}$ is more convenient and less error prone than $10101011000000001100110111111111$.
So the question moves to the usefulness of binary numbers: t... |
It is possible to prove that such a DFA would always have at least $2^n$ states (the idea of the proof is given [here](https://cs.stackexchange.com/a/144995/79440), but for a two-letters alphabet).
This bound can be reached: consider $A = (Q, \delta, q_0, F)$ where:
- $Q = \{0,1\}^n$: to each state corresponds a w... |
null |
It is very informal, but intuitively in case of bubble sort on each step you do a smallest possible step towards the goal (swap elements next to each other) while in selection sort you can do long jumps towards the goal. |
null |
I'm reading a book which says that to transform a number from decimal to binary with fixed point representation you have to follow these steps:
1. Take the integer part (the one before the point) of the number and transform it in binary like you normally do with integer numbers: that is the integer part of the bina... |
How fixed point Decimal to Binary conversion algorithm works? |
|binary|fixed-point| |
$T(n)=O(n^2)$ means that for all $n\ge N$,
$$T(n)\le cn^2$$ for some $N$ and $c$.
In no way does
$$T_a(n)\le c_a n^2$$ and
$$T_b(n)\le c_b n^2$$
allow you to draw conclusions on which of $T_a$ and $T_b$ is smaller. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.