instruction
stringlengths
35
11.4k
Given $G=(V,E)$, undirected graph, a group of vertices $S$ is called almost clique if by adding a single edge, $S$ becomes a clique. Consider the language: $L=\{\langle G,t\rangle \mid \text{the graph \(G\) contains a \(t\)-sized almost-clique}\}$. Prove that $L$ is NP-complete. Obviously, it is solved by polynomial re...
My loop is pretty simple. The function takes in two parameters, a and b; both are integers where a<=b. The function will then create a list of numbers from a to b. This is what I created: def cat(a,b): j = [] for i in range (a,b): j.append(a+1) a +=1 I honestly cannot figure out how to turn ...
I am interested in the alpha equivalence relation in languages with variable bindings, such as: t := x:y 'x belong to y' | bot 'False' | t -> t 'implication' | Ax.t 'forall x, t' Or the pure lambda calculus: t := x 'variable' | (t t) 'application ' | Lx.t 'abstraction: \x -> t' I am ...
As in the title, I am trying to find the largest (aka least upper bound) of a (very large) set of integers. Importantly, I do not have direct access to the full list of integers, but I do have a function $f(n)$ which returns true/false if $n$ is in the set. The function $f(n)$ is expensive and I would like to minimiz...
I'm trying to create a mcts ai for connect 5 algorithm. However, I'm confused on designing the tree. Here is a quick description of the algorithm: The initial state, S0 is the board state where the AI places the stone, or in other words, the AI's turn. Is it correct that each node should be the AI's turn, not the human...
I have to solve a system of up to 10000 equations with 10000 unknowns as fast as possible (preferably within a few seconds). I know that Gaussian elimination is too slow for that, so what algorithm is suitable for this task? All coefficients and constants are non-negative integers modulo p (where p is a prime). There i...
Sometime you want to model some data from the real world using a graph, but such that edges don't just connect to a vertex; rather, they connect to some aspect of that vertex - some connection if you will. For example, a node in a family tree would be a person, and they have a mother and father (never mind about adopt...
We're given the algorithm which uses stack in order to store data (stack is implemented via an array). When the stack is full the algorithm does the following: Creates a new array double the size of the original one. Copies all elements of the old array to the new array, preserving the order. Adjust the algorithm so...
For a nondirection graph $G=(V,E)$, I need to write an algorithm that finds connections that can be removed without destroying the graph (ex: a connection from a child of a child back to the root of the graph). I have created an algorithm with a runtime of $O(|V|+|E|)$ (utilizing BFS): smallerGraph(G,s): for al...
I have a question regarding multilevel page tables. As far as I know, in most 64 bit systems only 48 bits are used in page tables which would allow for 256TB of virtual memory to be addressed. For personal computers, I don't understand how they would ever be able to support that amount of memory being virtualized. If t...
I am new to machine learning. I have read several papers where they have employed deep learning for various applications and have used the term "prior" in most of the model design cases, say prior in human body pose estimation. Can someone explain what does it actually means. I could only find the mathematical formulat...
Given is graph with networks and bridges/switches. We know, the root Bridge is the bridge with the minimal Bridge-ID. The connections between every bridge and network is 1. In the lecture slides they calculated the "best"(shortest) path from one network to the root bridge. I assume they used BFS, because it would be th...
I am studying generalized Büchi automata and I don't really understand when a state is considered to appear infinitely often. The definition I have is: A state $s$ appears infinitely often if there exists an infinite set of points $i \in N$ such that the $i$th state of the execution is $s$. But there's also an example ...
I'm studying data structure. When I read the chapter of heap, something really confused me. DecreaseKey's time complexity of the binary heap is O(lgn). However, I found somewhere on internet claimed that Leftist Heap doesn't support DecreaseKey operation. But I wonder why? Can't we simply treat leftist heap as binary h...
This question might be too broad, but I really need help with this. I am required to choose a standard or notation to model an integration between two business processes, one of which is external. The question is - are there any standards/notations than can compete with UML Activity Diagram or BPMN. If there are, which...
I am going through the book on lambda calculus by Hindley and Seldin . They introduce the syntactic equivalence of expressions and proving them by a technique named "induction" , which has not been directly defined in the book . (a) $[N/x]x \equiv N$ (b) $[N/x]a \equiv a$ for all atoms $a \not \equiv x$ (c) $[N/x](PQ)...
In one of my courses, Big-O notation was used for defining what a sparse matrix is, under the context of qualifying for suitability for a particular set of linear algebra algorithms. I looked around on the net, and only found more such uses that I have an issue with. To say a matrix is sparse if it has O(n) non-zero el...
I was reading Jeff E's lecture notes on Algorithms when I came upon the following question: Describe and analyze an efficient algorithm that determines, given a legal arrangement of standard pieces on a standard chess board, which player will win at chess from the given starting position if both players play perfectly....
I was thinking about how effective it would be to calculate the number of CPU instructions a section of code would have and then trying to estimate the energy cost for a program. But I was curious if there were more elegant ways of going about this?
As part of my research, I have recently written an algorithm for mining medical data. We are looking to potentially publish some of the data we collected however I would like to describe the algorithm I used in detail. I was really curious about the algorithm so I recently programmed a dummy data generator and tested t...
Given a Directed Tripartite graph with 3 Groups of vertices {A, B, C} such that: Edges from A are directed in B. Edges from B are directed in C. Objective: Minimize the number of vertices in B (by keeping few and deleting the rest) such that every vertex in C is reachable from every vertex in A. I think this can be c...
Given a directed Graph and two vertices $S$ and $D$ (source and destination) such that each of its edges has a weight of the form: $A_i+B_ix_i = V$ where $A_0$ is a non negative integer, $B_0$ is a positive integer, $x_i$ a variable that can take non negative integer values (each variable used only once in the graph). ...
Let's consider the following situation. We have a finitie alphabet $A$. Let $A = \{a_1, .., a_k\}$ We consider words over $A$ of length exactly $n$. I am trying to solve some problem and I am going to: Generate every word using non-deterministic Turing Machine. And, for every generated word make a computation $C$. that...
Following up on this post denoting $(x \leftrightarrow y)$ the permutation of $x$ and $y$ and $P[x \leftrightarrow y]$ the term obtained from the term $P$ by permuting $x$ and $y$ (so for example if $P = \lambda x. \lambda y. x y$ then we have $P[x \leftrightarrow y] = \lambda y. \lambda x. y x$) (note that such trans...
I am trying to find a general solution for the given A,B,C in dynamic arrays. Those veriables presents factors in the following operations : given : c_i the size of the array after operation O_i (c_0 := 0) s_i is the number of elements after operation O_i (s_0 := 0) c_i ≥ s_i after pushBack: if s_i−1 = c_i , then ...
Why are we interested in negative edge weight cycles when finding out SSSP. In a path, we are not allowed to traverse a node more than once.
Can someone help me to construct a deterministic PDA for the following language: $L = \{0^n1^m | n \geq m$ and $m,n \geq 0 \}$ Here is my suggestion : the states are z0,z1,z2 , z0 is final state , for the empty string , z1 should also be finate state :
This problem probably falls under some category of algorithms but I don't know which. A given restaurant has $b_1..b_n$ branches around the world. A food critic has to travel all of the branches. When the critic finishes visit to the branch $1 \le j\le n$ he gets paid $m_j$ money by his employer for the job. For bra...
Regarding CPU cache, if the CPU does not find the data it needs in the cache, I understand it then looks for it in the main memory (RAM). (Let's assume we have only one level of cache in order to keep this question as simple as possible.) My question is this: if the data is found in main memory, what happens? Does the ...
The problem is this: Let us have an int array of length n. Find an algorithm to determine if the array represents a min-d-heap. My solution: We start from the first index in the array, and compare its value to the value of its children (all the nodes at locations $i*d+k$ where $k \in \{1,2,...d\}$, assuming we start th...
Let's say that when initializing a pet class, I wanted to exclude or disallow dogs or cats as species. What would be the proper way to throw an invalid_argument exception? using std::string; #include <stdexcept> using std:: invalid_argument; struct Pet { const string name; long age = 0; const string species; Pe...
So I have a pic which I think illustrates my confusion: the read surrounds what I wonder is the head? Does head refer to a node with both a data and next, or only a node with next? In other words, which marked box does it refer to in my pic?
2-SAT is unsatisfiable iff it contains unsatisfiable XOR-2-SAT. So, first, we just need to combine every clause that contains share same variables (both of them). Then, all of those which remain uncombined are "uninteresting" (don't affect satisfiability). Example: $\Phi = (x \lor y) \land (\overline x \lor \overline ...
I think I'm pretty confused about what's called a calculus and what's called a programming language. I tend to think, and might have been told, that a calculus is a formal system for reasoning about the equivalence of programs. Programs have an operational semantics specified by a machine, that should (I think?) be det...
I dont think this is true, take the language with a single element L = {0}, then the complement L' would have infinitely many strings (everything that isn't 0). So if it were true that A is mapping reducible to its complement, everything in L' can be obtained via a computable function from some element in L, i.e 010 i...
Is $L = \{\langle A\rangle\mid A\text{ is a DFA and }L(A) = \Sigma^*\}$ decidable? I know that $L'=\{\langle A,w\rangle \mid A\text{ is a DFA and }w\in L(A)\}$ is decidable, but I'm not sure if this is related.
I have been told (generic explanation) that 3SAT could be converted to unary 2DFA with endmarkers (assuming each variable of 3SAT as a prime number and then for each clause creating a cycle in unary 2DFA). Can someone please provide an example of the above with explanation of the process (a small example, say 3-4 claus...
I have three different algorithms for achieving a target. Algorithm 1 takes $O(Mn)$ - $M$ is constsnt and n is variable,Algorithm 2 takes $O(min(p^3,n^3))$ - both $p$ and $n$ is variable and Algorithm 3 takes $O(nk+nd)$ - $k$ constant, $n$ and $d$ is variable. Is it possible to compare these algorithms? Which algorithm...
I am quoting a paragraph in Operating System Concepts by Silberschatz, in paging chapter, In addition, the operating system must be aware that user processes operate in user space, and all logical addresses must be mapped to produce physical addresses. If a user makes a system call (to do I/O, for example) and pro...
This are two sections from a task I got. The Young tableau is defined as a matrix of m rows on n columns so that the bars in each row are sorted in ascending order Left to right and the elements in each column are sorted in ascending order from top to bottom. Some of the elements in the Young tableau may be $\in...
Given two representations of the same abstract data type, any optimal program that incorporates one representation has a corresponding optimal program that incorporates the other. What is the field of computer science that studies program transformation between two such optimal programs? If necessary, posit the practic...
I wonder what is $K(x|K(x))$, $K$ denoting (Kolmogorov-Chaitin) prefix complexity. Naively, it looks like it should just be $K(x)+O(1)$. Is that right? The same question for plain Kolmogorov complexity is interesting as well.
I have two sets of vectors $(\mathbf{l}_i)_{1\le i \le n}$ and $(\mathbf{r}_i)_{1 \le i \le n}$. Each vector $\mathbf{l}_i$ is in $[0,1]^4$, same for $\mathbf{r}_j$. I'd like to maximize the dot product $\mathbf{l}_i \cdot \mathbf{r}_j$, i.e. find tuples $(i,j)$ s.t. $\mathbf{l}_i \cdot \mathbf{r}_j$ is as big as possi...
I'm approaching some continuous optimization problems by considering discrete approximations of them at different resolutions. Those discrete approximations can be solved with linear programming solvers, like GLPK. After having solved a discrete approximation at resolution $h_0$, I can produce a reasonably good feasibl...
I'm looking for resources on (partial) type inference for dependent types. For example there could be a type inference scheme that fails if the term doesn't have a principal type, or a scheme that makes some choices and infers non-principal types. I'm also not sure how to integrate type inference into constraint-based ...
Using a bipartite graph to represent hypergraphs as described by Wikipedia : A hypergraph $H$ may be represented by a bipartite graph $BG$ as follows: the sets $X$ and $E$ are the partitions of $BG$, and ($x_1$, $e_1$) are connected with an edge if and only if vertex $x_1$ is contained in edge $e_1$ in H. Conv...
Valiant's theory of PAC learning looks at the tradeoff between expected error and algorithm runtime in different classes of learning problems. In particular, a lot of his analysis focuses on which classes of disjunctive normal form (DNF) formulae are learnable in polynomial time while minimizing expected error (PAC le...
$L_1 = \{ a^i b^j c^m \mid m ≥ min(i,j) \}$ $L_2 = \{ a^i b^j c^m \mid m ≥ max(i,j) \}$ Which language is CFL ? ANS : $L_1$ is CFL but $L_2$ is NOT. My understanding :  For Language $L_1$ : ( Here I am also interested in checking whether the language is DCFL or not. )  Checking DCFL or not :  By looking at language $...
We already know that $H:=\{\langle M,w\rangle | M$ halts on $w\}$ is undecidable, then how can there possibly be a machine that decides any infinite subset of $H$?
I want to prove that the hardness of the Steiner tree problem lies in determining the optimal subset of Steiner vertices that need to be included in the tree and I need to show this by proving that if this set is provided, then the optimal Steiner tree can be computed in polynomial time. It is clear that we can find an...
Having string $S$ of length $n$, finding the count of distinct substrings can be done in linear time using LCP array. Instead of asking for unique substrings count in whole string $S$, query $q$ containing indexing $(i,j)$ where $0 \le i \le j < n$ is asking for count of distinct substring inside given query range for...
I am currently reading the book "An Introduction to Functional Programming through Lambda Calculus" (the 2011 edition) and am a bit puzzled by the definitions of free and bound variables with regards to function application. The book states, in section 2.10, that a variable is bound in an expression if the expression ...
Could someone please explain me, what is a fix point? I caught the minimum explanation about fix point from the website: After infinitely many iterations we should get to a fix point where further iterations make no difference. It means that applying one more ExprF would't change anything -- a fix point doesn't...
Determine whether the following language is decidable, recognizable but not decidable, co-recognizable but not decidable or neither recognizable nor co-recognizable. Prove your answer. $$L=\left\{ \left\langle M\right\rangle |M\text{ is a TM and }A_{TM}\leq\mathcal{L}\left(M\right)\right\} $$ [Where $\mathcal{L}(M)...
Is the following language decidable? $$L = \{A : \text{A is a DFA and } |L(A)| \ge 2\}$$
I want to show that it satisfies Rice's theorem: (i) $L$ is non-trivial, since $\langle M\rangle \notin L$ where $L(M)=\emptyset$, as $M$ halts/rejects any input string in the first step. (ii) if $L(M_1)=L(M_2)$ where $M_1$ and $M_2$ are turing machines, then $M_1$ makes more than 10 steps on some input iff $M_2$ makes...
Is there an efficient algorithm for the following problem? Given: a $m$-vector $b \in \{0,1,2\}^m$, and a $m \times 2m$ matrix $A$, with the promise that for every $b' \in \{0,1,2\}^m$, there exists $x' \in \{0,1\}^{2m}$ such that $Ax'=b' \pmod 3$ Goal: find $x \in \{0,1\}^{2m}$ such that $Ax'=b' \pmod 3$ In more detai...
When reading up on deep learning from various sources, one is often presented with the notion that deep learning is essentially a black box: A set of recipes, heuristics and empirical best practices that have been found to often work, but where the mechanism by which good results are achieved is usually not well unders...
Is there a maximum possible ratio of white/black pixels in an edge map? In my theoretical consideration all areas in an image which have the same intensity are black and only the edges are white. Hence, the white/black ratio must be theoretically smaller than 50/50 in any conceivable picture of our environment (In my o...
1. Calculate the total number of moves required i.e. "pow(2, n)- 1". Here n is number of disks. 2. If number of disks (i.e. n) is even then interchange destination pole and auxiliary pole. 3. for i = 1 to total number of moves: if i%3 == 1: legal movement of top disk between ...
In the PAC-learning setting, it is easy to learn a CNF formula when we know each clause has at most $c$ variables. We go through each positive sample, and eliminate every clause that contradicts the sample. Learning a DNF formula is said to be much harder, but it seems a similar procedure can be used, so it is unclear ...
Many complexity classes have "complete" problems. Do complete problems exist for the complexity class of problems that can be solved in $O(1)$ time? A complication is that this class depends on the model of computation; a problem can be solvable in $O(1)$ time in one reasonable model of computation but not another, giv...
Does removing the leading(or trailing) n bits of any given hash have any negative effects other then increasing the likeliness of collisions? Does appending 2 hashes of the same object with different seeds have have any negative effects? For some context I am building a Bloom filter that has a variable size and would l...
The literature is fairly clear that unit-cost RAMs with primitive multiplication are unreasonable, in that they cannot be simulated by Turing machines in polynomial time can solve PSPACE-complete problems in polynomial time However, all of the references I can find on this topic (Simon 1974, Schonhage 1979) also invo...
Can anyone shed light on whether or not ERGMs are network models based on the maximum entropy principle? Especially if we say that the available information about the network is in the form of network measures, that is, we know that that graph in question G has $x_1(G), x_2(G),...,x_k(G)$ where $x_i$ is a measure, such...
Given ALL$_{\text{TM}}$ = { < M > | where M is a TM and L(M) = $Σ^*$ } show this is undecidable. I'm also told not to use Rice's theorem. I'm having difficulties with reduction type problems. How would you do a proof for this using a reduction of A$_{\text{TM}}$? Any pointers to resources are much appreciated.
Consider the following recursive algorithm for printing all balanced strings with $n$ left and right parentheses. It is called with prefix = $\epsilon$ (the empty string): A(prefix): If prefix contains $n$ right parens: print prefix and return. If prefix contains more left parens than right parens: call A(prefix + ")"...
How to order the functions $2^n$ vs $n^{\log n}$ based on their complexity? I found this question in a programming website (InterviewBit). But the answer given there, $n^{\log n}, 2^n$, does not seem convincing. The graph of the two functions also indicates that $n^{\log n}$ is more complex than $2^n$. I also tried su...
Is it possible giving a well defined problem, to write an algorithm which takes in as input another algorithm and checks if that algorithm is correct.   If it isn't possible, I'm thinking of storing solutions to a large number of problem sizes, randomly selecting a smaller number of problem instances and seeing if the ...
I am currently working on a seminar on $\mathbf{P \stackrel{?}{=} NP}$ and one of the points I want to adress is the Relativization barrier. However, it is hard to find a concrete definition of a "relativizing" proof. The best defintion I have found is as follows: "A relativizing proof is any proof that is insensitive...
In the fourth edition of Sedgewick's Algorithms, it's claimed that the running time of QuickSort is $\sim 1.39n\log_2 n$. I'm trying to find a "simple" proof and explanation of this. All I know is that the total running time obeys $$C_n = C_{\mathrm{partitioning}} + C_{\mathrm{leftArray}} + C_{\mathrm{rightarray}}$$ an...
I know how to calculate the shortest paths from source s to all other reachable vertices in a DAG (with no negative weight on the edges) By iterating the topological sort of the graph and relax each adjacent vertices. Which take O(V+E) However - I'm required to determine if a certain spanning tree is the shortest-path...
I am practicing for an exam. I am trying to convert a language to a regular expression. The language and my solution is as follows: $L=\{w∈\{a,b\}^+│|w|≥4\ and\ the\ second\ symbols\ from \ the \ front\ and\ the\ back\ are\ equal\}$ Solution: $(a+b)x(a+b)^* x(a+b) \ \ where\ x=(a+b)$ Is this correct? If not, c...
Define $A = \{<G,s,t> :G$ is un directed graph that has a Hamilton path from $s$ to $t\}$ $B = \{<G> :G$ is un directed graph that has a Hamilton path$\}$ I would like to show that $A \le_p B$. My attempt: Given $<G,s,t>$ , the reduction outputs $<G'>$ where $G'$ defines as follows: we take $v_s$ and $v_t$ s.t t...
I was given a array R of n rectangles [each element in the array is a bottom left point(x1,y1) and a top right point (x2,y2)] , parallel to the axis, and an array P of n points [each element is a point (x.y)]. I need to write an algorithm that finds a point in the P array that appears in the largest amount of rectangle...
My lecturer recently released solutions to an assignment. One of the questions was to determine the weakest precondition of: {y < 10} if (x > 0 OR y < 10) -> y:=10 fi {true} According to the provided solution, the weakest precondition of the selection command (x > 0 OR y < 10) -> y:=10 is (x > 0 OR y < 10) I underst...
I have been lurking for a while; this is my first post here. I’m sorry if my question is ill-formed or formatted poorly. This question came out of some ideas in another question from a sister site. Question Because of the nature of a blockchain, a large number of publicly agreeable coin flips may be generated - namel...
I have devised a compiler optimization that works on any structured language that has arrays assignments array[index] = value and counted loops (for i = n; i < N; i++) {doTHIS} (*). Now I want to represent this optimization using some formal semantics. Since I want to publish my results in a Programming Languages venu...
int a = 0; for (int i = 0; i < n*n; ++i) { for (int j = 0; j <= i; ++j) { a += j; } } Could someone help prove to me that this is function is $O(N^4)$. I remember doing this problem a while back, but now I do not see it. I understand that the outer loop is $O(N^2)$ but I am uns...
I have a Computer Science A-Level exam tomorrow and I've been trying to get this question answered by my teacher but she's not been too helpful so asking here instead. In an exam question, I have the following BNF grammar, where _ denotes a space. <fullname> ::= <title>_<name>_<endtitle> | <name> | ...
Given a set of $n$ linear equations in $v$ integer variables, where $v > n$, we can say that this system of equations will always have an integer solution. Over $\mathbb N$, is there any such constraint that guarantees that a solution always exists? Or, if not, can it be tested in polynomial time?
I was reading this question on how to update the distances matrix D of a graph after one edge was decreased, and I don't understand why it works: The answer suggests that if the an edge (a,b) was modified - then all you have to do is iterate through every edge of the graph, and calculate: D[u][a] + w(a,b) + D[b][v]. My...
I know how Translation Lookaside Buffers work, and i also know we use them to improve the performance of data/program access by storing the recent page numbers - frame numbers in a memory cache. The problem is that i can't understand why frequent memory locations are acccessed in a period of time? And what was the star...
I found two definitions Reed-Muller codes being used in literature. More specifically for any $n \in \mathbb{Z}^+$ and $1 \leq d \leq n$ we define the set $RM(d,n)$ in two possible ways, 1. $RM(d,n) = \{ f : \mathbb{F}_2^n \rightarrow \mathbb{F}_2 \vert $f$ \text{ is a polynomial of degree at most } $d$\} $ 2. $RM(d,n)...
In the textbook I'm reading, it states that If the interrupt is of a lower/equal priority to the current process then the current process continues If it is of a higher priority the CPU finishes its current Fetch-Decode-Execute cycle. The contents of the CPU’s registers are copied to a st... In short, the CPU...
I have these two terms: {P(a,x,x),P(a,b,c)} I'm supposed to find if the terms and unifiable using the unification algorithm. I'd do the following substitutions: b/x, resulting in : {P(a,b,b),P(a,b,c)} c/b, resulting in : {P(a,c,c),P(a,c,c)} And thus the two terms are unifiable. However, the solution in my book says tha...
I have the following system of recursive relations on $y_{i,j}$ that are derived from a Markov chain and that I am having difficulty in solving. For $i\ge 1$ and $j \ge 1$, we have $$y_{i,j} \times (p_i+q_j+2)=y_{i-1,j} \times p_i+y_{i,j-1} \times q_j+2y_{i+1,j+1}.$$ Also we have $$\begin{align*} y_{1,0} \times (p_1+q...
My understanding: The Halting Problem is undecidable for a Turing Machine, and yet it is decidable for a linear bounded automaton (a Turing Machine with finite tape). The reason is that the only way an LBA can loop is by entering a configuration it's already been in, which is easy to check. However, unlike an LBA, a Tu...
This is a follow up to the previous Question: Conditions for Linear Diophantine Equations to always have a solution It was established in the above's answer that obtaining or testing for the existence of an solution of an ILP in $\mathbb N$ is an NP Hard Problem. This in turn makes obtaining solution for a (LDP) Linear...
Let $T$ be a complete binary tree. Prove that $T$ is a binary search tree if and only if for every node $x$ of $T$ that is not a leaf, the key of $x$ is larger or equal than the key of the left child of $x$ or it is less than or equal than the key of the right child. To prove that if $T$ is BST then for every node $x...
I know that we can construct a BST by just having its pre-order traversal in $O(n)$ time (this link). But what if the tree is just a binary tree and we have its in-order and pre-order traversals? I could only find a $O(n^2)$ (worst case) algorithm for this problem, like this link. So I'm wondering whether a $o(n^2)$ al...
How to find all permutation of a String in Iterative way ? Code (Recursion) : private void permute(String str, int l, int r) { if (l == r) System.out.println(str); else { for (int i = l; i <= r; i++) { str = swap(str,l,i); permute(str, l+1, r); st...
Apologies in advance for the naivety of this question. I am a 50 year old artist trying to properly understand computers really for the first time. So here goes. I have been trying to understand how data types and variables are handled by a compiler (in a very general sense, I know there is a lot to it). I'm missing so...
If $NP \neq co-NP$ then no $NP-complete$ problem can be in $co-NP$. I found a proof on Wikipedia that I didn't fully get: https://en.wikipedia.org/wiki/Co-NP In the line "from this it follows that the set of complements..". Why does it follow? It seems like the author took a complement from both sides of the equation, ...
Which of the following languages are recursively enumerable? A={⟨M⟩∣ TM M accepts at most 2 distinct inputs} B={⟨M⟩∣ TM M accepts more than 2 distinct inputs} For first language I think that we can enumerate all the TM's which accept at most 2 distinct inputs using dovetailing method and same is the case with B languag...
A question bridging math and computer science, I have on the order of 10000 vectors each of a equal but high dimension, say 6 or 7 dimensions. I want to find a given number of 'unique' vectors in the set, the number generally equal to the dimension of the vectors. In math terms I believe I want to find a subset of vect...
I have an unweighted undirected graph and I have to find if there exists a path between two vertices $u,v$ that visits set of specific nodes $A$. $A$ can contain $1-10$ nodes. No node can be visited more than once. I thought about finding all paths between $u,v$ and then check if those paths contain vertices from $A$....
I have difficulty understanding the halting problem. I know that for all possible Turing machines and strings w, we don't have a Turing machine that can decide whether a TM M halts on input w. Now suppose we have a program p that, for example, solves the Hamiltonian path problem. Can we conclude from the halting proble...
I know that the main operations (Insert, Search, Delete) have a worst-case running time of $\mathcal{O} (h)$. But I wanted to dig into this deeper. Basically I am having some difficulties understanding "Big-Omega" when it comes to the worst-case time complexity. I usually define them as follows: Let $t(x)$ be the numbe...
Let us consider the knapsack problem. Given a set $P$ of $n$ items where each item has weight $w_i$ and value $v_i$ for all $i=1,2,\ldots,n$. We have two bins, one has a weight limit of $W$ and the other has a weight limit of $W'=2W$. Assume that we have an optimal algorithm $\texttt{OPT}$ that solves the knapsack prob...