instruction
stringlengths
35
29.1k
I want to determine the size of training data ($m$) when I know the parameters $VC(H)$, $δ$ and $e$. As I know the $VC$ bound satisfy this equation: $$ \mathrm{error}_{\mathrm{true}}(h) \le \mathrm{error}_{\mathrm{train}}(h) + \sqrt\frac{VC(H) \times \ln\left(\frac{2m}{VC(H)} + 1\right) + \ln(4δ)}m $$ but how can I det...
If an NFA with $n$ states is converted to an equivalent minimized DFA then what will be the maximum number of states in the DFA? Will it be $2^n$ or $2n$?
Which data structure can be used to "eliminate" recursion from a recursive program? Array, stack, queue, or list? How is it used to that end? When I eliminate recursion from the program computing factorial $n! = n(n-1)!$, I replace recursion with a loop. But I don't see how to do a similar transformation in general.
consider following code int f(int x) { if(x<1) return 1; else return f(x-1)+g(x); } int g(int x) { if(x<2) return 1; else return f(x-1)+g(x/2); } Questions: How do I find the growth of f(x), being that it contains a recursion to another function? Are growth and time complexity of a a function same thing? Are ...
I learned that there are two types of services in Windows , one called -service- which is in user-mode , other is called -driver service / device driver- which is in kernel-mode. What I wonder is , do kernel-level services considered as a part of the kernel? If so , does writing kernel-mode services mean extending Ope...
Below is a homework problem where we have been asked to alter a greedy algorithm to return n element instance of a set problem. The original algorithm is also below. I was thinking that I could alter line 3 so that it would run until the size of C was equal to n, and change the logic in line 4 so that it would pick and...
Are all the NP-complete problems have strong reductions? If I find a polynomial solution to one NP-complete problem, can I state that P = NP?
Valid-invalid bit is used to indicate whether a page in a process’s page table is valid or not. Why is it needed? Does that mean that each page table has a certain minimum size, i.e. it can accommodate minimum of n references to pages and if the number of pages being referenced by the process is less than n, then this ...
Consider assigning a single object to $n$ potential receivers. It can only be assigned to one person. For each receiver $k$, there is a value of profit $v_k$ and a probability $p_k$. Fix an ordering of the receivers, then for the $i$th receiver he accept the object with probability $p_i$, if he does, we gain a value $...
The question emerged while reading Ch. 3 of Rasmussen & Williams http://www.gaussianprocess.org/gpml/. In the end of this chapter, the authors gave results for the problem of handwritten digits classification (16x16 greyscale pictures); features are 256 pixel intensities + bias. I was surprised that in such a high-dime...
I've just been learning about pushdown automata and I'm trying to create one that describe the following language: {$a^n b^n c^i \in \{a,b,c\}^*\ |\ n \ge 0,i\ge 0$} What I have is the following: (state, symbol, top of stack), (next state, what goes to stack). $(s,$e$,$e$),(f,$e$)$ $(s,a,$e$),(s,d)$ $(f,b,d),(f,$e$)$ $...
I am studying Cluster Analysis and I came across BIRCH (Balanced Iterative Reduction Using hierarchical) http://en.wikipedia.org/wiki/BIRCH_(data_clustering) CF Tree insertion algorithm. I am confused what does branching factor(B), threshold for diameter of cluster in a leaf(T) means and in general how the algorithm wo...
Let $U$ be a universal Turing machine that on input $<M,w>$ simulates a Turing machine $M$ on input $w$. I have a question about what would happen if $U$ "operated" on itself. That is, what happens when we consider the input $<U, <M,w>>$? Or what about the input $<U, <U, <M,w>>>$?
Some guy on the internet recommends using the same ntp server when it is required to troubleshoot asymmetric routes through ICMP, and it's somewhat important to have synchronised time between the two machines doing ICMP. Granularity of timestamps in ICMP is 1ms (unique per 24h period), assume packet roundtrip between t...
I've got 30 elements which has to be grouped/sorted into 10 ordered 3-tuple. There are several rules and constraints about grouping/sorting. For example: Element $A$ must not be in the same tuple same unit $B$. Element $C$ must not be right in front of element $A$, etc. I am searching for an approximated algorithm: ...
I'm trying to study for an exam and I realized I'm confused about how the TLB and data cache work. I understand that the TLB is essentially a cache of most recently used physical addresses. However, I was looking at a diagram in my textbook (shown below), and I don't understand what's going on in it. It suddenly splits...
Let $L = \{ x \in \{a,b\}* | \ |x|_a \leq |x|_b^2\}$ I know this is a NOT context free language. How can i choose the correct $z=uvwxy$ and try to apply the Pumping Lemma? I think that $z=(a^n b)^n$ it's wrong, cause it's part of the language only if $n=0,1$ $z=(ab^n)^n$ should be fine. Then the relatives substring...
Im having some problems with a qeuestion regarding converting a context free grammar to chomsky normal form. I have S -> abC | babS | de C -> aCa |b I know what to do with the case of aCa and de and b but im not sure how to handle the abC case or the babS case. I believe that chomsky normal form is sup...
One of Wikipedia examples of use of Chernoff bounds is the one where an algorithm $A$ computes the correct value of function $f$ with probability $p > 1/2$. Basically, Chernoff bounds are used to bound the error probability of $A$ using repeated calls to $A$ and majority agreement. I don't understand how, to be frank. ...
I have the following two languages, which are languages of TM descriptions: $$INFINITE = \{ \langle M \rangle | \mbox{M is a TM and L(M) is infinite} \}$$ $$A_{ALL} = \{ \langle M \rangle | \mbox{M is a TM and } L(M) = \Sigma^* \}$$ Neither of these languages are decidable, recognizable, or co-recognizable. However, I...
Suppose we have a graph $H$, where each vertex represents a spanning tree of another graph $G$. We create an edge between 2 vertices in $H$ if $ST_1$ (spanning tree) contains exactly one edge not in $ST_2$ (and vice versa). How do we show that $H$ is connected?
This is one of the special cases for Chinese Postman Problem. I know the answer is (Cost of all Edges + Cost of shortest path between the odd degree vertices). How do I prove this? I am trying to prove the solution to this UVA problem.
Clique problem is a well known $NP$-complete problem where the size of the required clique is part of the input. However, k-clique problem has a trivial polynomial time algorithm ($O(n^k)$ when $k$ is constant). I'm interested in the best known upper bounds when k is constant. Is there an algorithm with run time $O(n...
The ICMP timestamp protocol is useful for determining which path — forward or reverse — is contributing to the jitter on the line. In an ideal world, all computers would have an excellent ntpd, and time accuracy of about 1ms (the granularity of ICMP timestamp) should not be a problem: 0 145.5 146 = 75 + 71 1 ...
Considering two sets $A, B$ containing some $p$-dimensional points $x \in \mathbb{R}^p$. Let $d_x^S = \min_{x' \in S \setminus \{x\}} \lVert \mathbf{x} - \mathbf{x'} \rVert$ denote the Euclidean distance from $x$ to its nearest point in $S$. We have a very simple algorithm: $\forall x \in A$, if $d_x^A > d_x^B$ then m...
I tried to solve the exercise: Proof that determining the existence of a Hamilton Path in a bipartite graph is NP-complete by making a bipartite graph from a general one (undirected) by inserting a vertex in the middle of every edge of the first (general) graph. This generates problems as suggested here: Finding the ...
Given the language $L_1 = \{a^i b^j c^k \mid i \neq j \vee i \neq k\}$, I need to determine whether it is context-free by using the pumping lemma. I must do the same for the complement of this language. I started off by breaking $L_1$ into two parts, $L_1 = L_2 \cup L_3$, where $L_2 = \{a^i b^j c^k \mid i \neq j\}$ and...
How do I precisely define the function which is a mapping reduction of A to B for the following examples? What is the process of figuring this out? Given: A and B are languages over the alphabet {0,1}. Examples: A is the language described by 1*0*, B is the language described by 01*0* A={w | the length of w is even}, ...
I have no clue how to prove this question. Consider the language $L = \{ \langle D_1, D_2, ... ,D_K \rangle : k \in {N},$ the $D_i$ are DFAs and ${\bigcap}_{i=1}^k L(D_i) = \emptyset \}$ Prove that L is NP-hard. Can someone guide me through this problem? I understand that I will have to reduce it into something, I ju...
I have been trying to implement an algorithm to detect cycles (probably how many of them) in a directed and undirected graph. That is the code should apply for both directed and undirected graphs. Using DFS or topological sort is mostly recommended in various posts. But largely, everything is addressed for undirected g...
I'm trying to build an algorithm which takes two lists of natural numbers and finds if every element of the first list is displayed at least once in the second list. What if the list is sorted? An algorithm that can do this is by comparing every element of the first list with every element from the second list. I thin...
I am studying the following paper for understanding next-word prediction using n-gram & trie: - http://nlp.cs.berkeley.edu/pubs/Pauls-Klein_2011_LM_paper.pdf Before this, I did some brief study on what are n-grams. And, I know trie data structure. The issue is - the algorithm in paper is not so intuitive to understand....
I Know that determining Hamiltonian cycle in a graph is NP complete. For the sake of my clarification, I just want to know that whether the problem remains NP complete with following restrictions ? 1) Graph is undirected , and every node has degree two. Any help will be appreciated. Thanks.
I was looking into how a next-word prediction engine like swift key or XT9 can be implemented. Here's what I did. I read about n-grams here - en.wikipedia.org/wiki/N-gram and aicat.inf.ed.ac.uk/entry.php?id=663 I read about Language Models/Markov Model/n-grams/training/Smoothing/Back-Offs - en.wikipedia.org/wiki/Langu...
I have just started learning Theory of Computation and have come across a question which I am not able to solve. The question is as follows: Design a DFA that reads a word (character strings) and decides whether the letters of the word are in sorted order. For example: 'adept' and 'chilly' have their words in sorted or...
Let $G_1,$ $G_2$ be two arbitrary graphs with $n$ vertices and we want to check if they are isomorphic. Question 1. For what maximal value of $n$ we ​​can actually perform such verification? Question 2. Is there any result like as a list of all non-isomorphic graphs up to $n$, and what is the value of $n$ — 10, 20?...
If I have a variable x bound to a machine precision real in Mathematica, I can use y = FromDigits[RealDigits[x]] then y is bound to a completely equivalent rational number which has infinite precision. What are the basic principles behind FromDigits and RealDigits? How could I implement a similar conversion using com...
Assume you have an object moving at a constant velocity(up, down, left, right) in a grid. You have unlimited resources (memory, time). At any given time step in the grid, you can "guess" the location of the object, and you win if it is currently at that position. Without relying on probability techniques, what would be...
$L$ is a regular language and $w$ is any word, not necessarily in $L$. We define the set as $$L/w = \{x \in \Sigma ^* \mid xw \in L\}.$$ Show that $L/w$ is regular. I'm really struggling with this one. I know its going to come on my final next week.
Suppose that G is a context-free grammar. How can I show that “Is L(G) regular?” is undecidable. Also, prove that L is always context-free but is regular if and only if L(G) = Σ∗. This is what I have so far Let N be some language that is known to be context-free but not regular (for example, {a^nb^n | n ≥ 0}). Conside...
I am having a rather distressing confusion about whether storage media and storage devices are the same terms. I found on this yahoo answers page that there is a subtle difference but very tricky to understand. I have googled a lot but cannot find the satisfying answer. Can anyone kindly explain the difference between ...
According to CLRS, each iteration of the outermost loop (on $k$) makes a new copy of the adjacency matrix. Is it safe not to copy the matrix on every iteration? What I mean is, according to CLRS: $d_{ij}^K = \min(d_{ij}^{K-1}, d_{ik}^{K-1} + d_{kj}^{K-1})$ Is the following possible? $d_{ij} = \min(d_{ij}, d_{ik} + d_{k...
So given an input of lets say 10 strings, what way can we input these so we get the best or worst case for these two given sorts? Heap sort: best case - nlogn worst case - nlogn Quick sort: best case - nlogn worst case - n^2 Where I get confused on these two is: heap- Since the best and worst case are the same does ...
Introduction and notations: Here is a new and simple version of my algorithm which seems to terminates (according to my experiments), and now I would like to prove that. Let the notation $x_i \in \mathbb{R}^p$ refer to a $p$ dimensional data point (a vector). I have three sets A, B and C, such that $|A| = n$, $|B| = m$...
I'm asked to prove that, if P=NP, that 0*1* is NP-complete, but I'm having trouble going about doing it. I know it's fairly easy to prove it's NP by creating a TM to verify an input (which can be done in O(n) time, and that's polynomial). But then I now have to reduce an NP-complete problem to 0*1* in order to prove t...
The question (Prove L is NP-hard) was about proving that the following language is NP-hard: $$ L = \{ \langle D_1, D_2, ... ,D_K \rangle : k \in {N}\text{, the } D_i \text{ are DFAs and } {\bigcap}_{i=1}^k L(D_i) = \emptyset \} $$ That got me thinking about the related problem: $$ L' = \{ \langle D_1, D_2, ... ,D_K \ra...
I read a claim that there are formulas for which any equivalent CNF has exponential length. Can you show me an example for such a boolean formula? I have been trying to build it myself and failed.
I've converted this NFA to a DFA and I get a similar soultion automata but I'm not sure if I really understand everything. Please correct me if I'm explaining it wrong, I would love some feedback. From the state 0 we only have the set {0} since there doesn't exist any ε-transition. After that we have to input "a" to m...
I have a genetic algorithm in Java and I'm testing new types of selections. For my tests I'm using the De Jong Half Sphere, my fitness function is $x^2 + y^2$. The selection method used is Sigma scaling : fscaled = S + (fraw −fmean)/2σ Example using S=1 - a) Fitness = 5.927822124 | After Scaling = 0.900756351532265...
For clarity, I attach below a concise implementation of the algorithm in Python. I understand that it checks all possible element swaps, but I don't see how that necessarily means that all possible orderings of the elements will be reached, and/or that no ordering will be duplicated. For example, what if the elements a...
Does there exist a Turing machine that halts on all inputs but that property is not provable for some reason? I am wondering if this question has been studied. Note, "unprovable" could mean a "limited" proof system (which in the weak sense think the answer must be yes). I am of course interested in the strongest poss...
I would like some hints on how to approach this problem, I know for instance that $TQBF$ is $PSPACE$-$Complete$, so it can solved in poly space and any other $PSPACE$-$Complete$ problems can be log spaced reduced to $TQBF$. I believe that I need to employ the space hierarchy theorem in some way but I am not sure how, t...
I got an amount of numbers, they are shuffled and represent the individuals. For example (3,1,3,2,5,22,5) is one individual or (22,3,1,3,5,5,2). Mutation is done quite easy by permutation within an individual. The problem is to find a crossover method between 2 individuals, in which the quantity of the values stay the ...
What is the range of “the” CRC-32, the one used by Unix, Ethernet, zip, and many other industrial standards? Mathematically, a CRC is defined as follows: let $G$ be the CRC polynomial in $\mathbb{F}_2[X]$, and $M$ be a representation of the input bitstring in $\mathbb{F}_2[X]$. Let $Q$ be the quotient of $M \cdot X^{\d...
I'm searching for computer vision or machine learning algorithms/methods that are used to classify or differentiate two outdoor environments. Given an image with vehicles, I need to be able to detect whether the vehicles are in a natural open landscape (desert, in particular), or whether they're in the city. I've sear...
Is it common to try to improve an algorithm by decomposing its action on a topological piece of data (e.g. graphs, geometric data) into a series of steps, each of which only makes a local change/perturbation in a confined neighborhood of the data while fixing the rest? One benefit of this "breakdown" is improved concep...
I'm looking for a way to position nodes on a 2-dimensional plane in such a way that the distances between the nodes, which are entered exogenously, are represented visually in a way that as good as possible communicates the logical distance between those nodes. Basically, I have a set of nodes A, B, C etc. and between ...
I wish to estimate the compression ratio of a stream of bytes. Specifically, I'm interested in DEFLATE compression. I'm looking for some algorithm/heuristic that can estimate roughly the compressibility (more quickly than just deflating the stream). My main interest is not on the absolute value of the compression (tho...
Is it possible to build DFA that support \d, \w, .(any symbol)? I understand that we can add each symbol from [0-9] as a separate edge for some of the symbols, but what about the others? for example .(any symbol)? or \S (not white space)? In other words, can we build equivalent DFA for this NFA (1) ---a----> (2) | |...
When can an algorithm be said to have $O(1)$ complexity? My doubt is if $n$ is specified to be a large number but constant and we cannot implement it in reality without a loop even then can we call it to have $O(1)$ time complexity? Consider the following examples. Algorithm to add first 1000 natural numbers (that is ...
Let's say we want to draw the transition graph of a Turing Machine that accepts that language L and then write the sequence of moves done by the TM when the input sequence is $w = abbcbba$ so I had some thoughts on how this could be built. $q0 - q1: a,a,R$ $q1-q2: b,b,R$ $q2 (loop): b,b,R$ $q2-q3: c,c,R$ $q3-q4: b,b,R...
It is NP-hard to approximate maximum 3D matching problem even if each element occurs exactly in two triples. I'm interested in the following decision version of 3D matching. Informally, Given a set of triples $F$ of elements such that each element occurs exactly in two triples, Is there a subset of $F$ such that each ...
Suppose we are given an array of numbers representing lengths of line segments. Find which three of these segments can be assembled into a triangle with maximum area. I can compute the areas of all $O(n^3)$ possible triangles in $O(n^3)$ time using Heron's formula, and then return the largest. Can this be improved to ...
I have this nondeterministic pda: $$\Sigma= \{a,b,c\}$$ and $$ L=\{\omega\ \epsilon\ \Sigma^*\ |\ \omega\ = \alpha\beta\beta^R\gamma\ and\ \alpha,\beta,\gamma\ \epsilon\ \Sigma^*\ and\ |\beta|\ >3 \} $$ So once i have create the NPDA, i have to calculate the probability of accepting a correct word, i know it depends...
I always see that people in the fields consider confusing vectors with positions as a severe error in one and n dimensions. Recently I have also encoutered a timedelta type in Python. By increadably inadequate reaction and severe punishment, I realize that people in the fields taboo answering why is the difference. Mig...
Presume I have the following case: int value a int value b, for which a < b int value i, for which a <= i < b I need an int value x, for which a <= x < b, randomly chosen, according to a non-uniform distribution: the distribution should follow a bell curve which is centered around i. In Java, I have the following met...
So I've been given the following language on an assignment. It is the only question I have left of 10, and I've been racking my brains out trying to solve it for hours. $$L=\{w:w\in(a+b+c)^*, n_a(w) > n_b(w)>n_c(w)\}$$ where $n_x(w)$ represents the number of character $x$ found in $w$. The problem statement is: pro...
I am a CS student. When I first came to school, I thought that programming was to make a software. Now I found I was wrong. Now I want to know what the difference is, and what is the difference between a programmer and a software engineer. I hope people can give me some advice. (forgive my broken English)
Given non-repeated list of integers $a_1\dots a_n$, is there $ATLEAST\mbox{ }ONE$ subset of them that sum to $0$. This problem is NP complete. Given non-repeated list of integers $a_1\dots a_n$, are there $ATLEAST\mbox{ }TWO$ subsets of them of sizes $n_1$ and $n_2$ such that $n_1+n_2=n$ each of which sums to $0$. Is...
How would you approach the knapsack problem in a dynamic programming situation if you now have to limit the number of item in the knapsack by a constant $p$ ? This is the same problem (max weight of $W$, every item have a value $v$ and weight $w$) but you can only add $p$ item(s) to the knapsack and obviously need to o...
Background. I am writing some code for semi-automated grading, using peer grading as part of the grading process. Students are given pairs of essays at a time, and the students have a slider to choose which is better and how much better it is. e.g., the slider might look something like this: A---X-B Based on the resul...
What bad things can occur when the lengths of the time slices in a multitasking system are too small? What can happen when they are too big? How should the length of the time slice be chosen?
I have an ensemble of points in 3D space, represented by their coordinates $\mathbf{c_i}\equiv(x_i,y_i,z_i)^\top$ . I need to calculate the distance between all these points: $\quad\forall i,j\quad d_{ij} \equiv |\mathbf{d_{ij}}|\equiv |\mathbf{c_j}-\mathbf{c_i}|$ the scalar product between all distances that share a ...
My doubt is based on the relation between regular grammar and regular languges $S \to Sa\ |\ a$ produces the regular language $a^+$ but this grammar is not type-3 grammar of Chomsky classification. So am I correct in stating that this is not a regular grammar even when it produces regular language?
Given is the following graph which is logically divided into layers (with Dijkstra's shortest paths algorithm): Vertices Layer Root 0 / \ A B 1 / \ | C D E 2 \ | / \ | / F 3 Now I'm looking for an algorithm which groups vertices when they have a (single) common ...
Is the language $L_{universal} = \{ \left \langle M \right \rangle | M \textrm{is a universal turing machine} \}$ decidable? I'm guessing it is decidable according to the definition of a UTM, that a UTM must be able to calculate every recursive function. Since the set of recursive languages and the set of all input wo...
Given the following multiplication table how could one construct an NFA such that it accepts all strings that have a certain product (say a) ? The string "abcb" would be evaluated as (a(b(cb))) = a \begin{array}{c|ccc} \times & a & b & c \\ \hline a & a & a & c \\ b & c & a & b \\ c & b & c &a ...
I'm studying for my CS final and I can't seem to get the anywhere with one of the questions. This is the question: Prove that if a node in a BST has a successor, but has no right child, then its successor must be an ancestor. (We will consider only BSTs with distinct elements.) I know that a successor is the node that ...
I need to modify the Dijkstra's algorithm to get the shortest path in a directed graph and get the one with the least amount of edges if there are equal paths. I am thinking to add another data field to count the number of edges from start and compare them in same way as weights. Would that work?
I have a question to find out that L = {a^(2k)|k>=1} is regular. I know that it is regular set but I was looking to find out if pumping lemma is satisfying or not. So I tried it as - Let # of states in the FA be n & I select the string w = a^2n Now let xyz = w xy = a^n y = a^m | m is odd number now x(y^2)z = a^(n-m)(a^...
I need to compute the bottleneck shortest paths from s to all vertices of a graph by modifying the Dijkstra’s algorithm. I found this explanation on Wikipedia(Link to Wikipedia) but I would appreciate if you can elaborate it a bit for me. If the edges are sorted by their weights, then a modified version of Dijkstra'...
There are many techniques to prove that a language is not context-free, but how do I prove that a language is context-free? What techniques are there to prove this? Obviously, one way is to exhibit a context-free grammar for the language. Are there any systematic techniques to find a context-free grammar for a given ...
This question is inspired by this SPOJ problem. That problem asks median of the final array, that can be done in $O(k+n)$, where k is the number of update queries and n is the size of the array. The variant : Given an array of length N (of the order $10^5$), initially all elements are 0. There are K (of the order $10^5...
I am a physicist, with little formal training in computer science - please don't assume I know even obvious things about computer science! Within the context of data analysis, I was interested in identifying clusters within a $d$-dimensional list of $n$ data-points, for which the dimensionality $d$ could be $\sim100$,...
I can see from this question that a $K_{r + 1}$-free graph with $n$ vertices and $e$ edges contains an independent set of order at least $$\frac{n}{2e/n + 1} \tag{1} $$ Since for a $C_{n}$/$P_{n}$ we know how many edges it contains it is easy to determine (1). However, are there any particularities of cycle graphs and ...
I have come across many sorting algorithms during my high school studies. However, I never know which is the fastest (for a random array of integers). So my questions are: Which is the fastest currently known sorting algorithm? Theoretically, is it possible that there are even faster ones? So, what's the least complex...
I need to describing a Turing machine that computes $\lceil\log_{2}(n)\rceil$ I know that: n = 1, 2, 3, 4, 5, 6, 7, 8, ... f(n) = 0, 1, 2, 2, 3, 3, 3, 3, ... So I'm thinking of putting $n$ on the tape. Then keeping a count of how many times I multiply 2*2 until it is greater than than $n$. For example for n=5, 2*2*2=8...
Let $n$ be an integer, and let $\mathbb{Z}$ denote the set of all integers. Let $[a,b]$ denote the interval of integers $\{a,a+1,a+2,\dots,b\}$. I am looking for a data structure to represent a map $f:[1,n] \to \mathbb{Z}$. I want the data structure to support the following operations: $\text{get}(i)$ should return ...
All the article I can find seems to talk about multitasking and context switch as its a two different thing. It seems that multitasking and context switch are the same thing.
How does one construct the residual network in such a case? The formula is for edge $(u, v)$ is $$rf(u,v) = (c_{\mathrm{upper}}(u,v) - f(u,v)) + (f(v,u) - c_{\mathrm{lower}}(v, u))\,,$$ where $rf(u, v)$ is the residual flow on the edge $(u, v)$, $c_{\mathrm{upper}}$ and $c_{\mathrm{lower}}$ are capacities on the edge...
I am looking for an efficient way to count the number of coprime vectors in a finite and bounded set of integer vectors. The vectors in my set are $N$-dimensional integer vectors whose components are bounded on the top and bottom by an arbitrary value $K$. Let $x = [x_1,x_2,\ldots,x_N]$ denote a vector from this set. T...
Please correct my statement. Assuming $L\in NP$, and algorithm A can determine L in poly-time in a nondeterministic machine, we have algorithm $A'$ and the complement of $L$ -- $L'$. $x$ is the input of $A'$ A'(x) { if(A(x) is true) return false else return true } In this code, it seems like $A'$ can...
I'm having trouble understanding some language notation, primarily what rules I can take away from it. The language is as follows: $\qquad L = \{a^n b^m b^p c^p b^{n-m} \mid n > 0, m < n, p > 2\}$ My goal is to create a context free grammar from this, but I can't get my ahead around the rules in place here. In plain En...
I read on a blog that there are mistakes in Karp's paper where he proved that 0-1 programming is NP-Complete, but I couldn't find it, can anyone explain? And I doubt that there are also mistakes where he proved Steiner Tree Problem is NP-Compelete but not sure. The blog post a little old and I thought asking the writer...
There is a 64 KB 1-word cache, and a word is 32 bits. From that I can derive that the length of the tag field is 16 bits, the length of index field is 14 bits, and, as my professor taught me, there is always 2 bits left behind for a byte offset. Why the offset field is 2 bits, other than it fills in the remaining 2 bi...
My friend asked this problem recently & am not sure which sorting to use for this kind of problem:- There are 20 stones of different heights. Each stone is so heavy, we need to sort the stones such that smallest stones are to left and highest to right. As stones are heavy make algorithm which moves stone least distance...
A YouTube video I was watching explained the differences between Imperative and Functional programming by demonstrating how the numbers from 1 to 10 are summed up in Java and in Haskell respectively. In Java, you must explicitly state each step and assign the result of each step to a variable - something like the foll...
All of the solutions for the zebra puzzle have a variable for each of the properties and a domain with the possible values. For instance A for Nationalities, B for pets, ... Ai with i = 1..5 and the domain for example {Dutch, Spanish, Italian, French, English} As I've seen in the n-queens puzzle, there can always be mu...
There seems to usually be a tight connection between decision problems and (corresponding) optimization problems in general. However, is this always the case? Are there examples where the typical "tight coupling" between a decision problem and the correponding optimization problem breaks down or behaves in an unusual...
when converting an NFA to DFA, we create sub-sets of states in the NFA. does it mean that every DFA-converted-from-NFA contain 2^Q states? or if some sub-sets are unreachable then they are not included in it?