instruction stringlengths 35 29.1k |
|---|
I was going through the classic text "Introduction to Automata Theory, Languages and Computation" by Hopcroft,Ullman,Motwani where I came across the simulation of a turing machine using a real computer. There the author argued that it shall be almost impossible to carryout the above simulation (not considering universa... |
Suppose you have a system that consists of $m$ slow machines and $k$ fast machines. The fast machines can perform twice as much work per unit time as the slow machines. Now you are given a set of n jobs; job $i$ takes time $t_i$ to process on a slow machine and time $\frac{1}{2} t_i$ to process on a fast machine. The g... |
Assume that Alice and Bob are respectively given two strings $x \in \{0,1\}^n$ and $y \in \{0,1\}^n$ such that the hamming distance between $x$ and $y$ is either $> n/2+\sqrt{n}$ or $< n/2-\sqrt{n}$.
Alice picks a set $A \subseteq \{1,...,n\}$ of size $k$ uniformly at random, and sends to Bob the set $\{(i,x_i) \mid i... |
Consider a set of n elements whose key values are $$0, 1, ..., n−1.$$ Let $p(i) (0 ≤ i ≤ n−1) $ be the probability that the element with key i is searched. Assume the following distribution of $p(i)’s$:
$$p(i) =
\begin{cases}
1/2^{n−1}, & \text{if i = 0} \\
1/2^i, & \text{otherwise}
\end{cases}$$
Assume linear search... |
I would appreciate anybody's help with a problem I am trying to solve.
A little background:
given is a social network consisting of people represented as a directed graph, with edge from person A to person B if person A is a follower of pers B on that network. For any set S of people, we say that S reaches all people... |
We have to maintain an array $a_1,\ldots,a_n$ supporting the following operations:
Assign $a_i = x$
Given $\ell,r$, return $\sum_{i=\ell}^r a_i$
Given $\ell,r$, return $\sum_{i=\ell}^r \sum_{j=\ell}^r a_i a_j$
Given $\ell,r$, return $\sum_{i=\ell}^r \sum_{j=\ell}^r \sum_{k=\ell}^r a_i a_j a_k$
After $O(n)$ initializa... |
I wrote a program recently which was based on a recursive algorithm, solving for the number of ways to tile a 3xn board with 2x1 dominoes:
F(n) = F(n-2) + 2*G(n-1)
G(n) = G(n-2) + F(n-1)
F(0) = 1, F(1) = 0, G(0) = 0, G(1) = 1
I tried to calculate the complexity using methods I know such as recursion tree and expansio... |
When given the string and the property in question as a potential certificate. Is there any classification theorem that says something along the lines of: all properties (of strings) that have this property (as a sub property) are verifiable in polynomial time?
Are there any collections of types of patterns in strings ... |
Problem Statement
I came across this problem here. For given arrays $A$, $B$ and $C$ arranged in ascending order, we need to minimize the objective function $f(a, b, c) = \max(a, b, c) - \min(a, b, c), a \in A, b \in B, c\in C$.
It can be thought of as a problem to select a number from each of the three arrays such tha... |
I'm not exactly sure how to approach this problem. I was thinking we would need to detect a vertex in a cycle, then run DFS on it while also orienting the edges along each vertex u in the cycle, to be directed from u to some vertex v incident to it. But I am not sure what edges cases I might be overlooking, or whether ... |
For school I have a big assignment on hashtables etc. One of the functions is a size_t function where we calculate the hash value. (Keep in mind the structure of every function is given so we are not allowed to change input variables/function types). However, the hash calculator function does need to handle errors, but... |
I have a directed graph that has positive weights (but there are reverse arcs) and I am trying to find the shortest path between a given source, s and a given sink, t but the path should also contain two given arcs in a sequence. Say we are given arcs a1, a2, we want to find a simple shortest path that goes from s to t... |
In a simple uniform hashing with chaining collision, the time complexity of a successful search is: $Θ(1 + (1 + \frac{α}{2} - \frac{α}{2n}))$ where $α=\frac{n}{m}$, but I don't understand how to determine it.
I tried to calculate the cost of access of each node in the list and to divide it by the number of elements of ... |
Are unguarded affine programs Turing-Complete?
Are affine programs with affine guards Turing-Complete?
Unguarded program: all branches are taken
Affine program: only assignments like $x:=x_1+5x_2-x_3+4 $(Affine equations as right hand)
Affine guards: all conditional branches have only affine guards, for instance $x_1+x... |
Does it simplify to $O(\log n)$ or $O(\log^2 n)$ or something else entirely? I am a bit stuck on this one.
|
Let's say I have an alphabet
$$\Sigma = \{A, B, C, D, E\}$$
with probabilities
$$P(A) = P(B) = P(C) = 0.25 \text{ and } P(D)=P(E) = 0.125.$$
I know that the entropy then is:
$$H(\Sigma) = 3 \cdot 0.25 \cdot \log 4 + 2 \cdot 0.125 \cdot \log 8 = 2.25.$$
My question now is: What does this mean in relation to the lower li... |
The capacity of a noisy channel $\mathcal{E}_{X\rightarrow Y}$, where the channel is given as a conditional probability distribution $p(y|x)$, is
$$C = \max_{p_X}I(X:Y),$$
where $I(X:Y)$ is the mutual information and $p_X$ is the input probability distribution. This optimization problem is concave. The Blahut-Arimoto ... |
My question is why O(nW) at the knapsack problem is pseudo-polynomial.
I read lots of the explanation at stackoverflow, But I don't really understand it.
(https://stackoverflow.com/questions/19647658/what-is-pseudopolynomial-time-how-does-it-differ-from-polynomial-time,
https://stackoverflow.com/questions/4538581/why-i... |
Given a set of points $P=p_1,p_2,..p_n$ in $R^2$ in where $p_i=(x_i,y_i)$,finding the point with smallest x-ordinate having y-ordinates between $y_1$ and $y_2$, where $y_1$ and $y_2$ are given as inputs. I can compare the point with other points which gives me an $O(n)$ time algorithm ? Can this be improved any further... |
I have some propositions regarding BSTs , please can someone confirm whether they are true or false:
Question :
1.Suppose we have a node $n_1$ with a value $val_1$ i.e $n_1(val_1)$
2.We wish to find the number of children of the predecessor node of $n_1$ , with respect to inline traversal (That is the number of
chil... |
I have an array $a_1, a_2, \dots, a_n$. After $O(n)$ preprocessing, I want to be able to compute each of the following in amortized $O(\log n)$:
Given $l,r,b,d$, for each $i \in \{l,\ldots,r\}$, increase $a_i$ by $b + (i-l)d$.
Given $l,r$, compute $\sum_{i=l}^r a_i$.
|
Turing machines and neural networks are equivalent in their expressive powers, but as models of computation they are different. Turing machines come pre-configured with their transition functions while the neural networks configure weights to build learnable computable functions using input data.
Is the class of proble... |
In the original paper in Goemans-Williamson paper for max-cut, we need to sample a random vector r and
we output
$$
S = \{i : r^{T}x_{i} \geq 0\}
$$
where $x_{i}$ are column vector of a feasible solution of the SDP relaxation.
My question is are we guaranteed that there exists a certain $r$ such that the output is ma... |
What exactly is the top view of a binary tree?
I find great ambiguity and lack of clarity from the articles I find.
For example, this is what is used to demonstrate the top view on geeksforgeeks:
1
/ \
2 3
/ \ / \
4 5 6 7
They go on to say that the top view is 4 2 1 3 7. The probl... |
I can't seem to find the explanation for why RW stage of a single cycle processor takes the shortest time to execute. Can anybody explain why this is so.
|
I am trying to reduce the Halting problem to show another problem is undecidable. The problem involves a program that is true if a machine $M$ writes to an arbitrary amount of memory, and false if it writes to a finite amount of memory cells. I am now thinking, is writing to a finite amount of memory cells equivalent t... |
F = {ww | w ∈ {0,1}^*}
Which strings are accepted and why?
0011
1010
1111
|
I would like to ask a question about fundamentals that are used intuitively in
solving a simple probabilistic task about sampling with replacement. However, when I start to think about underlying fundamentals, things become complicated.
Consider a bucket with three balls: two red (R) and one black (B). We randomly sele... |
Show that the language L = {< M1 > | M1 is a Turing machine that accepts 0} is Turing recognizable. I was told by my professor to go about this proof by giving an informal description of a Turing Machine 'V' that would accept 'M1' if and only if 'M1' was a Turing Machine that accepts 0.
Below I have the informal descri... |
I am trying to reduce the Halting problem to show another problem is undecidable. The problem involves a program that is true if a machine
writes to an arbitrary amount of memory, and false if it writes to a finite amount of memory cells. I am now thinking, can we somehow deduce if the machine halts based on if it wri... |
I am trying to prove that for a NP problem that is complete, its complement co-NP should be complete as well.
We know that a decision problem A $\in$ NP-complete if a) it is in NP and b) if every other NP problem is polynomial-time many-one reducible to it. There is a similar relationship between co-NP-complete and co-... |
I read many writing about the time complexity of 0-1 knapsack problem.
(https://stackoverflow.com/questions/4538581/why-is-the-knapsack-problem-pseudo-polynomial#answer-4538668)
In conclusion, the time complexity of knapsack problem is O(nW) but it is pseudo-polynomial
because the size of W in binary encoding system is... |
I'm looking for an efficient way of testing eights. What happens is I need to check if a value is eights and discard it.
The numbers I need to check for are:
8.8888, 88.888, 888.88, 8888.8, 88888.00 // 5 digits
88.8888, 888.888, 8888.88, 88888.8, 888888.00 // 6 digits
888.8888, 8888.888, 88888... |
We know that LP can solve optimization problems that have linear constraints and linear objective functions.
A knapsack problem can be formulated into a linear objective function (because it is just a summation of Pi*Xi) and linear constraints (because it is just a summation of the items weights which should be <= the ... |
For the algorithm that I have written the complexity is something like:
a * e(A) + b * e(B) + b * e(C) + ...
Where a represents the instance count of some node A and e(A) the edges outgoing of node A. Also if we say:
a + b + c + ... = n
e(A) + e(B) + e(C) + ... = e
Then I can say that the complexity is
O(n*e)
Is there... |
So say I have n numbers, where n is even. I want to pair the numbers such that the maximum sum of the pairs is minimized. For example -2, 3, 4, 5. The ideal pairing is (-2, 5), (3, 4), since its maximum sum is 3 + 4 = 7, and that is the minimal sum possible for a max sum in any pairing. The key to the algorithm is to s... |
Is there a way to get O(1) without extra space in the union find algorithm?
Imagine I have 3 sets
set1 = {1, 3, 5, 7}
set2 = {4,20,25}
set3 = {9, 13}
Now imagine I have a new edge between 3 and 20. So I would need to merge set1 and set2, but before I do that I need find which set 3 belongs to and which set 20 belongs ... |
It is said commonly that a software video encoder has creates higher quality output than hardware encoder. Higher quality here means higher picture quality at a given bit rate.
Hardware encoders are commonly for realtime usage and some are for mobile applications, then there are trade offs in hardware encoders to get r... |
I realize that each time I have to deal with the Big-O notation I am questioning myself why complexity in time or space share the same formal notation/letter. It is always confusing when I read examples in books because authors don't always give precision about whether the given result is a time or space complexity.
S... |
Working on a question were I should construct a deterministic finite automaton for the language
$L=\{w\in \{0,1\}^* \mid |w| \mod 2 =0 \lor |w|_0 \mod 3 =0 \}$
The DFA for the two sublanguages is clear, and also howto construct a nondeterministic automaton from these. However my DFA look horrible complicated. Is there ... |
Alright, first here's the text of the problem:
You're given n bags of candies where the i-th bag contains a[i] candies and all numbers a[i] are in the segment [1,m]. You can choose a natural number x and each second remove x candies from one of the bags if it contains at least x candies. The goal is to empty all th... |
The problem $1||\Sigma w_jU_j$ of minimizing the weighted number of tardy jobs in a single machine is NP-hard. This is well known and can be shown by reducing the knapsack problem to it.
Also, when the jobs have arrival times, the problem $1|r_j|\Sigma U_j$ of minimizing the number of tardy jobs in a single machine is ... |
What are the earliest known uses of the "greater than"/"chevron" symbol (>) to denote a parent-child relationship in a tree structure? i.e. parent > child
e.g.
CSS Child Combinator (initial definition)
Breadcrumbs
|
What is the time complexity of
1.cos(x)
2.acos(x)
3.acos(cos(x))
Please answer
|
I am aware that to get a running time by recursion tree method, we need to draw a tree and find:
a) number of levels in tree.
Since left side of tree decreases by 1 in size, so it's longest path from root. Subproblem size at level i is n-i . setting n - i = 1 when it hits a size of 1, we get number of levels, i = n... |
I'm looking for any programming language, DSL, library or pattern for live scripting but minimizing the expressions reevaluation.
Topological sorting provides non-revaluation of expressions.
Memoization provides a simple way of not re-evaluating but is a waste of memory.
A form of topological ordering can be achieved b... |
Let's say a person picked up a fruit and wanted to identify it.
The person knows certain features about the fruit, such as its color and where it was plucked from, but not its name. They also have knowledge that's relevant for identifying the fruit, but they're not aware that it's relevant (such as the color of the soi... |
L is a regular language. Let's say that E is one of L's equivalence classes - is it true/false that E is also regular?
The equivalence relation is, from Wikipedia: "Given a language L, and a pair of strings x and y, define a distinguishing extension to be a string z such that exactly one of the two strings xz and yz be... |
I have to write an algorithm that solves below problem statement -
There is a project requirement which has list of titles:-
"JobTitles" : [
"Developer",
"Programmer",
"Java Developer",
"Java Software Engineer",
"Java Software Developer",
"Application Architect",
]
There is a list of ap... |
We can use the induction hypothesis when we are proving a property for a structure that is well-ordered. I am aware that there is a proof for this.
When it comes to coinduction, I'm confused.
One of the answers to another question "What is coinduction?" mentions that there is a notion of a corecursive definition to be ... |
I'm putting together a personal list of recipes that I enjoy, and would like to construct an algorithm that parses this recipe database and automatically builds me a meal plan for the week.
For N number of meals per day, find permutation of recipes that comes the closest to satisfying these conditions:
Sum of meal cal... |
You have a Turing machine which has its memory tape unbounded on the
right side which means that there is a left most cell and the head cannot move left beyond it since the tape is finished. Unfortunately, you also find that on execution of a head move left instruction, rather than moving to the adjacent left cell, ... |
If you have n vertices and m edges, how would you find the shortest cycle of a bipartite graph in O(n^2) time? To do it in O(nm) time, it is simply a BFS on every single vertex. I do not understand how you can do it just by going over every single vertex. I know you would have to stop at non-tree edges to do so, but ho... |
I would like to know how to prove that the Job Scheduling decision problem is strongly NP-complete using 3-partition.
Input: A set of $n$ tasks of length $t_1, t_2, \ldots t_n \in \mathbb N$ and $k$ processors.
A feasible solution is a function $\alpha: \{1, \ldots ,n\} \rightarrow \{1, \ldots k\}$ which assigns each ... |
I'm solving a problem:
Given a directed, weighted graph $G$ that has $V$ vertices (vertex $0$, vertex $1$, ... , vertex $(V - 1)$) and $E$ edges and a positive integer $m$, describe an algorithm that finds the length of the shortest path from vertex $0$ to vertex $(V - 1)$ using less than or equal to $m$ edges. Note ... |
I'm new to Optimization and aproximation problems
I would like to know if the following statements are true or false and why :
If the optimization problem $K$ admits a PTAS then $K$ admits an approximation algorithm with
approximation ratio 2.
If there is an FPTAS for MIN-TSP then $P = NP$
|
I searched the pages a lot about the search problem but didn't understand much, so please make it clearer for me.
WIKIPEDIA:
In computational complexity theory and computability theory, a search problem is a type of computational problem represented by a binary relation. If R is a binary relation such that field(R) ⊆ ... |
As I have read in this answer: What is tail recursion? tail recursion is a special case of recursion where the calling function does no more computation after making a recursive call.
Here after the recursive call we just assign the result to another variable.
Can we consider this code as tail recursion?
class Solutio... |
Is the language $\{ w=w^R \mid w \in \{0,1\}^* \}$ a context-free language?
I am confused in deciding whether the language is context-free or not, that is one of my problems, I do a pumping lemma proof and what I get is that it is not a context-free language, but I want to make sure again.
|
Is the following language decidable?
$$ L = \{ \langle M,w \rangle \mid \text{$M$ moves its head left at least once when run on $w$}\}. $$
I feel like this is a decidable language. But I don't know the algorithm to prove that it is decidable. Any help would be appreciated.
|
I am looking for an approximation algorithm for the Maximum Coverage problem and a proof of its approximation ratio. As approximation algorithm I use the greedy algorithm which chooses the set that maximizes the number of new elements at each turn (same as the one proposed in the Wikipedia article). However it is not a... |
I have recently started studying the monotone complexity classes. There doesn't seem to be a single/clear containment hierarchy or single source regarding the same. Can we create one?
The classes are namely: $mTC^0, mNC^0, mNC, mAL, mcoNL, mL, mNL, mP, mNP, mP/Poly$. (I think that covers most)
The relationships I am aw... |
The hash value of a string $s$ is given by
$$
h(s) = \sum^{|s|}_{i = 1} s_i \cdot p^{|s| - i} \mod m; \text{ $m$ is prime, $m < 10^{12}$}.
$$
The string $s$, $p$, $m$ is given,
$|s| \le 14$, alphabet size $= 62$ (letters and digits).
I need to
find a string $s^{\prime}$:
$s^{\prime} \neq s$, but $h(s^{\prime}) = h... |
I already asked this question over on Mathematics and got the suggestion to ask it here.
So I'm basically implementing a number type that can represent all fractions and was working on an algorithm to compute the decimal expansion for said fractions.
Let's say we have the reduced fraction $\frac{n}{m}$. For converting ... |
Consider the language
$$ L = \{ \langle M,w \rangle \mid \text{$M$ on input $w$ tries to move its head past the left end of the tape}\}. $$
Prove whether L is decidable or not.
I tried to prove it as undecidable through reduction method but could'nt reduce the language halt to L inorder to prove that it is undecidab... |
I'm looking for an efficient algorithm for the following problem:
Input: a rooted tree (undirected) with a cost on each edge. It could be considered directed away from the root (or towards the root).
Output: a subtree from the root that has the minimum average cost per edge.
There are some results for minimum average-... |
How to prove that recursive and recursively enumerable language is closed under reversal?
Why recursively enumerable language is not closed under set difference? [But intersection of recursive and recursively enumerable language is recursively enumerable]
|
CLRS states that:
For some set $I$ of problem instances, we say that two encodings $e_1$ and $e_2$ are polynomially related if there exist two polynomial-time computable functions $f_{12}$ and $f_{21}$ such that for any $i \in I$, we have $f_{12}(e_1(i)) = e_2(i)$ and $f_{21}(e_2(i)) = e_1(i)$.
My understanding of ... |
How to show that Max-cut$_{dec}$ is NP-complete using Mon-NAE-3SAT ?
Mon-NAE-3SAT definition :
An instance is a m clauses of three positive literals (no complemented variable) $x \vee y \vee z$
The question: is whether there is a Boolean assignment that ensures that each clause contains at least one variable
Max-cut$_... |
I came across this question:
You are given a permutation cipher defined by the bijection t: N -> N where,
t(i) = i + 10, for i < 10,
t(i) = i - 10, for 10 <= i <= 20, and
t(i) = i, for i > 20.
Assume that the first index is 0, given a message m = 'HELLO WORLD AND THIS IS A SECRET MESSAGE', what is the ciphertext c?
W... |
What problems might exist if halting problem is solved. If there exist an oracle that can compute whether a given machine halts or not then what would be problems that could exists if such oracle is there
|
I have a linear regression model that I've implemented using Gradient Descent and my cost function is a Sum of Squares Error function. I've split my full dataset into three datasets, a training set, a validation set, and a testing set. I am not sure how to calculate the training error and validation error (and the diff... |
I am trying to solve the job secheduling problem using the Longest processing time rule, that is: We seek to minimize the makespan by first sorting the jobs in decreasing order of processing time, then the algorithm makes one pass through the jobs in any order; when it comes to job $j$, it assigns $j$ to the machine wh... |
I'm studying complexity classes and the diagram in NP-Hardness article is confusing to me.
NP-hard has all problems that can be reduced in polynomial time from a problem in NP to them. P is contained in NP. Then it is possible to reduce a problem X in P to a problem Y in NP-hard? This does not add up to me in the scena... |
I have a task, and its essence is as follows: how many knights on an $n \times m$ board can be set so that they do not attack each other. I am wondering if there is any mathematical solution to this problem, except for the algorithmic one.
|
Consider the algorithm below which calculates a V cut
Initialize $V_1 = V$ et $V_2 = \emptyset$
Attempt to improve the value of the cut in any of the following ways
Check if there is a $v \in V_1$ such as $c(V_1-\{v\}, V_2 \cup \{v\}) > c(V_1,V_2)$
If yes continue with $V_1 = V_1 -\{v\}$ et $V_2 = V_2 \cup \{v\}$.
Ch... |
I came across this riddle link question:
Your name's Graham.
Bob wanted to send Alice a secret msg m. However, he was concerned about the security. He encrypted his message with a keyword that both of them knew. Several weeks before this, you overheard them exchanging the keyword k = 'EZRA'. Now, Bob has asked you to ... |
Given an input string W, a description of a turning machine M, and a target output string O (W,M,O) as input, when can a machine M' decide, in fewer steps than simply running M on W, if running M on W, in fact, produces O or not?
What are the circumstances under which this faster M' exists and when is this impossible, ... |
Given a set of 10 integers $A = a_1, a_2, \cdots a_{10}$, is there an efficient algorithm which can tell me what's the probability a randomly chosen integer between $1$ and $10^{10}$ is NOT divisible by any member of this set.
I understand the Inclusion-Exclusion principle can be used to solve this problem but I can't ... |
I've seen a number of questions and answers related to the partitioning problem of dividing a set into 2 subsets of equal size and sum that use greedy or dynamic programming solutions to get approximate answers. However, I am looking to split a set into 2 subsets of minimum difference in size but with a target ratio of... |
Imagine my server is generating "tokens" of some sort for a client on a regular basis. When a client asks for a token, the server responds with a new value (and any other supplemental information it wants to, like a "witness"). Later, the client will submit the token (and optionally the witness) and the server needs to... |
I have a recursive sequence: $a_n = 5a_{n - 1} + 2a_{n-2} + 3$, for $n > 1$. And I could return $k-th$ member in $O(\log{k})$ of sequence i.e. $a_k$.
I know how to get the formula of the $k-th$ member using the generating function method, but I need to find a more algorithmic solution.
For example, like this one.
|
Consider the following greedy algorithm for Job Scheduling. For each new task, assign the task to processor with the shortest uptime.
How to prove that this algorithm has an approximation ratio of 2?
Suppose that once the algorithm is completed, processor $1$ is the busiest and assume task $l$ is the last task assign... |
How to solve the recursion:
$
T(n) =
\begin{cases}
T(n/2) + O(1), & \text{if $n$ is even} \\
2T(\lceil n/2 \rceil) + O(1), & \text{if $n$ is odd}
\end{cases}
$
I know that it can be written as O(n). But I want to find a tighter bound. For example, when dealing with powers of two, T(n) is O(logn), which will most prob... |
I have an intuition that topo-sort of an original graph
A -> B -> C
D -> B
topo-sort is [D, A, B, C] or [A, D, B, C]
If I transpose the graph
C -> B -> A
B -> D
the postordering dfs of this transposed graph also gives [D, A, B, C] or [A, D, B, C]
Please, I can't mathematically prove/disprove it.... |
How to solve the recursion:
$
T(n) =
\begin{cases}
T(n/2) + O(1), & \text{if $n$ is even} \\
T(\lceil n/2 \rceil) + T(\lfloor n/2 \rfloor) + O(1), & \text{if $n$ is odd}
\end{cases}
$
I think $T(n)$ is $O(\log n)$. Can somebody show a proof?
|
I would like to verify that the following language is not regular.
I know that if the pumping lemma is not valid then the language is not regular. (but its not enough to prove that the language is in fact regular if the pumping lemma is valid)
So, given the following language,
$\Sigma =\{a,b\}$,
$L=\{v\cdot u\cdot u: v... |
I have a simple quesiton:
It is conjectured that All Pairs Shortest Path (APSP) has no $O(n^{3-\delta)}$-time algorithm for any $\delta >0$ by SETH.
also
there is a result that says APSP can be solved in time $\frac{n^3}{2^{\Omega(\sqrt{\log n})}}$ by Ryan Williams.
But, this improvement doesn't refute the conjectu... |
I have a set $F$ of $n_1$ families, a set $C$ of $n_2$ children ($n_1<n_2$) and a set $M$ of feasible one-to-one matchings of the families with the children. All the children have the same preference list over the families, but the families have different preference lists.
Our objective is to select from the set $M$ a... |
For a mental exercise, I decided to try out my own simple sorting algorithm which processes an array of integers in any order, and as it passes thru them all, records the highest and the lowest. So imagine an array of size 10 with elements (9, 2, 4, 1, 6, 8, 5, 3, 7, 0) in that order. We want the algorithm to sort th... |
I have an undirected graph, where the value of the path is the maximum weight among all weights
edges included in it. And I want find the path of minimum value between two given vertices in time $O(n + m)$, where $n$ - number of vertices, $m$ - number of edges.
|
I'm reading the source code of JPlag and came across their rabin-karp algorithm implemented found here.
Here's the gist of it:
// modulo = 63
for (i=0; i<loops; i++) {
hash -= factor * (s.tokens[i].type & modulo);
hash = (2*hash) + (s.tokens[i+hashLength].type & modulo);
... |
I was trying to solve a problem with a mapping reduction from $A_{TM}$ to $INFINITE_{TM}$, and came across a solution that was 100% identical to another solution I saw for $A_{TM} \leq_M ALL_{TM}$. This is the reduction:
$M_f$: Given an input of $\langle M, w\rangle$, where $M$ is a $TM$ and $w$ is a word:
Define a TM... |
I figured out an algorithm to compute the square of a number (power of 2) in a recursive way backwards or forward. I don't think I have ever seen this anywhere else before, so I am curious if this already exists / does it have a name?
I put comments in the code that explain the whole idea. But I will TL;DR here:
TL;D... |
I've been working on a matrix-library in C++ for a while and amongst other functions, I've implemented two functions for calculating the determinant of a matrix:
Gauss-Algorithm:
This algorithm is based on the fact that the determinant of a triangular matrix equals the product of it's diagonal entries. Therefore it is ... |
I have an unweighted undirected graph.How is it possible in this graph for each vertex to find the length of the shortest cycle containing it?
P.s
This graph have not non-tree edge, but it have a cycle. What can be considered subtrees of the vertical 10? How will the algorithm work when the BFS reaches 16 and 17?
|
What is a Context? Is it like a scope in C? Does it have a start and an end? Can contexts contain other contexts?
I see Contexts being used in lambda calculi type system rules, but I don't understand concretely what they are and why they are necessary. If they are too abstract, then is there some visual or metaphorical... |
define a m-partition as: Given an undirected graph G = (V, E) and an integer j. Does there exist a partition of the vertices into m parts {V1, V2, ... , Vm} such that at least j of the edges have their endpoints in different parts of the partition?
I started by partitioning the graph into k parts: each partition repres... |
Let's start from finding a minimum hitting set problem. Given a collection of sets $U=\{S_1,S_2,S_3,S_4,S_5,S_6\}=\{\{1, 2, 3\}, \{1, 3, 4\}, \{1, 4, 5\}, \{1, 2, 5\}, \{2, 3\}, \{4, 5\}\}$, it is easy to know that a minimum hitting set is $\{2,4\}$.
I am thinking what this "hitting set" problem would be if the set $... |
Taking a sequence, I am looking to calculate the minimum amount of continuous palindromic subsequences to build up such a sequence. I believe the best way is using a recursive DP algorithm.
I am having trouble picturing the problem space or the most efficient way to do it. (For example, is it best to find the longest p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.