instruction
stringlengths
35
29.1k
Wikipedia says: The problem has been shown to be NP-hard and the decision problem version ("given the costs and a number x, decide whether there is a round-trip route cheaper than x") is NP-complete. How can the "non-decision problem" version be NP-hard? Doesn't this class contain decision problems, by definitio...
Given an $n \times m$ matrix $A$ where $m-n=1$ The value of any $A$[$i,j$] is either $1$ or $0$ If $A$[$i,j$] $=1$ then $i<j$ Does anyone know of an algorithm which would run as follows and what its complexity might be: Starting with the last column, column $m-1$, traverse each index $A[i,m-1]$ (where $0 \leq i < m-...
For this question, I have tried everything that I can think of, but cannot solve it. What I want to do is iterate over all possible values of $z_1$, but every method I use, it requires me to know what $p(m|z_1)$ will be for various $z_1$ values. Thus I am stumped and looking for help. A robot applies the so-called s...
I understand that the theoretical size of a diff patch between two similar files can be calculated using Kullback Leibler (KL) as described @ Wikipedia. Can anyone point me to a numerical example of this calculation? I can only find general theory and formulae. I'd like to check my work. So this is what I have so fa...
To my understanding, as long as we can find some polytime function $f$ such that $\forall x:x \in A \Longleftrightarrow f(x) \in B, x\notin A \Longleftrightarrow f(x) \notin B$, it follows that if $A$ is NP-complete and B is in NP, then B is also in NP-complete. My question is about what sort of 'things' we can do to o...
After constructing a binary search tree, you can read off the key values in ascending order by performing an in-order traversal. Will the resulting sorted order be stable? If so, how would the tree have to be coded to ensure this? If it is not possible, why not?" Just a review question I came across. From what I unde...
Hello I'm having trouble understanding how an intersection/union of regular languages can be regular and in other case non-regular. Can someone please give me some good examples?
Consider the usual RGB color palette, for which each color (red, green, blue) has $256$ distinct intensities. Can the set of all $2^{24}$ colors be expressed as a ternary linear code? If so, give a basis. If not, explain why not. I'm confused on how to solve this because I've only worked with binary linear codes. Ca...
Can every regex be translated into a DFA? Or only a subset of regular expressions? If so, what is an example of a regular expression that cannot be translated into a DFA?
A finite automaton is a generator for a regular language, and a regular expression represents a regular language. A language can be represented in many forms of regular expressions. So can a finite automaton have more than one regular expression?
How many words exist in the format of the simple precision IEEE 754 standard to represent the NaN value?
I tried finding real life applications for the Four Color Theorem (except for coloring maps) but couldn't find anything useful and well illustrated. For example I found this: Graph coloring problems are widely applicable to the problem of scheduling. Consider a university, where you are trying to schedule times for al...
I would like to know where in memory the global variables are stored. Thanks for your help.
There exists a collection c where c = {1, 2, 3} and a randomization of c, d where d = {1, 3, 2}. d was obtained by a function f where f is an undefined randomization function. Can c be obtained again (i.e. d = c) by randomizing d or d initially and then each randomized collection resulting from d using f? If so, can...
Having the implicit plane equation $$ax + by + cz + d = 0\,,$$ how do I find the affine transformation that must be applied to transform this plane into the plane with equation $$x + y = 0\,?$$ Please note in my case this is the horizontal plane as $y$ points up.
I am learning about deontic logics and there I can make the following inferences: If A then there is **duty to create an entity of class C**, If B then there is **duty to assign value 5 to the attribute c.a**, if A and B then **the computation D should be executed**. I. e. those deontic logic statements contain the usu...
In the current version as of the Wikipedia article “Potential method”, the amortized cost of each operation is defined as the following $$ T_{\mathrm{amortized}}(o) = T_{\mathrm{actual}}(o) + C \cdot (\Phi(S_{\mathrm{after}}) - \Phi(S_{\mathrm{before}})), $$ and the total amortized cost is $$ \begin{align*} T_{\mathrm...
Disclaimer: This is a simplified part of a question from my homework, addressing the point that I didn't figure out. let A be a 1-indexed sorted array of $n$ elements. There are at most 3 numbers that has at least $\lfloor n/4 \rfloor+1$ occurrences. Find three indexes that will surely "hit" all such numbers. Explai...
S -> aA | bC | CC | a | b | C A -> B B -> S C -> A | S It looks like its going to loop so it would be endless replacing the unit rule....
In a 'pool' with a lot of cpus ,jobs(processes) are running(lots of them) . Given I have time/resource usage 'samples' from many prior/still running jobs - how would you go about trying to predict the process resource usage ? Very abstractly , what I think should be done is as follows : 1) New job is submitted and s...
Is the class of problems with complexity $O(n^{n^\epsilon})$ at every $\epsilon>0$ same as class of problems with complexity $O(n^{f(n)})$ at every $f(n)\in\omega(1)$ and hence both classes are equivalent to $\mathsf P$ ($n$ is number of input bits)? (This is my view. Denote $C(n^{n^\epsilon})$ to be class of problems ...
The exact cover problem with restrictions on the size is: Input: Given a set $U=\{1,2,\ldots,n\}$ and a collection of $C$ of subsets of $U$. Question: Is there a subcollection $C^\star$ of $C$ such that The intersection of any two distinct subsets in $C^\star$ is empty; The union of the subsets in $C^\star$ is $U$; an...
Suppose that you extend the Calculus of Constructions with "holes" - i.e., incomplete pieces of code that you didn't fill yet. I wonder if there is an algorithm to fill those roles automatically. For example (using Morte's syntax): Case A: λ (pred : ?) -> λ (Nat : *) -> λ (Succ : Nat -> Nat) -> λ (Zero : Nat) -> (Su...
The (optimization version of) Set Cover problem is the following: given a "universe" set $S$ and a collection of subsets $S_1, \cdots, S_m \subseteq S$, we want to find the minimum cardinality set of $k$ elements $\{i_1, \cdots, i_k\}$ such that $\bigcup_{i=1}^k S_{i_j} = S$. It is a well-known result in an introductor...
The exercise is to prove or give a counterexample to the following proposition with $L \subseteq \Gamma^*$ regular and $h: \Gamma \to \Sigma^*$ a homomorphism. Is there any regular language $L'$ such that $h^{-1}(L^*) = L'^*$ ? I know that it isn't that easy to see, since $h^{-1}(L^*) \not= h^{-1}(L)^*$ in general with...
This is a practical problem in energy generation with heliostats. We have a number of heliostats basically forming the shape of a doughnut. The facility needs to deploy hubs on those heliostats. One hub can support 12 harnesses (a kind of cable) and one harness can support 16 heliostats; namely, one hub can support 192...
I tried to calculate the worst case of binary search (not binary search tree). My calculations: $$T(n) = T\left(\frac{n}{2}\right) + 1$$ $$T(n) = T\left(\frac{n}{4}\right) + (1+1) = T\left(\frac{n}{8}\right) + (1+1+1) = {\dots} = T\left(\frac{n}{2^{k}}\right)+(1\cdot k) $$ $$T(n)=T(1) + (1\cdot k) = c_{1} + (1\cdot k) ...
Let $X$ and $Y$ be problems, and let $X \le_p Y$. Is it true that \begin{equation} Y \in NP \rightarrow X \in NP\ ? \end{equation} I do mean $NP$ here, not $NP$-complete or $NP$-hard. The solution is simple if the reduction from $X$ to $Y$ transforms an instance of $X$ to an instance of $Y$; to verify that a solution...
I know that $E_{LBA} = \{\langle M \rangle ~ \mid ~ L(M) = \emptyset \}$ is an undecidable language, but is it recognizable (recursively enumerable)? It seems that it's complement is recognizable since we could construct a Turing machine that enumerates all strings and checks if any belong to the language. If both $E_{...
This is my new post linked with my previous post. Is bounded waiting satisfied in the 2 Process Solution? The answer in that post was very useful and cleared many concepts, but I just want to apply that answer for this example, that how BW works here . Especially, I want to know this definition works for this example...
In one of the lectures I went to, my professor stated that in order to determine the size of a search tree, we use the following formula: $$\frac{b^{d+1}-1}{b-1},$$ whee $b$ is the branching factor and $d$ is the depth of the tree in question. I would like to understand why we divide by $b-1$. I would have thought tha...
The topic of extracting the Facial Action Coding System (FACS) Action Units (AUs) [1] from images and it's translation into emotion prediction [2] is pretty well studied, but I'm not clear on how it stacks up against alternative approaches such as Convolutional Neural Networks (CNN). How much does the accuracy of AUs e...
I tried to find out how to arrange the complement of diagonal language, but I failed. So I'm about to believe that it's not a countable language. Could you, please, help me?
I have a weighted, undirected, Euclidean complete graph $G$, a special vertex $r$, and an upper bound $b$. I want to find a minimum-cost path cover that covers all vertices of $G$, subject to the restriction that every path must have length at most $b$ and every path must start at the vertex $r$. In other words, I wa...
If there is a deadlock between the processes does that mean that there is starvation also? My Thinking: deadlock is no process using that resources , but starvation is like not giving chance to only that process so there is progress in starvation but not in deadlock Is my thinking right?
I first saw this question on this website where I was trying on Java puzzles. Here is the Question:- You are given in an ArrayList, 1 to N Numbers. For Example, 1,2,3,4,5. However, one of the numbers is repeated twice. That is, in the form 1,2,3,4,2,5. Find the duplicate number without using loops. I thought that thi...
I'm trying to do some non-linear predictions and am going to use a random forest with Sk-learn. However my question has to do with data pre-processing. I'm planning on using minmaxscaler to normalize the temperature, wind, and humidity data...however I have two other variables class, and month. Class is a category data...
I am studying formal languages and production bases systems (rule-bases systems) and I am a little confused about why do these two word "production" and "rule" mean the same thing in so many context in Computer Science. In English Language they do not seem to mean the same thing. I am not a native English speaker but I...
The question that was in my lecture notes said "Encode the decimal number 2370 in ASCII. " and the answer given there is 32 33 37 30 (ASCII code representation) My question is how do we get this? Do we simply add 30 to each digit? I am sorry if this is a very obvious question I do not know the correct way...
Let's say you have list of $n$ vectors with entries from $\{0,1,x\}$ and $x$ is > $n$: $$ \begin{align*} L_0 &= [1,0,x] \\ L_1 &= [1,1,1] \\ L_2 &= [1,0,0] \\ L_3 &= [x,1,0] \\ L_4 &= [1,x,0] \end{align*} $$ I want to find all combinations of $m$ vectors (subsets of vectors from this list) whose elementwise sum in this...
Or: Do we need Rupert in order to get presents at all? Routing issues aside, Santa faces the following problem (many, many times over): Given a bag with capacity¹ $C$ and a set of presents $\{p_1, \dots, p_n\}$, each with size $s_i$, he wants to make children $\{c_1, \dots, c_k\}$ happy. He knows from all the wish lis...
For example for the sw command in MIPs, the control signal values are ALUOp1: 0 ALUOp: 0 RegWrite: 0 MemRead: x MemWrite: 1 Branch: 0 ALUsrc: 1 RegDest: x MemToReg: x Why do memRead, RegDest and MemToReg have the values of x? Why not just 0?
I just have taken an algorithm class exam and there was a T/F problem 'one can show that a problem A is in NPH by giving a polynomial reduction from A to a NPH problem B'. I know the direction of reduction is silly, but no counter examples come to mind right now...
let S and Q to be initialized to 1 process p0: process p1: wait(S); wait(Q); wait(Q); wait(S); .. .. .. .. Signal(S); Signal(Q); Signal(Q); Signal(S); I know there is a deadlock , where both the process will be going into th...
In here it was clarified that $\cap_{f(n)\in\omega(1)}\mathcal C(n^{f(n)})\subsetneq\cap_{\epsilon>0}\mathcal C(n^{n^\epsilon})$ where $\mathcal C(t(n))$ is the class of problems solvable in $O(t(n))$ time. My query now is whether there is a function of $g(n,\epsilon)$ that non-trivially depends on $\epsilon$ with $g(...
How to modify Dijkstra's algorithm, for wheel chair users, to take into account the road quality? There are three levels of quality: $1$ for pure concrete, $2$ for partly concrete and $3$ for rough road. Taking this into account, if there are roads $p1$: the short distance with road quality $3$ and $p2$: the long dista...
Is the language $\{ w \in \{ a, b \}^{*} : |w|_{a} + |w|_{b} = 2^{n} \}$ context sensitive ?
Given an undirected weighted graph $G = (V, \{E,F\})$, how to find the shortest walk that passes through all edges $e \in E$ exactly once? I'd like to know if there is a general approach to this problem. However, additional constraint may be added for my specific scenario. The graph $G_0 = (V, E)$ initially has only e...
My definition says A clique is a graph that has an edge connecting every pair of vertices but as I understand, an edge connects only two vertices. Like $A-B$. If we want to connect three vertices, we need at least two edges. For example, $A-B-C$. I don't understand how an edge can connect every pair of vertices.
How can I prove that this language isn't regular using the pumping lemma for regular language? $$L = \{a^nb^m| n,m > 0, \gcd(n,m)=1\}$$ I've already checked this answer: Proof that a language involving $gcd$ is not context-free but don't understand this part. "Let s' be $a^{(n+ik)}b^m \ with \ k \geq 1$. Then s' e L if...
I have a constraint in a linear programming formulation with two variables: $X \ge Y$ To which I want to apply the following if-else conditions: if Y=1: X=1 else: X=0 Where $X$ and $Y$ are binary. How can I fit this if-else into linear programming? Do I need to define another variable? It looks as an AND opera...
Disclaimer: I'm not a CS so I basically have no idea what I'm talking about I have a large (>1000) set of directed acyclic graphs with a large (>1000) set of vertices each; the vertices are labeled. I want to identify substructures that appear frequently over the whole set of graphs. A substructure is a graph of at le...
How can I construct -- or better to say what type of circuit can be like this -- a circuit that takes 3 binary numbers (a, b, c) and then calculates two binary numbers (d, e) in a way that a + b + c = d + e The circuit should be of constant depth and furthermore, a, b, c, d, and e are as follows; a=a_n−1…a_0 b=b_n−1…b_...
So, $G$ is a connected claw free graph. How can i prove that if $M$ is a maximum matching in $G$ then $M$ exposes $at$ $most$ one vertex of $G$ ? Any ideas ?
The R-Tree creates 'rectangles' to index 2D data. How is their size calculated exactly? What happens to the performance by changing this parameter i.e. the size of this rectangle/MBR? Number of overlaps, area covered change but can this speed up some kind of queries or build a smaller index?
I wish to calculate the number of nodes within a certain distance of a particular node in a tree such as the one below: Let's assume I'm looking for all the distances to node 2. What would be the most efficient (in terms of time complexity) method of computing the distances? Can it be done in linear time? For this ins...
I was given the following algorithm: PARTITION(A,p,r) x <- A[p] i <- p j <- r repeat while A[i]<x do i<-i+1 while A[j]>x do j<-j-1 if i <= j then exchange A[i] <-> A[j] until i>j return i,j quicksort(A, p, r): if p<r then i,j <- PARTITION(A,p,r) QUICKSORT(A, p, j) QU...
The problem is to find $C = AB$, where $A$ and $B$ are $n \times n$ matrices that may be sparse. Let $n$ be around 1000. The elements of $A$ and $B$ are real values, though, for practicality's sake, let's say we use floating-point numbers. Ideally, the approach would be fast enough for small $n$ and, of course, should ...
My question is the following. Assume that $\Pi$ is an NP-hard problem. Given an arbitrary instance $I$ of $\Pi$ and assume that an adversary knows that this instance is easy to solve, is it possible to find a deterministic polynomial-time algorithm to solve this particular instance $I$? For example: Suppose that $\Pi$ ...
I'm having a really difficult time understanding the logic behind reduction of the halting problems to other problems in order to prove them undecidable. Here's my reasoning: Let's say that we want to find out if the following problem is decidable: given any machine $M$ and a string $y$ find out whether the machine $M$...
I am reading the classical book "Compilers. Principles, techniques and tools" by Aho et alii. On chapter 9.3 they talk about a general framework to solve data-flow analysis problems that use a framework which is monotone and of finite height. The technique is shown to be useful for live variable and reaching definitio...
I need help identifying what algorithm I need to solve a problem. I'm not asking for programming help here, just identifying the algorithm. Each row of a matrix represents a state. Each element corresponds to the count of how often the current state transitions to another state. Some states are final states and do not ...
For example: $O(-e^{-x} +1)$. Basically as the size of the input increases, the time it takes to run converges.
I do not understand the difference between the All Pairs Shortest Path problem (solved by the Floyd–Warshall algorithm) and the Shortest Path problem (solved by Dijkstra's algorithm).
Let there be $N$ positive numbers given as $\lambda_1\geq\dots\geq\lambda_N$. Now I am interested in the following numbers given as $$\alpha_i=\exp(\frac{\lambda_i}{\lambda})$$ for some positive constant $\lambda$. Define the function $\mathcal{S}(..)$ which takes a subset of these numbers (let me call me them as a seq...
I am preparing for a coding interview and I can't really figure out the most efficient way to solve this problem. Let's say we have two arrays consisting of numbers that are unsorted. Array 2 contains a number that Array 1 does not. Both arrays have randomly located numbers, not necessarily in the same order or at the ...
Here is an algorithm to output a subset of activities S such that no activities in S overlap and profit(S) is maximum. Define $p[i]$ to be the largest index $j$ such that $a_j$ does not overlap $a_i$. $\#$ Return maximum possible profit from $a_1,...,a_n$ def rec_opt(n): if n == 0: return 0 else: ...
I'm currently working my way through An Efficient Algorithm for the “Stable Roommates” Problem by Robert Irving (Journal of Algorithms, 6:577–595, 1984). On page 7 the paper starts with describing the algorithm for phase 2. The only thing that phase two does is reducing all-or-nothing cycles. The paper seems to assume...
Here are two ways to output a subset of activities S such that no activities in S overlap and profit(S) is maximum. I can't see what's the difference between these two algorithms except the first one use a if statement and the second one use a for loop. They both store result in OPT[n] first.
Not sure if this question should be here, or on math.se. That said, let me proceed: On the Wikipedia page for the Ackermann function, it is mentioned that by passing the inputs of 0, 1 and 2 to the third parameter one could perform the three fundamental operations of addition, multiplication and exponentiation, respect...
I want to transform a general rooted, node-labeled tree into a related binary tree. I came up with four different schemes ("left shallow", "right shallow", "left deep" and "right deep" binarization) that are illustrated by an example in the diagram below. They all preserve certain aspects of the original structure. Chi...
Let $A$ be a collection of strings over the alphabet $\{0,\ldots,m-1\}$ that in total contain $n$ symbols. Your task is to sort each of the strings internally, and then sort the resulting strings in lexicographic order. (Your algorithm doesn't have to operate this way.) Example: Input: 33123 15 1 0 54215 21 12 Output:...
I am creating a simple program to detect if the given pushdown automaton accepts the given word, and I have a problem in finding an algorithm that does that. My thought at first would be to go through all possible transitions, and check if we didn't match this word in accepting state, but got in problem with (epsilon,...
I have a finite collection of finite sets $\{A_i\}_{i \in I}$. There is a relation $R$ defined on the elements of those sets (which is not transitive, it is irreflexive, and it is symetric). Suppose we define a related partial choice as a set $\{a_j\}_{j\in J}$ such that: $J\subseteq I$ $a_j \in A_j, \forall j \in J...
I am looking for a recursive algorithm to find the max sum of 2 numbers in an array, and the numbers can't be "neighbours" ( for example $a[0]$ and $a[1]$ or $a[4]$ and $a[5]$, in general $a[i]$ and $a[i+1]$ ) example: for the array 5 8 3 9 20 1 4, the result will be 28.
Suppose I have a quantum state represented by a Complex vector, arbitrarily: $[~-0.538, 0.044 - 0.323i, 0.706, 0.044 + 0.323i~]$ With each value in that vector corresponding to some classical state: $[~ |00\rangle, |01\rangle, |10\rangle, |11\rangle ~]$ What is the correct mathematical formula to derive a probability d...
I have been given the following implementation of basic list functions in LISP: nil = (lambda (k) (k ’none ’none)) (cons x y) = (lambda (k) (k x y)) (car l) = (l (lambda (x y) x)) (cdr l) = (l (lambda (x y) y)) (null? l) = (l (lambda (x y) (= x ’none))) As an intent to show that data can be constructed using only pure...
This question stems from this question and this answer. I also want to preface this question by stating that this question is done from the perspective of a RAM (or PRAM if it's more accurate term) model. From the comments in the answer, it seems like when doing algorithm analysis for the solution: $O(n)$ solution (...
I understand in open addressing hash tables some clustering will always happen just by random chance, even if the input data is perfectly random, leading to some "best possible" lookup performance hit (for an open addressing scheme). If the hash function is of low quality, and we use linear or quadratic probing, we may...
I will soon be starting a part-time job within a start-up and I've been assigned to a project where I'll have to build a CNN that recognizes and counts people in various kinds of videos. My CEO knows I have no training or experience in Computer Vision and he suggested that I should spend all my working hours in the fir...
I have been searching on the internet how to multiply a function but I cannot find any. I have only found solution in adding but not in multiplication. $add(2,3) = s(s(s(add(2,0)))) $ $add(2,3) = s(s(s(I(2))) $ $add(2,3) = s(s(s(2)) $ $add(2,3) = s(s(3)) $ $add(2,3) = s(4) $ $add(2,3) = 5 $ For example, Using the multi...
I know the difference between deadlock prevention and avoidance. But i want to know the difference between deadlock avoidance and detection. ?
I was checking this question and wondered how to apply it to the following language to prove it is in $RE$: $$ L = \{ \langle M \rangle : \exists P \text{ such that } M \text{ halts on every input } w \text{ within } P(|w|) \text{ steps} \},$$ where $P(x)$ is a polynomial with coefficients $a_1,\ldots,a_n \in \mathbb{...
I have the following notes that introduce how lambda calculus handles lists. They go as follows: A list is something we can match on and deconstruct if it is not empty: list match{ case Nil => M case Cons(x,y) => N(x,y) } A list value is given by how it interacts with two terms M and N (1) For starters I don't und...
Given a DAG $G=(V,E)$, with non-negative weights $ w_e \, \forall e\in E$, we want to modify (increase/decrease) the weights such that: $\forall u,v\in V$ and $\forall p_1\neq p_2 $ paths from $u$ to $v$, the weights ratio of $p_1$ and $p_1$ is at most 2. After modifications, the weights are non-negative The cost of ...
I am reading Automata Theory book by Hopcroft, Motwani and Ullman 2nd ed. In this book, there are these sentences: In general, if we have an algorithm to convert instances of a problem $P_1$ to instances of a problem $P_2$ that have the same answer, then we say that $P_1$ * reduces to *$P_2$. We can use this proof to ...
I have problem of interpreting Context-free grammar notation in making LL(1) parse table. To make LL(1) parse table. Two rules are shown below: If A -> α is a production choice, and there is a derivation α =>* aβ, where a is a token, then add A -> α to the table entry M[A,a]. if A -> α is a production choice and there...
When was big O first used in computer science and when did it become standard? The Wikipedia page on this cites Knuth, Big Omicron and Big Omega And Big Theta, SIGACT April-June 1976, but the beginning of that paper reads Most of us have gotten accustomed to the idea of using the notation $O(f(n))$ to stand for any ...
I'd like to show that the language DISCONNECTED-SET, defined by $$ \{\langle G, k\rangle | \text{$G$ is an undirected graph that contains a disconnected set of size $k$}\},$$ is NP-complete. (A disconnected set $S$ is defined as a set of vertices such that for every pair of vertices $u,v \in G$, if there is no edge bet...
Given a dictionary of words, and given a string which is an anagram of concatenation of group of words from the dictionary, is there an efficient algorithm to find valid set of words that can form this string ? eg1: dict = [ 'dog', 'cat', 'cow' ] s = 'ocdgatcta' ans = [ 'cat', 'cat', 'dog' ] If we join the words in t...
im having some problems when it comes to Pumping Lemma of Context-free Language ... this is the Language : $$L = \{a^n b^n c^m | n\ge 0 , 0 \le m \le 2n \}$$ Here is my attemp to prove that the language is not context-free: Assume $L$ is context-free. Let $p,r>0$ be the pumping length given by the lemma. Let $z=a^p b^...
The best approximation algorithm for vertex cover is randomly choosing an edge and removing its vertices (picking the largest degree vertex actually is a worse approximation), but the best approximation algorithm for almost the identical problem of set cover does take the largest set. How can we explain intuitively wh...
I know that the formula for the evaluation function in A* Search is given by: $f(n)=g(n)+h(n)$ I was wondering what would happen if I made h(n) negative. I suppose it doesn't make sense to have path costs that are positive but an estimate that is negative so maybe I shouldn't be asking this question? However, let's tak...
I am given a list of processes with their arrival time, CPU, time and Priority. The time quantum is given as 2 seconds. A lower priority number translates to a higher priority. (process #, arrival time, CPU time, Priority) -P0: 0, 8, 5 -P1: 2, 2, 4 -P2: 4, 1, 6 -P3: 6, 3, 3 So the priority ranks P3,P1,P0, P4. would my...
In the Wikipedia page on P vs. NP problem there is an algorithm that "solves" SUBSET-SUM in case P=NP in polynomial time. (It's idea is to find a TM that gives a certificate). But it gives "yes" in polynomial time and runs forever if the answer is "no". It can be obviously fixed to give "no" in exponential time (just t...
If I may summarize how I feel about collapse of the polynomial hierarchy: Are intractable models of computation, including collapse of $\mathbf{PH}$ or $\mathbf{PSPACE}$ above but not down to $\mathbf P$ useful for any reason besides the off chance they might collapse? Obviously "useful" is broad - I would gladly be ...
A process executing machine instruction Y right after machine instruction x.On executing x It causes a page fault. what is the next instruction that is executed immediately on restarting the process. ? assume that instead of page fault the process receives timer interrupt while executing x. what is the next instruction...
http://dickgrune.com/Books/PTAPG_1st_Edition/BookBody.pdf The book by Grune and Jacobs presents an example of a grammar that is $LL(K + 1)$ but not $LL(K)$ The example is $S -> a^kb/a^ka$ The grammar of this type is $LL(K + 1)$ but not $LL(K)$. I have an example based on the grammar shown. Is this also $LL(2)$ ? $S-> ...
Can someone tell me where we use Dynamic/Greedy algorithm and how we trace from the question that it will solved by any one of the above? Thanks
I need to fit a low-degree polynomial $p$ (with $\text{deg}(p) \leq k$) to a function $f$ evaluated on the grid $\{0, 1, ... n-1\}$, so as to minimize the $L_\infty$ norm, i.e. minimize $\text{max}_{0 \leq i < n}{\left| f(i) - p(i) \right|}$. Now, I know that for $L_2$, this can be solved using a system of linear equat...