instruction
stringlengths
35
29.1k
Let's say $\mathcal{P}$ is a yes/no prolem with an existing reduction to the problem $\mathcal{Q}$ (with time complexity $\mathcal{O}(n^2)$). $\mathcal{Q}$ is NP complete. Does this mean that $\mathcal{P}$ is also NP complete?
I am pretty desperate finding the correct context free grammar for the following language: $$L=\{a^lb^mc^n \mid l,m,n \in \mathbb{N}_0, \, l\geq 2n+m\}$$ I would really appreciate if anyone could tell me how to generate the CFG from this language as I am stuck on this one for 2 days now. I can't find a solution for add...
Given a set $S$ of $n$ points in $\mathbb R^2$, denote by $\mathrm{convb}(S)$ the boundary of the convex hull of $S$. Let \begin{align*} S_1 &= \mathrm{convb}(S)\\ S_{i+1} &= \mathrm{convb}\left(S \setminus \bigcup_{j=1}^i S_j\right). \end{align*} Now $S_1,\ldots$ forms a partition of $S$. Is there an $O(n\log n)$ time...
Sorry for maybe a silly question but i need to understand how ¬(¬∀x ¬A(x)) equals ∀x ¬A(x) In my mind, the negation before the parenthesis will be applied to both ¬∀x and ¬A(x). So it would look like this: ¬(¬∀x ¬A(x)) = ¬¬∀x ¬¬A(x) A double negation would become positive and would then let ¬(¬∀x ¬A(x)) equal to ∀x A(...
I need help to find an algorithm that calculates the single-source shortest paths in a graph, with an extra condition that the weight of the path has to be even. In another words, we have to find the shortest way with the minimum even weight. I'd like to have some ideas how we solve this. Thanks.
In Predicate Logic, if you want to prove the logical consequence using the method of resolution, do you ALWAYS start off by negating the conclusion?
Given a graph with |V| vertexes and |E| edges, I have to find a negative cycle, if there is one, in a graph. The wanted complexity is O(|V|*|E|). I was thinking about using Bellman-Ford to solve the question doing this: Do |V| iterations of Bellman-Ford, If there were no changes on the last iteration, there is no cycle...
I am studying push down automata. When I read a solution for showing $L = \{x\#y \mid x \neq y, x,y \in \{0,1\}^*\}$ is a CFL, I could understand $L = L_1 \cup L_2$, $L_1 = \{x\#y\mid|x| \neq |y|\}$, $L_2 = \{x\#y \mid|x| = |y|,x \neq y\}$, and make a CFG for $L_1$, but I don't know how to make a CFG for $L_2$, since $...
I am supposed to decide, if the statement is true or false and use arguments for my answer. In every weighted n-vertices graphs: with no negative weighted edges, with n>10, in which every weighted edge appears constant number of times(e.g. 1,2,3.., but not n number of times), but graphs, in which every edge has the sa...
Let $R$ be some problem in NP. Suppose algorithm of solution check M(x,y) runs in time $O(n^3)$ and uses $y$ additional information, s.t $y \leq 5 \log n$ bits. For what $f(n)$ can we claim that $R$ belongs to $\textbf{TIME}$$(f(n))$? I have no idea how to solve this.
I'm having a little trouble with Tarjan's Algorthm. So here's my problem: I have a graph such that these nodes are directionally-connected as shown: A: B C D E B: D E C: B D E F D: C E E: B F: A B D E My problem is Tarjan's Algorithm never revisits nodes, apparently. If the node isn't on the stack, it's not checked....
I am trying to state, whether the statement is true: During a DFS/BFS, first time visited nodes form a spanning tree, that has the same number of edges whether you use DFS or BFS. Is it true? What I tried was to do both DFS and BFS on a couple of graph and the spanning tree I got was the same each time. But perhaps th...
In every weighted graph with $n$-vertices with negative weights, with $n > 10$, a weight can't appear $n$-times in graph, there are between every two vertices at most $4n^3$ shortest paths. I'm trying to prove whether the statement above is true or false, however I am clueless. So far I failed to find a graph where t...
What is an intuitive way to think about the convergence of the distance vector routing algorithm? According to Wikipedia: Distance-vector routing protocols use the Bellman–Ford algorithm and Ford–Fulkerson algorithm to calculate the best route. I am aware of the Bellman-Ford and Ford-Fulkerson algorithms and have som...
I am preparing for my Computational Theory final and ran into this exact problem : B={ x | there exists a prefix of x that is in A}. Show that B is semi-decidable. In other words, you need to describe an algorithm M that on input a string x semi-decides if some prefix of x is in A (“semi-decides” means that it is OK i...
In the Map-Reduce implementation, the reducers start when all mappers finish their jobs. Why don't we stream the records from mappers to reducers while they are being processed instead? I think there are two reasons: (i) if we use streaming method, if a reducer fails, all the mappers have to recompute the map function ...
Can someone explain why BFS is $O(V + E)$ whereas DFS is $\Theta(V + E)$. I understand the definitions of both notations, but I just don't see why the bound for DFS should be tighter than that of BFS. Is it because DFS is guarenteed to visit all vertices and hence has the lower bound $\Omega(V+E)$? Note: I am studying ...
Diameter of a connected, undirected graph is the smallest natural number d, so that between any two vertices of the graph exist path of length at most d. Prove or disprove: in Bellman-Ford is the number of iterations always equal or lower than d. I'm trying to solve this issue. What I tried was sketching a lot ...
I'm trying to prove that that language isn't a context free: $ L = \{ w11w \mid w\in \Sigma^* = \{0,1\}\}$ I succeed to prove that $L = ww$ isn't context free, but not the language above. What am I doing wrong?
Where can I find a proof that the emptiness problem for the intersection of two context free languages is undecidable? I searched on the internet but could not find anything helpful. Do you maybe have a book or paper I should investigate?
The Handbook of Markov Decision Processes 1 defines bias of a stationary deterministic policy as follows: $h(x, \phi) = \sum_{n = 0}^{\infty} E[r(x_n, \phi(x_n)) - w(x_n , \phi)]$ where $x$ is a state, $\phi$ is a stationary deterministic policy, $r(s, a)$ is the mean reward of taking action $a$ in state $x$ and $w(x, ...
Is doubly-connected edge list a good data-structure for planar graph which vertices can be moved freely? I experienced DCEL as a very good structure when it comes to add/delete some vertex or edge. And I can detect all faces easily too. But when I start to move vertices of the graph it can happen that the graph is no l...
I am currently reading this paper by Chales-Lev. This paper explain an implementation of work-stealing dequeue. The part where I don't understand is in the implementation of steal operation. public Object steal() { 11 long t = this.top; 12 long b = this.bottom; 13 CircularArray a = this.activeArray; 14 long size = b -...
I am learning LR(0), SLR(1), CLR(1) and LALR(1) parsers. I know how parsing tables of each of them is formed. If x < y means parser x is less "powerful" that parser y, then, I read, the relationship between these parsers can be shown as: LR(0) < SLR(1) < CLR(1) < LALR(1) However, I am not very clear about exactly wha...
x∈ L1* ∪ L2* ⇔ x∈ L1* ∨ x ∈L2* ⇔ x ∈(L1)* ∨ x∈(L2)* ⇔ x ∈L1* ∪ L2* ⇔ x∈(L1∪L2)* Is it enough to prove it this way?
I am trying to draw a DFA that accepts the following language: $L=\{a^{2i+5j} : i , j \geq 0\}$ I started out by drawing an NFA, which I can then convert to a DFA but I am not sure if my NFA is correct.
Is it possible to write the following logical constrain in linear programming? Let $v$ be an integer variable and $k$ an integer constant. Let $y$ be a binary variable. The logical constraint is $y=1 \Longleftrightarrow v=k$. I need this kind of constraint in linear programming to use it in AMPL, but I really can't fi...
If Bubble Sort is written as: while True: False for i in (0 to n - 2): if list[i] > list[i + 1]: swap.(list[i], list[i + 1]) True return list (where n is len(list)) Seems to me that in the worst case (a list in descending order): the while loop runs ...
Consider a directed $k$ partite graph $G$ with a source node $s$ and a sink node $t$. Each vertex in the graph is labeled with a positive integer value. Both the source and sink are labeled with $0$. There are directed edges from the $s$ to all vertices in partition $0$. There are directed edges from all vertices in pa...
I have the following diagnosis problem: h(A): z1 = not(in1) h(D): z2 = not(in2) h(B): z3 = z1 or z2 h(C): out1 = not(z3) h(E): out2 = not(z3) This is an image of the system: I have an observation where I know that: in1 = false in2 = false out1 = true out2 = true I want to check if {B} is a diagnosis of the system, m...
I am learning this MIT course, which gives this formula $$O(n^2) = n^{1.5}$$ is there a table to calculate this? like $O(n^{1.5})$, $O(n^{5})$ ? what x takes would have O(x) give $c \cdot n$ where c is a constant,
Given a graph G and a set of vertices $(v_1, v_2)$. How can you determine whether there is $\textit{one}$ unique walk between $v_1$ and $v_2$?
Array $P$ of length $n$ is a permutations of $\{0, ..., n-1\}$ Write a code, which would in $O(n)$ create an array $R$ of length $n$, so for values $x_i, x_j \in P$, $R[x_i] < R[x_j]$ if $x_i$ is on the left of $x_j$ ($i<j$). This is a algorithmization problem that's recurring in the final's test each year and I'...
I'm working on the following problem: Is the following language Turing recognizable (recursively enumerable) ? $$L = \{ \langle \langle \ M\ \rangle \rangle \ | \ M \ \text{does not > accept}\ 010 \} $$ The way I see it: Suppose that a machine $M$ loops forever on $010$. If a $TM$ recognizes $L$, it should accept ...
In this previous question, I learned that if each variable in a string $C \in 3\text{-SAT}$ appears only "locally", then finding a satisfying assignment is no longer NP-hard. My question below builds on this to ask whether NP-hardness is recovered when, loosely speaking, there are multiple "layers" of variables leadin...
I want to decide if a deterministic TM $A=(Q, \varGamma, \delta, q_s, q_h)$ halts on every input in at most $k$ steps. If the TM $A$ stops after $k$ steps, then the positions $A$ can reach are limited by $2k$. Thus I can create a NFA with state set: $$ Q' \subseteq \{1,\dots,k\} \times Q \times \varGamma^{2k} \times \...
Here is a minimal working example of the question: Consider a network with nodes arranged in a pyramid: $1$ node in the first row, $1+d$ nodes in the second, $1+2d$ nodes in the third, and so on, for $m$ rows. (So $n = m + (m-1)md/2$ nodes total.) Each node takes a state of 0 or 1. All nodes not in row $m$ have $1+...
I am not certain this is the proper site for this question however I am mainly looking for resources on this topic (perhaps code). I was watching TV and one of the characters had a lawyer who destroyed his documents using a paper shredder. A lab tech said that the shredder was special. I am not familiar with this area...
I have the following constraints I'm trying to model in Linear Integer Programming. I will try out diverse solvers for this later, but first I need to model the problem. Given the integer variables: x1, x2, x3, x4, y1, y2, y3, y4, I have the following constraints: IF (y1 ≤ y3 ≤ y2 OR y1 ≤ y4 ≤ y2) THEN (x1 ≥ x4 OR ...
I have the following problem of recurrences and divide-and-conquer. Consider the algorithm, called StoogeSort in honor of the immortals Moe, Curly and Larry. The swap operation $(x,y)$ exchanges the values ​​of $x$ and $y$. Algorithm StoogeSort: procedure StoogeSort(A[0...n −1]) if n = 2 ∧ A[0] > A[1] then ...
So I have recently ran into a graph theory problem and was unable to find a matching algorithm for the problem or reword the problem to match some existing algorithm. The problem is pretty straightforward - given a weighted directed graph, pick edges to maximize the sum of all weights of the chosen edges. Max one edge ...
$1-2^{-23}$ and $2-2^{-22}$ both represents floating point representation or normalised representation.But are those two represent same value or both have different value? Is floating point representation same as IEEE representation??
Recently, I came up to the following problem: Given array $A$ of size $n$ and integer $k$, We should answer $Q$ questions of the type: for given range $[l, r]$ we should find sum of the $k$ maximum elements over all $A_i$ such that $l \leq i \leq r$. Trivial solution would be to sort all values in the range and iter...
Can anyone please help me out with my query: can disconnected graphs have minimum spanning trees?
I have a blackbox program that generates a set of strings. What is the best regular expression learner that I can use to learn (approximate) what the blackbox program uses as a generator? Note that I only have positive examples. (Checking whether a string is accepted or rejected is possible but rather costly). I see th...
My intuition is that $L\notin coRE$, but I haven't managed to prove that $HP \le L$, as previously I only saw reductions from $HP$ or from $\overline{HP}$ with $f$ such that $f((\langle M\rangle,x))=\langle M_x\rangle$, while $M_x$ performs some simulation of $M$ on $x$. (The answer eluded me for some time, so I starte...
Suppose you have a graph G, and you want to support the following operations: addNode(Node n) addEdge(Node n1, Node n2) deleteNode(Node n) Now I want to track after every operation what the connected components of my graph are. If I only had to support addNode and addEdge, I would use a Union-Find data structure to m...
While learning about the pumping lemma, I came across the following question: Given the language L is $ a^n(0|1)^* $ with $ c_0 \cdot c_1 = n $, where $ c_0 $ indicates the amount of zeros present, use the pumping lemma to prove that this language is not regular. Examples of valid words in L are 0, 1, a01, aa001, etc.....
Context-free languages are not closed under intersection. Suppose $L_1, L_2 \in CF \setminus REG$ (i.e., $L_1,L_2$ are context-free but not regular). Are there well-known theorems (and/or whole papers/research topics) that try to shape the sufficient/necessary conditions for $L_1,L_2$ to make $L_1 \cap L_2$ context fr...
Suppose you have an expression like this: sqrt(x) * 6 + sqrt(x + 1) * 6 + sqrt(x + 2) * 6 Are there any well-known or published algorithms that can find the repeated partial expressions and extract a function like this? let f(x) = sqrt(x) * 6 in f(x) + f(x + 1) + f(x + 2) I imagine there are some clever schemes in e...
I'm trying to write a context-free grammar for a comma-separated list of statements with comments. It is trivial if the comma appears at the end of a statement. It is trivial if the comment is ignored. But I don't know how to include a comma in the middle of a statement (before the comment). This Python / Lark CFG: ...
Since there is only a constant between bases of logarithms, isn't it just alright to write $f(n) = \Omega(\log{n})$, as opposed to $\Omega(\log_2{n})$, or whatever the base might be?
Assume that I need to determine the reliability of a service. The service includes component a (software reliability=0.95) and component b (software reliability=0.98). I have 2 computers: Computer A (hardware reliability=0.99) and Computer B (hardware reliability=0.99). I have two following cases: Case 1: Deploy both ...
What is "Fibonacci" about the Fibonacci LFSR? If I read right, Fibonacci LFSR means that it depends on its two last states, but from the example in Wikipedia it doesn't look like two states are taken in consideration (ie. XORing the taps in the current state, shifting and inputing the left bit..). What am I missing?
I have two algorithms has a complexity of O (n log n) and the B-complex algorithm (n^2). By imposing NA size the larger issue that a algorithm can solve in a given time and NB size the larger issue that the B algorithm can solve in the same time on the same machine. Prove that NB < NA. How can I solve this question ? ...
So, if I were using a black-box decision algorithm, PATH in which I could say, "does a path of weight k exist in this graph from S to V", problably the typical way one would solve the optimization problem of shortest path is to start at k at zero and increment until PATH returns true. But since paths start at -inf shou...
Problem: Find the closed-form expression for$$ T_n = \left(\sum_{i=1}^{n-1}7 T_i\right) + 1 \tag{1} $$where $T_1 = 1 .$ Calculating this sum I came up with the following result: $$ T_n = 8^{\left(n-1\right)} \tag{2} \,,$$ but is this result correct? I know the sequence is:$$ \begin{align} T_1 & = 1 \\ T_2 & = 8 \...
The following is the definition of what a bound function for a while loop must satisfy: The bound function is an integer-valued, total function of some of the inputs, variables and global data that are defined when the loop is reached. When the loop body is executed, the value of this function is decreased by at least...
Assume I have L1 which is a regular language, so we know since regular language is closed under complement, the complement of L1 is also a regular language. But let's say if the complement of L1 is a non-regular language, is it safe to conclude that L1 is a non-regular language as well? Since I'm trying to prove a la...
Problem text (from Sipser's "Introduction to the Theory of Computation"): 2.42 Let $E = \{1,\#\}$ and $Y = \{ w \mid w = t_1\#t_2\# ...... \#t_k \, \text{for $k \geq 0$, each $t_i \in 1^*$, and $t_i \neq t_j$ whenever $i \neq j$}\}$. Prove that $Y$ is not context free. Solution: Consider a string $1^p\#1^{p+1}\# .....
It is well known that the emptiness problem vor PDAs is in $\mathcal{O}(n^3)$. I couldn't find a good paper proving this theorem. Furthermore a proof for VPAs would be fine for me as well if that is easier. Do you maybe have a book or paper I should investigate? EDIT: This looks interesting but a formal proof from a bo...
Does a 3-SAT problem, where in each clause there is at least a negative-literal, always has a solution? After looking at it, seems to me that the answer is yes, but maybe there is something I am not seeing.
given is a reduction from 4-SAT to 5-SAT. How is it possible to describe such a function? I found some informations about reduction 3-SAT to 4-SAT here, but it can't help me so much.
Let $L_{1},L_{2}$ be languages that are not Turing recognizable, and let $L$ be a language such that $L_{1} \subseteq L \subseteq L_{2}$. Is $L$ also not Turing recognizable? I am inclined to believe it is, but I really have no idea how to show this. It seems that non-recognizable languages have very little about the...
When I prove some language is context free, It is too hard to find example string. Is there any tips? It takes too many time or eventually give up.
Let $ACFG$ be the language of all encodings $(C,x)$ where $C$ is a context-free grammar that generates a language containing $x$, i.e. $ACFG$ is the acceptance problem for context-free grammars. It is easy to show that $ACFG$ is decidable. Parsing algorithms like CKY are proof of this fact. Are $ACFG$ also regular? Is ...
this book "Fundamentals of Python: Data Structures 1st Edition" says data items in hierarchical collections are ordered in a structure resembling an upside-down tree. Each data item except the one at the top has just one predecessor ... A file directory system, a company's organizational tree, and a book's t...
Trying to understand how to write proof of correctness. Searched over the internet on how to write proof of correctness but can't find a good solution for it. The following sorting algorithm is proposed using the AVL tree: AVL input of all elements, and printing them in order. Algorithm - Sort AVL (A[1..n]) T -> Empty...
I am reading about a method called guided backpropagation. https://ramprs.github.io/2017/01/21/Grad-CAM-Making-Off-the-Shelf-Deep-Models-Transparent-through-Visual-Explanations.html#deconv-and-guided-backprop. As shown in the figure below, you essentially compute the derivates of the output with respect to the input i...
This is a follow-up to this question, which asks for an example of a non-regular language $L$ which satisfies the following condition, intersection resilience: If $L'$ is context-free then so is $L \cap L'$. We know that all regular languages are intersection-resilient, and clearly every intersection-resilient langua...
I've been trying to understand the idea behind proving a language is not regular by using Nerode's theorem, but I just couldn't apply the idea on what I've been asked. The problem is to prove the following languages are non-regular: $L_1 = \{waw^R \mid w∈{a,b}^* \}$, the language of all odd-length palindromes over $\...
I am trying to show that our problem is NP-Complete by reducing the known problem CLIQUE to our problem. Regular CLIQUE problem: Input: An undirected graph $G$ and a positive integer $K$. Goal: Does $G$ have a clique of size at least $K$? Our problem: Input: An undirected graph $G$ and a positive integer $K$. Goal: ...
Let's say I have a set of beads, $b_0,\dots,b_n$, and let $b_0$ be the 'special bead'. I want to lay out the beads on a string to minimize the total cost, defined as $\sum_{i=1}^n w_i \cdot d(b_0, b_i)$, where the weights $w_i$ are given, and the distance is computed as the number of beads between the two corresponding...
Given two strings, A and B, of the same length $n$, find whether it is possible to cut both strings at a common point such that the first part of A and the second part of B form a palindrome. I've tried bruteforce, and this can be achieved in $O(n^2)$. I'm looking for any kind of optimization that is faster than $O(n^2...
I have a feeling that the answer is either a "circular linked list" or a finite state machine, but the answer is probably a circular linked list.
I am reading about Goedel machine http://people.idsia.ch/~juergen/goedelmachine.html and especially the article about possible implementation (in the Scheme language) of this machine http://people.idsia.ch/~juergen/selfreflection.pdf . The idea is that there is Scheme environment, then there is special virtual machine ...
I wonder about the following decision problem : Instance: We consider a $n\times p$ matrix $M$ of zeros and ones, and two integers $N$ and $k$. Question: is it possible to cover all the ones of the matrix with $N$ squares of side length $k$? It is possible that the squares cover some of the zeros in the matrix, and the...
How is the equivalence of DFA defined? I found the equivalence of states --- James Hein, section 5.3, page 301. But he doesn't define equivalence between entire automata. (Ullman and Hopcropft seem to define neither.)
Is there a correspondence between the steps in using DPLL to find out that a formula in propositional logic is unsatisfiable and using sequent calculus to prove that its negation is valid? And given that the latter problem asks for less information (e.g. no need for a "counterexample" in case the formula is invalid), i...
I have the following first order logic expressions: $f(g(a, h(b)), g(x, y)),~f(g(z,y), g(y, y))$ and I want to compute the most general unifier for them. If I follow the algorithm found on these slides then I get the following. \begin{align*} S_0 &= \{f(g(a, h(b)), g(x, y)), f(g(z,y), g(y, y))\}\\ D_0 &= \{g(a, h(b)),g...
Let Σ be the signature made up from the following symbols. e: 0 arguments function (constant symbol) f: 2 arguments function g: 1 argument function Variable set Var is made up from x,y,z Let E be the set of the following equations f(x,f(y,z)) = f(f(x,y),z) f(x,e) = x f(g(x),x) = e Can someone explain to be me how I can...
I have tested and measured the running time of a backtracking algorithm for solving the $N$-Queens problem. When $N=7$, the run time is $0.773$, but for $N=8$, the run time is $0.492$. I think the run time should grow exponentially with the size of $N$. Why is the algorithm slower for $7$ than for $8$? This case also h...
I got a weird homework question about graph. A helicopter is going to land on an island to check the n houses after an earthquake. Some of the two-way roads connecting the houses are destroyed however the helicopter won't know beforehand. Once the the helicopter lands on a house u, they can drive to any neighboring hou...
Given a graph $G$ along with two non-negative integers $t, k \in \mathbb{N}$, The instance $(G,t,k)$ is a yes instance of the problem if and only if the graph $G$ contains $t$ cliques with $k$ vertices (there are $t$ copies of $K_k$, a cliques of size $k$ in the graph $G$). How to prove that $(G,t,k)$ is NP-complete? ...
So we have this block of pseudocode: Monsters = [M1,M2,M3,M4,M5,M6,M7,M8]; qsort(Monsters,rand_compare); qsort() sorts the array via quicksort where we use the last element as pivot. To compare two elements it uses rand_compare, which, with equal probability (i.e., 1/2 either way), will return either "1. element ...
I have read that when pivot element is choosen as Median, then QS Algorithm gets nearly balanced splits and have time complexity of O(nlogn), but my doubt is what if all the elements of the input are same like (2,2,2,2,....,2) and pivot is still the median element, then what type of partitions QS will get as left and r...
I'm trying to determine the input for the worst case time complexity of Karb-Rabin regardless of the used hash function. However, I'm seeing both of these answers on the Internet: String "AAAAAAAA" and pattern "AAA" String "AAAAAAAB" and pattern "AAB" Which of these inputs would have the worst running time in Karp-Ra...
So I know the conditions required for a problem to be NP-Complete is that it has to lie within NP and has to be NP-hard. The given problem I have is subset sum. However, the conditions have been change to sum ≤ M and sum ≥ M from sum = M. To be more specific: "If we ask if there is a subset with sum ≤ M, is the pro...
You can solve a Rubik's cube by factoring its permutation into a sequence of "elementary" permutations (a subset of permutations that is sufficient to construct every other permutation in the group). There are several algorithms for solving Rubik's cubes. Are there any algorithms for the general problem of factoring pe...
I am implementing an R-tree with the quadratic splitting method. However in most articles I have read there a piece of information that is missing or misleading (or the most probably case, I completely misunderstood something). R-trees are supposed to be balanced, yet you need to find the node that will increase less ...
In "Types and Programming Languages", Pierce gives a translation from recursive types ($\mu$ types) to types expressed as regular trees: possibly infinite trees, but with finitely many distinct subtrees. I'm wondering, is the converse true? Can every regular tree type be expressed using the $\mu$ fixpoint notation? It ...
Is there a known solution for the 0/1 knapsack problem that allows the weights of the objects to be real numbers? The only algorithm I can think of is a brute force search. I have tried searching for a solution but couldn't come across any. When weights are natural numbers, the most common solution uses dynamic program...
I just started Unix System Programming with Standard ML and starting on page 22 Shipman begins to explain a pure functional way of avoiding the constant state changes of typing at a keyboard: A lazy stream is an infinite list of values that is computed lazily. The stream of keystrokes that a user presses on the keyb...
I am currently studying mapping reduction in computational theory and finding it hard to grasp the concept fully. For reference, consider the following given WHILE-Prog sets: A = { (p.d) | p doesn't halt on input d } = Complementary HALT set. B = { p | p halts on exactly one input (the input is unknown) } Is A < B. me...
In an unweighted tree, suppose that we want to delete (or mark) any node which is closer to node $v$ than node $w$ ($dist(x,v) < dist(x,w)$). The solution that comes to my mind is running two BFS, which gives us $\mathcal{O}(V + E)$ running time. Is there any better way to do this? possibly with one BFS? EDIT: We ca...
Consider the following variation on stCON desicion problem: Given a directed graph G, decide whether for every two different vertices $s$ and $t$, there is a directed path between $s$ and $t$. Intuitively, it seems like this problem is indentical to the clique desicion problem, for a clique of size $n$. But does it a...
Given a list of museums, their opening hours and time needed to visit each, make a schedule such that a tourist visits maximal number of museums in a given day. Suppose that no time is needed in order to travel from one museum to another. Tourist cannot, of course, be in two different museums at the same time. For exa...
 I found the following description when I was reading a paper on computational complexity theory. This can be done ... in time 2n・poly(logs,n)+2O(logs)c. For s≤2no(1), the runtime is 2n・poly(n). I know this means substituting s≤2no(1) for 2n・poly(logs,n)+2O(logs)c results in 2n・poly(n), but I don't know how this is d...
Suppose we have an algorithm for a decision problem with $n$ bit inputs that runs in $DTIME[f(n)]$ is there ways to convert to circuits of $O(f(n))$ size with AND, OR and NOT gates? How about when we go from circuits to programs?
Given a bipartite graph the standard reduction to max flow is with the construction similar to following diagram: We can formulate max flow as an linear programming problem with integer variables in latter. If we do not use integer variables does solving for maxflow in linear programming formulation with only real ...