instruction stringlengths 35 29.1k |
|---|
Is there an efficient algorithm for the following problem?
Given: a $m$-vector $b \in \{0,1,2\}^m$, and a $m \times 2m$ matrix $A$, with the promise that for every $b' \in \{0,1,2\}^m$, there exists $x' \in \{0,1\}^{2m}$ such that $Ax'=b' \pmod 3$
Goal: find $x \in \{0,1\}^{2m}$ such that $Ax'=b' \pmod 3$
In more detai... |
When reading up on deep learning from various sources, one is often presented with the notion that deep learning is essentially a black box: A set of recipes, heuristics and empirical best practices that have been found to often work, but where the mechanism by which good results are achieved is usually not well unders... |
Is there a maximum possible ratio of white/black pixels in an edge map?
In my theoretical consideration all areas in an image which have the same intensity are black and only the edges are white. Hence, the white/black ratio must be theoretically smaller than 50/50 in any conceivable picture of our environment (In my o... |
1. Calculate the total number of moves required i.e. "pow(2, n)- 1".
Here n is number of disks.
2. If number of disks (i.e. n) is even then interchange destination
pole and auxiliary pole.
3. for i = 1 to total number of moves:
if i%3 == 1:
legal movement of top disk between ... |
In the PAC-learning setting, it is easy to learn a CNF formula when we know each clause has at most $c$ variables.
We go through each positive sample, and eliminate every clause that contradicts the sample.
Learning a DNF formula is said to be much harder, but it seems a similar procedure can be used, so it is unclear ... |
Many complexity classes have "complete" problems. Do complete problems exist for the complexity class of problems that can be solved in $O(1)$ time?
A complication is that this class depends on the model of computation; a problem can be solvable in $O(1)$ time in one reasonable model of computation but not another, giv... |
Does removing the leading(or trailing) n bits of any given hash have any negative effects other then increasing the likeliness of collisions? Does appending 2 hashes of the same object with different seeds have have any negative effects?
For some context I am building a Bloom filter that has a variable size and would l... |
The literature is fairly clear that unit-cost RAMs with primitive multiplication are unreasonable, in that they
cannot be simulated by Turing machines in polynomial time
can solve PSPACE-complete problems in polynomial time
However, all of the references I can find on this topic (Simon 1974, Schonhage 1979) also invo... |
Can anyone shed light on whether or not ERGMs are network models based on the maximum entropy principle? Especially if we say that the available information about the network is in the form of network measures, that is, we know that that graph in question G has $x_1(G), x_2(G),...,x_k(G)$ where $x_i$ is a measure, such... |
Given ALL$_{\text{TM}}$ = { < M > | where M is a TM and L(M) = $Σ^*$ } show this is undecidable. I'm also told not to use Rice's theorem. I'm having difficulties with reduction type problems. How would you do a proof for this using a reduction of A$_{\text{TM}}$? Any pointers to resources are much appreciated.
|
Consider the following recursive algorithm for printing all balanced strings with $n$ left and right parentheses. It is called with prefix = $\epsilon$ (the empty string):
A(prefix):
If prefix contains $n$ right parens: print prefix and return.
If prefix contains more left parens than right parens: call A(prefix + ")"... |
How to order the functions $2^n$ vs $n^{\log n}$ based on their complexity?
I found this question in a programming website (InterviewBit). But the answer given there, $n^{\log n}, 2^n$, does not seem convincing.
The graph of the two functions also indicates that $n^{\log n}$ is more complex than $2^n$.
I also tried su... |
Is it possible giving a well defined problem, to write an algorithm which takes in as input another algorithm and checks if that algorithm is correct.
If it isn't possible, I'm thinking of storing solutions to a large number of problem sizes, randomly selecting a smaller number of problem instances and seeing if the ... |
I am currently working on a seminar on $\mathbf{P \stackrel{?}{=} NP}$ and one of the points I want to adress is the Relativization barrier.
However, it is hard to find a concrete definition of a "relativizing" proof. The best defintion I have found is as follows:
"A relativizing proof is any proof that is insensitive... |
In the fourth edition of Sedgewick's Algorithms, it's claimed that the running time of QuickSort is $\sim 1.39n\log_2 n$. I'm trying to find a "simple" proof and explanation of this.
All I know is that the total running time obeys $$C_n = C_{\mathrm{partitioning}} + C_{\mathrm{leftArray}} + C_{\mathrm{rightarray}}$$
an... |
I know how to calculate the shortest paths from source s to all other reachable vertices in a DAG (with no negative weight on the edges)
By iterating the topological sort of the graph and relax each adjacent vertices. Which take O(V+E)
However - I'm required to determine if a certain spanning tree is the shortest-path... |
I am practicing for an exam. I am trying to convert a language to a regular expression. The language and my solution is as follows:
$L=\{w∈\{a,b\}^+│|w|≥4\ and\ the\ second\ symbols\ from \ the \ front\ and\ the\ back\ are\ equal\}$
Solution: $(a+b)x(a+b)^* x(a+b) \ \ where\ x=(a+b)$
Is this correct? If not, c... |
Define
$A = \{<G,s,t> :G$ is un directed graph that has a Hamilton path from $s$ to $t\}$
$B = \{<G> :G$ is un directed graph that has a Hamilton path$\}$
I would like to show that $A \le_p B$.
My attempt:
Given $<G,s,t>$ , the reduction outputs $<G'>$ where $G'$ defines as follows:
we take $v_s$ and $v_t$ s.t t... |
I was given a array R of n rectangles [each element in the array is a bottom left point(x1,y1) and a top right point (x2,y2)] , parallel to the axis, and an array P of n points [each element is a point (x.y)].
I need to write an algorithm that finds a point in the P array that appears in the largest amount of rectangle... |
My lecturer recently released solutions to an assignment. One of the questions was to determine the weakest precondition of:
{y < 10} if (x > 0 OR y < 10) -> y:=10 fi {true}
According to the provided solution, the weakest precondition of the selection command
(x > 0 OR y < 10) -> y:=10
is
(x > 0 OR y < 10)
I underst... |
I have been lurking for a while; this is my first post here. I’m sorry if my question is ill-formed or formatted poorly. This question came out of some ideas in another question from a sister site.
Question
Because of the nature of a blockchain, a large number of publicly agreeable coin flips may be generated - namel... |
I have devised a compiler optimization that works on any structured language that has arrays assignments array[index] = value and counted loops (for i = n; i < N; i++) {doTHIS} (*).
Now I want to represent this optimization using some formal semantics. Since I want to publish my results in a Programming Languages venu... |
int a = 0;
for (int i = 0; i < n*n; ++i) {
for (int j = 0; j <= i; ++j) {
a += j;
}
}
Could someone help prove to me that this is function is $O(N^4)$.
I remember doing this problem a while back, but now I do not see it.
I understand that the outer loop is $O(N^2)$ but I am uns... |
I have a Computer Science A-Level exam tomorrow and I've been trying to get this question answered by my teacher but she's not been too helpful so asking here instead.
In an exam question, I have the following BNF grammar, where _ denotes a space.
<fullname> ::= <title>_<name>_<endtitle> |
<name> |
... |
Given a set of $n$ linear equations in $v$ integer variables, where $v > n$, we can say that this system of equations will always have an integer solution.
Over $\mathbb N$, is there any such constraint that guarantees that a solution always exists? Or, if not, can it be tested in polynomial time?
|
I was reading this question on how to update the distances matrix D of a graph after one edge was decreased, and I don't understand why it works:
The answer suggests that if the an edge (a,b) was modified - then all you have to do is iterate through every edge of the graph, and calculate: D[u][a] + w(a,b) + D[b][v].
My... |
I know how Translation Lookaside Buffers work, and i also know we use them to improve the performance of data/program access by storing the recent page numbers - frame numbers in a memory cache.
The problem is that i can't understand why frequent memory locations are acccessed in a period of time? And what was the star... |
I found two definitions Reed-Muller codes being used in literature. More specifically for any $n \in \mathbb{Z}^+$ and $1 \leq d \leq n$ we define the set $RM(d,n)$ in two possible ways,
1.
$RM(d,n) = \{ f : \mathbb{F}_2^n \rightarrow \mathbb{F}_2 \vert $f$ \text{ is a polynomial of degree at most } $d$\} $
2.
$RM(d,n)... |
In the textbook I'm reading, it states that
If the interrupt is of a lower/equal priority to the
current process then the current process continues
If it is of a higher priority the CPU finishes its current
Fetch-Decode-Execute cycle. The contents of
the CPU’s registers are copied to a st...
In short, the CPU... |
I have these two terms:
{P(a,x,x),P(a,b,c)}
I'm supposed to find if the terms and unifiable using the unification algorithm.
I'd do the following substitutions:
b/x, resulting in : {P(a,b,b),P(a,b,c)}
c/b, resulting in : {P(a,c,c),P(a,c,c)}
And thus the two terms are unifiable.
However, the solution in my book says tha... |
I have the following system of recursive relations on $y_{i,j}$ that are derived from a Markov chain and that I am having difficulty in solving. For $i\ge 1$ and $j \ge 1$, we have
$$y_{i,j} \times (p_i+q_j+2)=y_{i-1,j} \times p_i+y_{i,j-1} \times q_j+2y_{i+1,j+1}.$$
Also we have
$$\begin{align*}
y_{1,0} \times (p_1+q... |
My understanding:
The Halting Problem is undecidable for a Turing Machine, and yet it is decidable for a linear bounded automaton (a Turing Machine with finite tape). The reason is that the only way an LBA can loop is by entering a configuration it's already been in, which is easy to check. However, unlike an LBA, a Tu... |
This is a follow up to the previous Question: Conditions for Linear Diophantine Equations to always have a solution
It was established in the above's answer that obtaining or testing for the existence of an solution of an ILP in $\mathbb N$ is an NP Hard Problem. This in turn makes obtaining solution for a (LDP) Linear... |
Let $T$ be a complete binary tree. Prove that $T$ is a binary search tree if and only if for every node $x$ of $T$ that is not a leaf, the key of $x$ is larger or equal than the key of the left child of $x$ or it is less than or equal than the key of the right child.
To prove that if $T$ is BST then for every node $x... |
I know that we can construct a BST by just having its pre-order traversal in $O(n)$ time (this link). But what if the tree is just a binary tree and we have its in-order and pre-order traversals? I could only find a $O(n^2)$ (worst case) algorithm for this problem, like this link.
So I'm wondering whether a $o(n^2)$ al... |
How to find all permutation of a String in Iterative way ?
Code (Recursion) :
private void permute(String str, int l, int r)
{
if (l == r)
System.out.println(str);
else
{
for (int i = l; i <= r; i++)
{
str = swap(str,l,i);
permute(str, l+1, r);
st... |
Apologies in advance for the naivety of this question. I am a 50 year old artist trying to properly understand computers really for the first time. So here goes.
I have been trying to understand how data types and variables are handled by a compiler (in a very general sense, I know there is a lot to it). I'm missing so... |
If $NP \neq co-NP$ then no $NP-complete$ problem can be in $co-NP$.
I found a proof on Wikipedia that I didn't fully get:
https://en.wikipedia.org/wiki/Co-NP
In the line "from this it follows that the set of complements..". Why does it follow? It seems like the author took a complement from both sides of the equation, ... |
Which of the following languages are recursively enumerable?
A={⟨M⟩∣ TM M accepts at most 2 distinct inputs}
B={⟨M⟩∣ TM M accepts more than 2 distinct inputs}
For first language I think that we can enumerate all the TM's which accept at most 2 distinct inputs using dovetailing method and same is the case with B languag... |
A question bridging math and computer science, I have on the order of 10000 vectors each of a equal but high dimension, say 6 or 7 dimensions. I want to find a given number of 'unique' vectors in the set, the number generally equal to the dimension of the vectors. In math terms I believe I want to find a subset of vect... |
I have an unweighted undirected graph and I have to find if there exists a path between two vertices $u,v$ that visits set of specific nodes $A$. $A$ can contain $1-10$ nodes. No node can be visited more than once.
I thought about finding all paths between $u,v$ and then check if those paths contain vertices from $A$.... |
I have difficulty understanding the halting problem. I know that for all possible Turing machines and strings w, we don't have a Turing machine that can decide whether a TM M halts on input w. Now suppose we have a program p that, for example, solves the Hamiltonian path problem. Can we conclude from the halting proble... |
I know that the main operations (Insert, Search, Delete) have a worst-case running time of $\mathcal{O} (h)$. But I wanted to dig into this deeper.
Basically I am having some difficulties understanding "Big-Omega" when it comes to the worst-case time complexity. I usually define them as follows:
Let $t(x)$ be the numbe... |
Let us consider the knapsack problem. Given a set $P$ of $n$ items where each item has weight $w_i$ and value $v_i$ for all $i=1,2,\ldots,n$. We have two bins, one has a weight limit of $W$ and the other has a weight limit of $W'=2W$. Assume that we have an optimal algorithm $\texttt{OPT}$ that solves the knapsack prob... |
The "Common successor"-heuristic ist described here: Motamedi et al.: A Survey of Techniques for Internet Topology Discovery, p. 11, 2015
http://ieeexplore.ieee.org/abstract/document/6970764/
From the above named source:
The “common successor” heuristic suggests which two IP addresses may be aliases. This heuristic re... |
Will the Traveling Salesman Problem (TSP) become easier if the simple path constraint is omitted?
That is, each node in the topological graph should be visited once at least (instead of exactly).
Is it still NP-complete or reduced to a P problem?
How would this modification affect classical methods for solving the orig... |
If I have two number consider a and b and let their division quotient is c.
I know the value of c but I don't know either value of divided(a) or divisor(b). If I came to know the value of divisor is increased by one, can I somehow calculate the new value of quotient(c)
I guess, maybe using some bit manipulation rules o... |
By integers, I mean a whole number.
Example:
Input : 2, 4, 7, 9, 3, 1, 11
Output: 1,2,3,4 forms an AP (of difference 1) with length 4.
An obvious solution is to sort the array with a comparison based algorithm O(nlogn) and then do a second scan through the unsorted array to find the longest sequence.
Can we have a b... |
Question
I want to Implement Rod cutting Algorithm without Dynamic Programming Approach.
Let me Describe the problem statement.
Given a rod of length $n$ inches and a table of prices $p_{i}$ for $i=1,2,3,4,\,.\,.\,.$ determine the maximum revenue $r_n$ obtainable by cutting up the rod and selling the pieces.
In corme... |
Link: http://www.spoj.com/problems/MINUS/
I have an Idea, after doing n-1 operations one can see that there is just + and - coefficients before each number that matters.
For eg.
given sequence: 12 10 4 3 5 and we need to make it a mathematical expression using + and - signs only to get 4 ,one solution will be +12-10... |
Let $\Phi$ be a k-CNF and $\Phi_{min}$ be a minimal CNF (one that contains smallest amount of literal occurences) that is equal to $\Phi$.
Can $\Phi_{min}$ contain a clause of size $m > k$?
What I have tried:
Let's define the concept of partial assignment: an assignment that has free variables. Example: $x_1 = 0, x_2 =... |
I am learning lambda calculus as my previous questions indicate . But in a different book , namely , The structure and interpretation of computer program I cam across the concept of "church numerals " and the stumbled upon the following link about church numerals :
https://www.cs.rice.edu/~javaplt/311/Readings/supplem... |
Definitions:
An up down language is a language whose alphabet is a set of pairs, but not characters, of two characters, where the one character in the pair is the opposite of the other character in the pair.
Each word in the language is concatenation of some characters from the alphabet given in the pairs of the alphab... |
I'm reading the AKS primality test paper as it is found here. I'm confused about a statement in Lemma 4.3:
"Note that $(r, n)$ cannot be divisible by all the prime divisors of $r$ since otherwise $r$ will divide $n^{\left \lfloor{log(B)}\right \rfloor}$
by the observation above."
Here $(r, n)$ is short-hand for $gcd(r... |
How can I prove that $NDFA = \{ \langle M_1,M_2 \rangle | M_1$ and $M_2$ are $DFA$s such that there is at least one string $x$ that is accepted by neither $M_1$ nor $M_2\}$ is decidable using the fact that $ANFA = \{\langle N \rangle | N$ is an $NFA$ with some input alphabet $\Sigma$, and $L(N) = \Sigma^*\}$?
|
I'm trying to create an algorithm for time spent on a blog post which gives a number in the -1 to 1 range. Negative numbers will mean that users spent less than expected time on a post, while positive numbers means the opposite.
Now, what I've tried to do so far is to:
Set an expected time (in seconds):
Expected time ... |
I sort of need an explanation on how can I demonstrate that a language formed by strings that are multiples of k, is a regular language
I really dont know how
|
Excuse any mistakes in my description as I'm new to ML. But I have an application that takes user input to generate paths/curves (All symbols are single paths) and I would then like to attempt identification. This seems, generally, to be a pretty well studied problem, and there is a lot of reference I can find.
However... |
$L = \{wtw' \mid w,w' \in \{a, b\}^*, \hspace{0.3cm} |w|_a = |w'|_a, \hspace{0.3cm} |w|_b=2|w'|_b, \hspace{0.3cm} t\in\{c\}^* \}$.
Note : $|w|_a$ means the number of $a$ in substring $w$.
To substring $w$, the number of symbol $a$ and $b$ is not relevant to each other.
It's also applied to substring $w'$.
To make mat... |
Assume that we have access to a generative model $G$, that takes as input a state-action pair $(s,a)$ and outputs a sample consisting of a successor state-observation pair $(s',o)$, that is, $(s',o)\sim G(s,a)$.
It can be assumed that the states, actions, and observations all take on a finite number of values (can be p... |
The graph coloring problem, in which we have to decide whether a given graph can be legally colored using $K$ colors, is NP-complete for any $K>2$.
Consider the following more restricted variant of the problem:
Given a graph with $N^2$ nodes in which each node has degree at most $2N$. Provided that we can color the giv... |
I was given the following CFG :
$S \rightarrow A\ |\ B$
$A\rightarrow aAa\ |\ abAb\ |\ bAc\ |\ aca\ |\ abcb\ |\ bcc$
$B \rightarrow bBa\ |\ aBb\ |\ babBc\ |\ bca\ |\ acb\ |\ babcc$
And I have to show if it is ambiguous by giving two leftmost derivations for the same word.
I am pretty sure that there are two leftmost de... |
Let's say we have a string $s$. We define a unique substring in $s$ as a substring that occurs only once in $s$. How can we efficiently find such a substring with the smallest length in $s$?
The most obvious solution is in $O(n^3)$ by checking every substring. What if we can preprocess the string?
|
I have the following greedy algorithm for max cut problem:
Initialization: $A \leftarrow \{v_1\}$ , $B \leftarrow \{v_2\}$
For $v \in V − \{v_1, v_2\}$ do:
if $d(v,A) \geq d(v,B)$ then $B \leftarrow B \cup \{v\}$,
else $A \leftarrow A \cup \{v\}$.
Output $A$ and $B$.
Here, $v_1$ and $v_2$ are arbitrary vertices in $... |
I am having some trouble understanding the equivalence of DTM's and NTM's.
If you have Sipser its under 7.11; where he says that any NTM $N$ that halts after $t(n)$ steps has an equivalent DTM $D$ that halts after $2^{O(t(n))}$
steps.
He says that $N$ 's "computation tree" has at most $b^{t(n)}$ leaves, where $b$ is ... |
I just started working on algorithms and am having some trouble understanding how you can correctly analyze the number of operations of computations that are done.
According to the paper I am reading, the following two steps take 3 multiplications and 2 exponentiations.
$$m' = m \cdot \frac{P}{p_k} \cdot (P^{-1}\mod p)... |
Is it possible to perform some sort of pre-processing that would allow to answer the question efficiently (fast)?
The graph is connected, undirected, has no self loops neither parallel edges (a cycle is formed by at least three nodes).
Note that this a yes/no query, meaning that I just need to know whether such a cycle... |
I'm trying to write a regular expression over the alphabet {0,1,2} for the language in which every 1 is preceded by 0. For example 2200201010, 01022020102012 are strings of the language.
I've tried with this:
(0+2)*(01)*(0+2)*(01)*(0+2)*
, where '+' means {0,2,00,02,20,22,.....}.
Is this reg-exp correct?
Thank you
|
I am studying Quantum Computing using the book Quantum Computation and Quantum Information of Michael Nielsen and Isaac Chuang. I am confused by the meaning of the $\oplus$ (addition modulo 2) symbol in the notation.
Given a starting state $|\psi\rangle|\phi\rangle$ and a unitary gate $U$ such that $U|\psi\rangle|\phi\... |
Suppose there is a language $L$ that is not Turing-recognizable. Now suppose, for every word in $L$, you would concatenate a "0" as prefix, resulting in $L' = \{0w | w \in L\}$. Does this mean that $L'$ is also not Turing-recognizable?
I would argue that $L'$ is also not Turing-recognizable:
No Turing machine recognize... |
This question is about modern CPU architectures and multi-threading. I'm mainly interested in personal computers or servers having 2, 4, 8, 16... cores like for example an Intel core i7. I mean not a NASA supercomputer or GPU vector processing.
You have N cores.
You write an algorithm in a low level language such as C,... |
I've seen to explanations for the quick sort algorithm.
One in which a pivot is chosen, and put into place, before both sides of the pivot are recursively pivot-sorted.
Another involved a more complicated solution involving two pivots which interchanged.
What are the benefits of either solution, why was the dual-pivot ... |
I came across this paper, which mentions an interesting variation on SAT:
We call a CNF formula F insensitive if every total assignment α satisfies the same number of clauses of F.
I hadn't come across this before. You can easily define the same property for DNF formulae as well.
Which brings me to the following que... |
Given an array with $n>2$ elements of integer sets intervals, where each set is represented as a tuple of the form $(inf, sup)$ (with $inf $ ínfimum and $sup $ maximum of the set), we want to obtain the two intervals such that the number of elements of the intersection is maximum.
$e.g: A=[(1,2),(1,4),(3,7),(4,7)]$... |
I have an IPv4 packet, 3523 byte of information Data a MTU (maximum transmission unit) of 516 (496 byte + 20 byte IP header), also an TCP header with 20 byte.
How does this result is created from the above information? I always come out at 51 byte Information data for the last package.
3523-(496*7) = 51
Maybe someone ... |
I want to work on a model where I make some manual corrections in my clinical notes data and want the neural network to learn those corrections.The algorithm will be supplied with both corrected and initial documents for supervised learning.
I am now looking for some survey or research papers to start with. I have sear... |
I would like to show a language $A$ is in $NP$.
I can find a TM for $A$, but I wanted to try a different approach and see if it is correct.
Let $B$ be a known problem in $NP$. If I show a polynomial time reduction $A \leq B$, will this imply $A\in NP$?
I believe it will, but I am not 100% sure.
|
I have $8$ sets $E_1, \ldots, E_8$, each one of size $256$, whose elements are $4\times 4$ matrices of (nonnegative) integers. I'd like to design an algorithm to find:
$$\underset{M_1 \in E_1, \ldots, M_8 \in E_8}{\max} ||M_1 \times \ldots \times M_8||_1$$
where:
$$||M||_1=\sum_{i=1}^4\sum_{j=1}^4 M_{i,j}$$
A reasonab... |
I've already programed a grammatical evolution on GPU with a very satisfactory result (an improvement on time of about 140% with relative small datasets, expecting better results whith big ones). Currently, using CUDA, I just 'fill' one core on my GPU, having a low memory usage so i'm thinking about filling every multi... |
As the title states. Let's say we have a set of inputs that define a tree structure. Is it possible to construct an automaton that can perform depth-first search on this data that is not Turing-complete? If so, can we state that the ability to do DFS a sufficient proof of Turing-completeness?
For the purpose of the que... |
What maps to Semantic Analysis the way automata like Finite State Machines and Pushdown automatons map to Lexing and Parsing?
A couple of years ago I came across a paper that presented such a construct; I don't remember much about the paper to be useful, but here's what I think I remember:
I think the paper was from t... |
Given a set of intervals $S = I_1, ..., I_n$, what is the fastest way to find all intervals of $S$ that are completely contained in an interval $I_\text{query}$? It should also support incremental (dynamic) insertion of new intervals to $S$.
Interval trees are not suitable for this, since they are designed to query ove... |
I am interested in implementing abduction over a full first order theory ie it may be non-Horn. (Aside: Almost all the references I've seen for abduction operate over Horn theories eg "Modeling Abduction over Acyclic First-Order Logic Horn Theories in Answer Set Programming: Preliminary Experiments". Is there a reason ... |
I am studying computing as part of my A level course, and my understanding is that all instructions in a RISC architecture should execute in roughtly the same, small number of clock cycles (ideally one).
This leads me to ask how multiplying two (possible very large) numbers takes (roughly) the same time as all the oth... |
I've been struggling with the following problem: how do I find all possible sub-ranges in a range of integers where each segment is at least length 1, and I specify the total number of segments? A couple examples:
segments=2, range=(0,5)
> [0,1],[2,5]
> [0,2],[3,5]
> [0,3],[4,5]
segments=3, range=(0,8)
> [0,1],[2,3],[... |
I was reading the Modular Multiplication page on wikipedia...and could not understand the algorithm to compute $a \cdot b \pmod{m}$.
uint64_t mul_mod(uint64_t a, uint64_t b, uint64_t m)
{
long double x;
uint64_t c;
int64_t r;
if (a >= m) a %= m;
if (b >= m) b %= m;
x = a;
c = x * b / m;
r = (int64_t)(a ... |
I have a reducible control flow graph with only natural loops, produced from a simple DSL. Every node keeps a list of successors and a list of predecessors. I need to make a sequence of nodes out of this CFG with following properties:
All predecessors of a block are located before this block, with the exception of bac... |
I am designing a programming language and I want to give everything the ability to return a value. For example, if I use a block as a right-hand side value, I can assign it to a lvalue:
sum := {
if (a < 0) { a := -a; }
if (b < 0) { b := -b; }
return a + b;
};
Also, if and while statements could return a va... |
I developed an algorithm but just not sure what is the complexity of the algorithm. I provide a brief description of it below:
"For $N$ user case, there are $B(N)$ Decision Variables. $B(N)$ is Bell Number, for those of you who are not familiar with Bell Numbers please be noted that $B(N)$ grows exponentially with $N$.... |
There are plenty of libraries around allowing to draw Bézier paths, but not that much information about how to implement one of those libraries.
The question is: What algorithms are used for drawing Bézier paths?
Current work:
Searching on Internet, I found many documents about drawing Bézier lines (unfilled) using se... |
Def MKP (Multiple Knapsack Problem): Given a set of n items and a set of m bags (m <= n), with
pj: profit of item j
wj: weight of item j
ci: capacity of bag i
select m disjoint subsets of items so that the total profit of the selected items is a maximum, and each subset can be assigned to a different bag whose capac... |
Which algorithm is used for generating random permutations in shuf command in linux
|
Is NP defined as verifiable in polynomial time, or solvable in polynomial time? Verifiable meaning that the solution can be checked in polynomial time, and solvable meaning that the solution can be found in polynomial time?
|
Suppose we have a DAG $G$ with one source node $s$, ie. it has a path to every node, and target node $t$ which every node has a path to it. For a pair of paths from $s$ to $t$ we can define a distance function $d(\cdot,\cdot)$ as:
$$d(P_1,P_2) = |(P_1 - P_2) \cup (P_2 - P_1)|$$
We want to find the maximum value of thi... |
A while ago, I think on Stack Overflow, I saw someone say that Haskell literals can be thought of as functions that don't operate on anything. This makes sense to me but I remember someone else vehemently disagreeing with him.
If I understand correctly, all values in primitive types, or at least those in Bool, are type... |
Let I have 3-QCNF formula.
Classic recursive algorithm for TQBF takes exponential time. However, following divide & conquer modification allows to do it in quadratic time (not sure about correctness, and that's the question).
ctr = 0
for i = 0..n
Step 1. Take i'th clause, find E-quantified variable inside it.
... |
If for every $\epsilon$-NFA their exists an equivalent NFA what is the purpose of ever using an $\epsilon$-NFA? I am having trouble understanding what the practical purpose of using one would be.
|
I need to implement a collection DS that exposes an iterator which can be used to iterate an underlying collection and possibly remove the current item. I can use either a vector (dynamic array) or a linked list as an underlying DS. I'm inclined toward toward linked list because of the easiness of operations. Is it a g... |
Recall that $G$ has a clique of size $k$ if it has a complete sub graph consisting of $k$ vertices.
Let us define the problem $Clique-k$ as follows:
$$\{ \langle G \rangle \mid G \text{ is an undirected graph that contains a clique of size } k\}$$
Question: Find a reduction $f$ from $Clique-6$ to $Clique-3$ such th... |
I wanna determine whether an image belongs to warm/neutral/cool tone. I find Kelvin color temperature to calculate the average temperature of an image over all piexls. But the result seems not good. Can anybody point in the right direction to determine the tone of one image?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.