instruction stringlengths 35 29.1k |
|---|
Is there any generic algorithm which implements a floating point radix conversion?
Lets say we have a $p$-digit FP number
$A = \sum_{i=0}^{p-1} A_i \beta^{e-i}$
in radix $\beta$ and with $0 \leq A_i < \beta$.
How do we find the $A'_i$, $e'$ values for the $p'$-digit base $\gamma$ FP number
$A' = \sum_{i=0}^{p'-1} A'_... |
I'm trying to learn how the "failure table" is constructed in the Knuth-Morris-Pratt algorithm since it seemed nontrivial to me that you could do it in $O(k)$ time (where $k$ is the length of the pattern, $W$). To be clear, we let the failure table $T$ be a length $k$ array where $T[i]$ is the length of the longest pro... |
Let $A$ be an alphabet and $u,v\in A^{*}$ be words. If it exists $z, u', u'', v', v'' \in A^{*}$ such as: $u = u'zu'' $ and $v = v'zv''$ then $z$ is a substring (also known as factor) of both $u$ and $v$ (i.e. “common”).
Is there a fairly standard or acceptable notation to denote either:
The predicate: “$u$ and $v$ ha... |
I'm currently debating with some friends what is the Big O space complexity of this isAnagram method:
public boolean isAnagram(String firstWord, String secondWord) {
if(firstWord == null || secondWord == null || firstWord.length() != secondWord.length()) {
return false;
}
Map<Character, Integer> ch... |
I've already attempted it but I am finding it difficult to understand if this is correct.
give a context free grammar for the following:
$$ \{p^{3m+n}q^nr^2p^m\mid m,n\ge 0 \}$$
The answer i've attempted is:
$S \to XY$
$X \to pppXp \mid \ q$
$Y \to qYr \mid \epsilon$
I've been trying to understand if i need to break d... |
When reading discussions of Gödel's theorems one is always heeded that just because formal system $F$ proves a theorem $T$ that doesn't necessarily mean that when one applies the intended interpretation the theorem is actually true. After all, even if one assumes that $F$ is consistent, it might still be unsound.
But t... |
Let $x_1,x_2,x_3,x_4$ be boolean variables (i.e $x_i \in \{0,1\}$)
Consider
$f(x_1,x_2,x_3,x_4) = x_1 \wedge x_2 \wedge x_3 \wedge x_4 $
I want to write $f$ in terms of two-input NOR gates. I.e, $\mbox{NR}(x,y)= \neg ( x \vee y ) $.
What is the minimum number of NOR gates to write it?
I found that it can be done with ... |
When I search unit interval graphs in ISGCI, it says that the unit interval graphs (UIG) are equivalent to ($C_{n+4}$,$S_3$,claw,net)-free graphs.
I am confused about the definition of an $S_3$ graph.
I am aware that in some resources, $S_n$ means $K_{1,n}$, and in others $S_{n-1}$ means $K_{1,n}$.
However, in both cas... |
Past year paper question:
Let $M_i$ denote the Turing machine with code $i$ using the alphabet $\Sigma=\{a,b\}$.
Show that the following language is not recursively enumerable:
$L = \{a^i \;:\; (\exists x \in \mathrm{Lang}(M_i))\;[ xx \notin \mathrm{Lang}(M_i) ] \}$
I tried to show that we can reduce $L_e$, the set of ... |
I am trying to solve this problem listing all prime numbers less than an integer but using the smallest amount of memory.
Is it possible to solve this problem using a smaller amount of memory?
int main ()
{
int n = 10000;
for (int i=2; i<n; i++)
for (int j=2; j*j<=i; j++)
{
if (i ... |
Construct a DFA $M$ with $\Sigma = \{a\}$ and max. 11 states so that $a^{23}\not\in L(M)$ but $\{a^i|i\geq 24\}\subset L(M)$.
I don't see how it is possible? Because it's a DFA and the alphabet only contains $a$, shouldn't I only be able to look at modulo 11? I could make 1 mod 11 not accepting but then $a^{34}$ would... |
According to Wikipedia, while the 2SAT problem is polynomial, its maximization variant MAX2SAT is NP-hard. But, they do not provide a reference for this claim. Is this obvious? If not, where can I find the reduction used to prove this claim?
|
I am trying to create a regression model using a Neural Network. I am currently learning how to work with neural networks (deeplearning.ai) and so the model is not implemented using any existing frameworks like keras.
Based on what I have learned,
the model is configured to use no activation function in the output
la... |
In MAX-SAT, we are given a formula and want to maximize the number of satisfied clauses. I.e., given a formula $\phi = c_1 \cap \cdots \cap c_n$, where each $c_i$ is a disjunction, we want to find the largest $k\in\{1,\ldots,n\}$ such that, for some assignment, some $k$ clauses $c_{i1},\ldots,c_{ik}$ are true.
In MAX-M... |
I have been wondering this question because given a number $n$ with prime factors of the form $4k+3$ when we square $n$ and find a sum of two squares which should reveal these types of factors (as when we find non-trivial answers they have a gcd above 1 etc.). However, when a number solely has prime factors of form $4k... |
I'm a noob reading Michael Sipser's Introduction to the Theory of Computation, and I'm at a part where he's demonstrating how to construct finite automata that accept languages described by regular expressions. He does this by giving regular expressions, breaking them down into simpler regular expressions that represen... |
Let's say $h_1(n) \geq h_2(n)$ so that dominance is established even if $h_1$ and $h_2$ are both inadmissible/non-optimal heuristics -in whichever given search space.
Is $h_1$ still faster/better than $h_2$ or does the dominance rule only apply to admissible heuristics?
Also, if I could ask for a bit of extra help, ca... |
I am currently converting this NFA to a DFA
I have come up with the following DFA:
0 1
->A {A} {B}
B {CA}
*CA {A} {AB}
AB {CA} {B}
Although, I have no idea what to put for B. In the NFA, upon the B receiving 1 input, it goes nowhere - assumable unaccepted by the NFA. Do I send the... |
What is meant by a short pipeline?
Does that mean the instructions are split into small number of pieces OR length of a piece is short?
|
If uncomputable numbers existed, could this hypercomputation machines compute them? Could hypercomputation compute all types of uncomputable things? Even truly inconsistent things? Even things that cannot be described by any type of information (like a way of factorizing number 181 using classical mathematics, the math... |
Average memory access time = Hit time + Miss rate * miss penalty
Assume a computer with only one cache level. What is the exact meaning of hit time? Is it the number of clock cycles to access data from cache? OR Clock cycles to execute an instruction? How does the number of clock cycle per instruction come into this e... |
For a homework assignment, I have to prove that a given language $L \in coNP$.
I understand that one way of doing so, would be to prove that $\bar{L} \in NP$, i.e. give a polynomial time verifier for $\bar{L}$.
I am having trouble understanding what the complement of the language would be. eg: if
$$L = \{ (a, b, c) \i... |
We are given a set of $n$ coins with denominations $v_1,v_2,\ldots,v_n$ and a number $x$.
The coins are to be divided between to persons, with the restriction that each person's coins must add up to at least $x$.
For example, if $x=1$, $n=2$, and $v_1=v_2=2$, then there are two possible distributions: one where Person... |
In a programming class I take, we briefly (very briefly) touched lambda calculus. I think I have a pretty good grasp of the basics now, but one example given I just don't understand. Am I missing something or is the example possibly false?
$\lambda x.x \; (\lambda y.2*y) \; square \; 3$
The solution to this was $6$, be... |
I am studying computational complexity and i am trying to solve this problem.
We are given a (non-bipartite) complete graph:
G = (V, W, E)
where the vertices can be divided in two classes V and W and the edges between any two vertices are weighted either 1 or 0.
w(x, y) = {0, 1} ∀ x, y ∊ V ∪ W
We need to:
calculate a ... |
Given the following graph:
With the assumptions below:
A node on the left is linked to several nodes on the right
Nodes on the right are paired together: one is black, one is white
Each pair of nodes on the right can be swapped (black becomes white and white becomes black)
A node on the left is green if linked to onl... |
I am working on a recursive descent parser for lambda calculus. In my grammar, after removing left-recursion, I am left with the following two productions:
# APPLICATION -> ATOM APPLICATION'
# APPLICATION' -> ATOM APPLICATION' | ε
Both APPLICATION and APPLICATION' correspond to the same type of node in the AST... |
If its proven today that $P=PSPACE$ the whole polynomial hierarchy collapses. Moreover since $BQP \subseteq PSPACE$, it will also result in $P=BQP$.
However unlikely the above scenario is, hypothetically if this were the case what are the complexity classes (the most important ones) that will survive this collapse into... |
Context:
I play in a simulated online basketball league (a la the NBA) where each human player controls one of the teams. When each simulated basketball player is a free agent (that is, their previous contract with a team has expired) they field offers from teams and a group of moderators decides which team that player... |
When you have an algorithm that may skip a lot of iterations due to a hash table lookup, do you still count the iterations that are exited immediately?
Hypothetical example:
var n = input.length; //eg, [1,4,6,2,0,8]
for (var i = 0; i < n; i++) {
visited[i] = true;
for (var j = 0; j < n; j++) {
if (visited[j] ... |
I am currently studying algorithms and algorithmic design, and I am confused those terms. What is the difference between them?
Thank you.
|
I'm trying to prove (by induction) that BFS in equivalent to DFS, in the sense that they return the same set of visited nodes, but I'm stuck in the middle of some of the cases.
Let $G$ be a directed graph and $u \in V(G)$.
We want to prove that $ BFS(G,u) = DFS(G,u)$.
$\text{BASE CASE}$
$V(G) = \{u\}$
$BFS(G, u) = ... |
In compressed data, repetition of same pattern is not a lot, so, you can expect it to be with space inside to contain always. I found a way to compress data without limitation. Is it right? Am I thinking in the true way?
BigNumber = BigNumber * N + LittleBitsNumber (=>smaller than N)
Remove that bits Number from data/f... |
I chanced upon the following question online:
A company has two trucks, and must deliver a number of parcels to a
number of addresses. They want both drivers to be home at the end of
the day. This gives the following decision problem.
Instance: Set V of locations, with for each pair of locations
v, w ∈ V , a dista... |
I have a problem at work. I need to find a subset of a set of positive integers that sums to a certain value. I know there is a subset but I need to find it. Is this new problem the same as the subset sum problem?
|
A code is (statistically) self-synchronizing if, given that the transmitted string is long enough, the receiver is guaranteed to eventually synchronize with the sender, even if bit flips or slips have occurred.
Do Huffman codes have this property in general? In case not, is there a criterion for testing if a Huffman co... |
I want to design a binary tree with preallocated nodes, in order to avoid calling malloc/free every time I want to insert/delete a node. The problem is I don't know ahead of time how many nodes the tree will have, so I am thinking I need to allocate a block of nodes at a time, then allocate another block when the first... |
I have a question as follows
Consider the relations $r1(P, Q, R)$ and $r2(R, S, T)$ with primary keys $P$ and $R$ respectively. The relation $r1$ contains $2000$ tuples and $r2$ contains $2500$ tuples. The maximum size of the join $r1⋈ r2$ is :
My attempt - Suppose all value of $R$ in $r1$ are same. Then it should ... |
The traditional way to implement a SQL database is to parse the query, create a parse tree, and then evaluate it using the "volcano" model. In this model you call .next() on the root node of the tree to get the next tuple, and each node calls .next() on its child nodes, percolating the tuple up the tree.
In 2011 Effici... |
"If every element comparison (testing whether $a_i \le a_j$ ) provides at most one bit of information, argue that you need at least on the order of $\ln(n!)$ many tests/comparisons to sort the list."
This is a question on my homework at the moment. I don't understand how I'm supposed to go about arguing this as I don't... |
I have an $n \times m$ matrix, and fill it with numbers of $1 \dots k$.
If a matrix can be turned into another matrix by exchanging its lines and exchanging its columns, the two matrices are considered to be the same.
I know that I can easily computed the numbers of the different matrices out in $O((n\times m)^k)$ time... |
From the given formula, we can compute the CPU utilization:
CPU Utilization = 1 - P^n
Where p is the probability of I/O and n is the total number of processes.
E.g, If we were to find CPU utilization if the computer has enough room to hold four programs in its main memory. These programs are idle waiting for I/O half... |
The problem is proposed here and related to this question. Given $n$ and $k$, I would like to know how to compute$$\sum_{\substack{x_0 ⊕x_1⊕\cdots⊕x_k=0\\x_i≥0,\ 0≤i≤k\\\sum\limits_{i=0}^kx_i≤n-2k}}\binom{n-k-\sum\limits_{i=0}^kx_i}k$$ in $O(nk·\log n)$ time, where $⊕$ is exclusive or.
Let $\sum_{i=0}^{k}x_i=S$.
The s... |
I’ve run into a challenging algorithm puzzle while trying to generate a large amount of test data. The problem is as follows:
We have $N$ buckets, $B_1$ through $B_N$. Each bucket $B_i$ maps to a unique item $a_i$ and a count $k_i$. Altogether, the collection holds $T=\sum_1^N{k_i}$ items. This is a more compact repre... |
A model of computation is called Turing complete if it can simulate any Turing machine.
This rules out for example a combinational logic circuit.
However, there is a sense in which combinational logic circuits can solve all problems that Turing machines can: while it is not the case that we can find for Turing machine ... |
I'm searching (without results) a problem that can be reduced to finding the densest subgraph with the same cardinality between two classes of nodes.
Consider a graph with nodes of class A and nodes of class $B$ (not bipartite and $|A|$ it is not necessarily the same as $|B|$).
The problem is to find the densest subgra... |
I am searching for an undecidable language $L$, such that $L \leq \Sigma^* \setminus L$ and $\Sigma^* \setminus L \leq L$,
but I am not able to find a concrete language and reduction.
Is there anything like this?
|
I am reading about the Satisfiability Problem, in page (5) the author gives the following example :
$(P \lor Q \lor R) \wedge
(\bar{P} \lor Q \lor \bar{R}) \wedge
(P \lor \bar{Q} \lor S) \wedge
(\bar{P} \lor \bar{R} \lor \bar{S})$
A satisfying assignement is $: P,Q,\bar{R},\bar{S}$.
A different assignments is $P,\bar{R... |
Word size of most modern cpu’s is 32 or 64 bits. Both are a power of 2.
This looks “intuitively reasonable”, because a bit has 2 states, but I don’t actually have a hard argument for why this is the case. Moreover, in the past, word sizes of processors have been multiples of other numbers, such as multiples of 6 (becau... |
What is known about the complexity of the promise problem "determine whether a propositional formula is a tautology in intuitionistic logic, given that it is a tautology in classical logic"?
Does it matter whether you have access to a proof that the proposition you're asked to validate is a classical tautology?
I thin... |
So I know from some research I've done that the OPT-IP <= OPT-LP for the maximum coverage problem, however I'm having some difficulty following the explanations I find. Does an example exist where it can be shown OPT-IP < OPT-LP easily?
|
I read that in a paging scheme memory management, some os's have a paging daemon that wakes up periodically to inspect the memory of the RAM. This is to ensure that modified pages can be scheduled to write back to disk before page fault happens and it also makes it more efficient to have a pool of free frames rather th... |
I have quite a hard time understanding co-NP problems.
If we can reduce every problem to decision problem. NP problems should accept YES instances -> instances where the answer is yes. So for example for Traveling Salesman problem, we would ask "Is there a path that visits every city, and is shorter than N" ?
For co-NP... |
I've got a question regarding the A* search algorithm's implementation.
According to Wikipedia, one has to use a priority queue for retrieving the next node with the lowest f value, is it possible to skip to a node that is not a direct descendant of the current node?
For example:
Say we start with node S (set f=0), t... |
I am implementing the gift wrapping algorithm to find the convex hull of a set of points in the 3D space.
However, all the articles I have read seem to omit the description of the first step of the algorithm; namely, finding a face (that is, a triangle) in the set that will definitely be in the convex hull (and doing s... |
Can $n$ elements be sorted in a worst case time of $\sqrt{n}\log n$? Why or why not?
I've seen algorithms being sorted in the worst case of $n\log n$, so why can they be or cannot be sorted in $\sqrt{n}\log n$?
|
In order to calculate the effective access time of a memory sub-system, I see some different approaches, a.k.a formulas. All are reasonable, but I don't know how they differ and what is the correct one.
Assume a two-level cache and a main memory system with the following specs:
h1 = 80% t1 = 10ns L1 cache
h2 =... |
I am trying to clearly define various terms related to top down parser "so that I can relate them and come up with clear classification". Now this efforts might seem unnecessary as the terms I am talking are pretty basics, but I am trying this all for sake of 100% clarity.
The dragon book defines predictive parsing as ... |
I have a problem that I believe is NP-hard. If I reduce a NP-complete problem to it in exponential time (and not polynomial time), does that prove the problem is NP-hard?
|
(1) ∀x, y, z (x < y ∧ y < z → x < z) (transitivity)
(2) ∀x ¬(x < x) (antisymmetry)
(3) ∀x, y (x < y ∨ x = y ∨ y < x) (linearity)
I need to give an example of a (nonempty) structure with one binary relation that satisfies (1)and (2) but not (3), and in addition the formula ∀x ∃y (x < y). I was thinking naively of y = x ... |
For any two different numbers there is an number in between.
I'm trying to write this in predicate logic and have no idea how to do it, since I need 2 variables X and Y? For all x there exists a y such that y - x is positive?
I'm a mong ignore.
|
Modern personal computers as far as I understand have increased in power (measured informally by ability to compute “more demanding programs”) due to two “broad factors”:
decreased transistor size (thereby decreasing delay time between computations).
increased transistor quantity
It seems to me that the first factor ... |
We have two types of Automata. One is NFA and second is DFA. These are little bit different but thing is that in which environment we prefer NFA over the DFA?
|
Given a relation R(A,B,C) and a FD set (A->B, B->C), find the FD Closure. Enumerate all the FD's and organize them accordingly to the LHS of the FD's. Mark all the trivial FD's.
I am a little confused with the second part of the question and don't understand what exactly they mean by "organize them accordingly to the L... |
What do you call a structure which becomes a tree after collapsing cycles (so the new vertices are the old faces)?
For instance, the digraph (given by an NFA; ignore edge labels please) below becomes a tree
$\{a,b,c,d\}$ with edges $(a,b), (b,c), (b,d)$ via:
\begin{eqnarray*}
a\mapsto&\text{the cycle }&S_0,S_1,S_2,S_3,... |
Can someone explain the difference between first-order programs and higher-order programs in the context of programming languages?
My understanding so far is that Functional Languages (most) use higher order programs. Plus, higher functions either a) take other functions as arguments, or b) return functions as results.... |
What is the complexity of this problem
EULERIAN ARC REVERSAL
Input: a directed graph $G(V,A)$ and an integer $k$
Output: YES if $k$ arc reversals are enough to transform $G$ into an Eulerian graph, otherwise NO
Given an arc $(u,v)\in A$, an act of reversing it will result in the opposite arc $(v,u)$ while the origin... |
There was a time when a "computer" was a person who worked on accounts. However, machines were introduced and this profession eventually died out over time. The definition below was taken from pag 750 of volume C of the year 1893 of the OED dictionary:
Computer [...] one who computer; a calculator, reckoner a person e... |
Say I am given two hash functions f1 and f2 is there anyway that I can prove one hash function will produce fewer collisions than another one? That is say for some domain assuming all values in the domain are equally likely to be chosen can I show that f1 will on average perform better than f2?
Looking up how to determ... |
I am trying to show that given a co-finite language $A$, $A \in \text{TIME}(1)$.
If $A$ is co-finite, $A$ is regular, so $A \in \text{TIME}(n)$.
I'm not sure how to proceed from here. Any hints?
|
I am trying to solve above question, below is the automaton I came up with:
Is there any ways to define automaton without having marked states?
|
I would like to know if there has been any work relating legal code to complexity. In particular, suppose we have the decision problem "Given this law book and this particular set of circumstances, is the defendant guilty?" What complexity class does it belong to?
There are results that have proven that the card game M... |
I know that AVG Memory Access Time = Hit time + Miss Rate * Miss Penalty
If I am given the AMAT and miss rate, aswell as the latency to access memory(call this x) how do I calculate the miss penalty & / or Hit Time?
For example:
AMAT = 80 (cycles)
Miss Rate = 0.4
Memory access latency = 60 (cycles)
How do I get miss p... |
Hi I have been reading Ch 34(NP-Completeness) Section 34.1 of CLRS and I am confused why do we need to consider different encodings. Everything is represented as binary at the end so why consider different encodings of the input?
Any help is highly appreciated.
|
The master theorem can be used in case of a recurrence relation of the form $T(n) = aT(\frac{n}{b}) + g(n)$
But is it possible to use the master theorem for recurrence relations of the form $T(n) = aT(\lfloor \frac{n}{b} \rfloor) + g(n)$?
|
Disclaimer: Assignment question.
I am trying to solve the below question, the condition is not to use guards and variables. Is it at all possible to do this?
My approach was to have 4 separate automatons, 1 for each of the three servers and 1 for the entire system(with states for 0, 1 and 2 customers in the system). B... |
I would like to calculate an eularian path using Christofides algorithm on this graph: (Focus on the first number in each box representing the distance)
$\alpha$ denotes the start and end vertex of the Eulerian path
Step 1 - Calculate minimum spanning tree $T$
Step 2 - Calculate the set of verices $O$ with odd d... |
I have an unsorted array of (x,y) coordinates and need to find the min/max for both (x) and (y) separately so that I can build a bounding box using $O(\frac{3n}{2})$ comparisons.
If I use this method to find the min/max for the left/fight box boundaries, then use the same algorithm to find min/max of y for the top/bot... |
I was reading Combinatorial Sketching for Finite Programs and wanted to understand why synthesis of the sketching language was possible/feasible.
As far as I understand a partial program is transformed to the Quantified Boolean Formula Satisfiability Problem (QBF) and a sketched (partial) program $S$ with specificatio... |
Dragon book says:
An ambiguous grammar can never be LR.
And then immediately further it says:
For example, consider the dangling-else grammar:
$\begin{align} stmt \rightarrow & \textbf{ if } expr \textbf{ then }stmt \\
&| \textbf{ if } expr \textbf{ then }stmt \textbf{ else } stmt \\
&|\textbf{ ot... |
I am learning CFGs and before that I've made a RE (Regular Expression) for the language of "all strings with at least two $0$'s over the alphabet $\Sigma = \{0,1\}$."
I made this: $(0+1)^*0(0+1)^*0(0+1)^*$
I checked the answer and it is: $1^*01^*0(0+1)^*$
Is there any difference between the two?
If mine is also correc... |
I am working with a linear programming problem in which we have around 3500 binary variables.
Usually IBM's Cplex takes around 72 hours to get an objective with a gap of around 15-20% with best bound. In the solution, we get around 85-90 binaries which have value of 1 and others are zero. The objective value is around... |
I'm a bit confused at a fundamental level.
In Computer Science, maybe some of us mostly use discrete mathematics since our computer is digital (like during studying operating system, algorithms, security, or automata theory for example). Of course, there are also calculus and nonlinear mathematics in Computer Science,... |
We do not know if $P=NP$ has an impact on $VP=VNP$ however how about $P=PP$?
Is $PP$ and $VNP$ related and would $P=PP$ or $P=PSPACE$ imply $VP=VNP$?
Is there a way to show $\#P$ is in $FP^{PP}$?
|
Let $G$ be a graph on $n$ vertices whose degree sequence is $d_1,d_2,...,d_n$. Let $\alpha(G)$ denote the size of maximum independent set of $G$, i.e., the size of a maximum subset of vertices of $G$ that are pairwise non-adjacent. So Caro-Wei says that $\alpha(G) \geq \sum_{d_i \in V(G)}{\frac{1}{1+d_i}}$. The standar... |
The $n$ dimensional hypercube $Q_n$ is a graph that has a vertex $v_s$ for each string $s \in \{0, 1\}^n$ and an edge between two vertices $v_s$ and $v_t$ if and only if the Hamming distance between $s$ and $t$ is $1$.
I would like to find directed hamiltonian cycles in this graph that satisfy a certain property, and w... |
$T(n) = T(n-2)+T(n-3)+2T(n/3)$ and $T(n)=1$ for $n<4$.
I tried to compute the complexity of $T(n) = T(n-2)+T(n-3)+2T(n/3)$ using the recursion tree but it's not clear enough for me to make a guess and demonstrate it by induction? also, it should be computed given both upper and lower bound.
|
The question asks what kind of languages (regular, context free) can a Turing machine accept if you are not allowed to overwrite the input string. The initial configuration of the machine is start symbol followed by a blank followed by the input string followed by infinite blanks. The head is pointing at the blank just... |
https://en.wikipedia.org/wiki/Processor_register
So from the information in this link there are limited Floating point and General Purpose registers in a cpu. My question is how are these registers used. By that I mean let's say I defined some variables in python but I think It's stored in RAM or HDD so does cpu only ... |
My implementation of counting sort is based on the description I found here. I've also included my code in this REPL, but here it is:
def counting_sort(input_list, max_int):
# Make a histogram array for occurences of each integer
count = [0] * (max_int + 1)
for i in range(len(input_list)):
value = input_list... |
Consider the recurrence
$$
T(n,m) = T(n,m-1) + T(n-1,m) + c,
$$
with base cases $T(n,0) = T(0,m) = 1$.
This is the complexity of a recursive algorithm for the longest common subsequence, I know that the complexity is exponential and equals $\Theta(2^i)$, but I'm not sure if $i=\max(n, m)$ or $i=nm$. Also, how can I dem... |
I'm looking for an algorithm as efficient as possible for a regex engine that supports submatch tracking (a.k.a capturing parentheses) and backreferences. What I mean by as efficient as possible is that the simple parts of the regex (like .*.*) should still be matched in linear time no matter whether the backreferences... |
I am looking at the diverse subset problem in Kleinberg and Tardos, shown in the image:
Why can't we give a polynomial time algorithm for this? Cant we iterate through each person a, and then each item i, and then see for each person b $\neq$ a if b has bought item i, then conclude that a and b cannot be diverse? And... |
Suppose that a graph class $\mathcal{C}$ is defined as follows:
A graph $G$ belongs to $\mathcal{C}$ if, and only if $G$ is chordal,
but has at most $k$ $5$-cycles.
I am aware that the definition of $\mathcal{C}$ is contradictory. However, I am looking for a notation like
$G \in C_4\text{-free} + k*(C_5)$
Is there ... |
Can some Turing Machine $M$ with description $\langle M\rangle$, check if an input string $w$ is a description of itself? That is, can $M$ be constructed such that $M$ can tell if $w$ = $\langle M\rangle$?
The closest related problem I could find was: Can I construct a Turing machine that accepts only its own encoding... |
As I understand it to prove something is NP-complete you have to show that it's NP-hard by reducing and a known NP-complete problem to your problem and also prove that it is in NP which you do showing that an answer can be verified to be correct in polynomial time.
Now for the longest Hamiltonian cycle in a weighted gr... |
This is a quote from wikipedia:
Each computer architecture has its own machine language. Computers differ in the number and type of operations they support, in the different sizes and numbers of registers, and in the representations of data in storage. While most general-purpose computers are able to carry out essenti... |
Today I did a test in my class, the trace was:
Prove that the language $L =\{\langle M\rangle\mid \forall w \in \{0,1\}^\ast: M \text{ accepts
}w\implies M \text { accepts }ww \}$, is undecidable with a reduction
from $A_{\mathrm{TM}}$.Hint: You can suppose that $w\in \{0,1\}^*$
I answered:
Suppose that $L$ is dec... |
number -> digits(.digits)?(E[+ -]?digits)?
This transition diagram runs the above mentioned token I can not understand this how this is work.what is meaning of "?"Symbol and digits. can anyone explain me this
|
The master theorem didn't work here. I tried to do the substitution method but I ended up with an additional term: $2Σ(i \cdot 3^i)$. Also I should find the solution $g(n)$ such as $f=\Theta(g)$.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.