instruction
stringlengths
35
29.1k
We know that P=NP implies NP=coNP. Does the reverse implication hold? Does NP equal coNP imply that P equals NP? If not why not? I googled but didn't find the answer.
An adversary gives you a set of items whose total size is $x$ (he gets to choose how $x$ is distributed. e.g. there may be $k-1$ items of size $\frac{x}{k}$ and 2 items of size $\frac{x}{2k}$). The item are now randomly distributed into $2x$ bins (you may assume $2x\in \mathbb{N}$). What's the probability (i.e. what ca...
A problem is in NP if a correct answer to it can be verified to be so in polynomial time. A problem is in co-NP if an incorrect answer to it can be verified to be so in polynomial time. P is a subset of the intersection of the sets NP and co-NP. My question is: what is a specific problem that is in the intersection...
what is the reason for the correctness proof of Prim's Algorithm for the undirected case cannot carry over to the directed case? Is it because of after any number of steps, $S$ might not be in a sub tree of an MST since it depends upon the direction of the edge of the directed graph, unlike the undirected one?
It is well known that the maximization problem of Knapsack if NP-hard. How about just finding a feasible solution i.e. objective is set to zero? And also if we set the values to all one (not the weights) in the objective of the Knapsack problem is it still NP-hard i.e. $\max v^Tx$ where $v=(1,1,1..,1)$?
I have a list of webpages and I must download them frequently, each webpage got a different download frequency. Based on this frequency we group the webpages in 5 groups: Items in group 1 are downloaded once per 1 hour items in group 2 once per 2 hours items in group 3 once per 3 hours items in group 4 once per 12 hour...
After we prove that a certain optimization problem is NP-hard, the natural next step is to look for a polynomial algorithm that comes close to the optimal solution - preferrably with a constant approximation factor. After we prove that a certain decision problem is NP-complete, what is the natural next step? Obviously ...
I'm trying to come up with a good algorithm for the following decision problem: Let $G=(V,A)$ be a directed graph and let $s,t \in V$. Are there at-least 2 non-intersecting paths from $s$ to $t$? By non-intersecting I mean that if $P_1$ and $P_2$ are non-intersecting paths from $s$ to $t$ then $\forall e\in P_1\in A, e...
I am working on CFG grammars, LL grammars in particular and I encountered the following theorem in the slides of presentations written by my professor: A CFG grammar cannot be left-factored if all elements in the FIRST-set of one factorizable rule belong to the FIRST-set of the alternative rule. Mathematically speak...
If the clock shows 14:15:36.909302, why not just use the fractions of a second part (09302) as a kind of random number? What is wrong with this form of generating random numbers? I am aware that obtaining truly random numbers is a difficult task, so I am assuming that there is something wrong with this method.
Given two languages $L_1$ and $L_2$ that are in $\mathsf{P}$, can it be proven that there is a polynomial time reduction from $L_1$ to $L_2$ and vice versa? If so, how? I noticed that if $L_1$ is the empty language, and $L_2$ is the "full language" $\{ 0,1 \}^*$, there does not seem to be a reduction from $L_2$ to $L_1...
I'm reading about the Hindley-Milner typing algorithm while writing an implementation, and see that, as long as every variable is bound, you'll always get either atomic types or types where the arguments will determine the final type, such as t1 -> t1 or (t1 -> t2) -> (t1 -> t2) where t1 and t2 are type variables. I ca...
Many problems in computer science come in two flavors: Optimization problem: "Find an object with the largest size". Decision problem: "Given $n$, find an object with a size of at least $n$, or reply that such an object does not exist". Given a solver for the optimization problem, the decision problem can be solved s...
Hi I'm trying to prove the following proposition: Given a network $G,s,t,\omega$ where $\omega$ is the capacity, create a minimal cut cut ${S=\left\{ (s,v)\in E_{G_{r\_max}}\right\} }$ where $G_{r\_max}$ is graph representing the the residual network(meaning we take the group of all vertices that are reachable from ...
Given a digraph $D = (V, A)$ and $m \in \mathbb{N}$, the question is is there a subset $A' \subseteq A$, such that $\lvert A' \rvert \geq m$ and $d_{D'}^+(u) \leq d_{D'}^-(v)$ holds for every arc $(u, v) \in A'$ in the subgraph $D' = (V, A')$, i.e. the out-degree of $u$ is not larger than the in-degree of $v$? Note tha...
I'm trying to apply Dijkstra's algorithm to the Problem 83 on projecteuler.net. The problem reads: In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by moving left, right, up, and down, is indicated in bold red and is equal to 2297. 131 673 234 103 18 201 96 342 ...
Suppose I have a queue where I pull from left and push to the right, and suppose I have the contents in the queue as $a b c @ d e$ (from left to right, left is head, right is tail). Is there a simple algorithm that doesn't require extra structures that makes $e$ at the head? meaning to get us to the queue $eabc@d$? P.S...
How do I see if the following ciphertext eaeairtntrnaeemtve is a transposition cipher, using letter frequency? This article suggest how to detect by using letter frequency detection and cryptanalysis but I am unsure of how to do this. Any suggestions?
a^2n b^(2n+1) is a regular language. I am not able to decompose it in xyz so that I can pump any power of y as per pumping lemma. Please help me out.
In the theory of NP-completeness, researchers refer to the concept of combinatorial explosion. Some researchers use it as justification for intractability or NP-completeness. Others use it to refer to the exponential growth of possible solutions of an intractable problem while others use to refer to the apparent expon...
Given a fully deterministic single player resource management game with a pre-known finite number of turns and reasonably simple rules (eg, Farmville, if it were single player, deterministic, and ended after a certain number of turns), is it usually possible to write a computer program that can optimize the game in...
I have two questions. After compilation of any C program result is assembly language code which should depend on processor. So my question is: how do different computers with different processor types, for example Intel i3,i5,i7 etc., are able to run the same software, for example, media-player, browser, etc.? (I gu...
If we suppose that we are given two numbers $a$ and $b$ to add, what circuit depth do we require to add them? I'm wondering if $a$ and $b$ are $O(n)$, and thus the amount of bits required to store $a$ and $b$ are $O(\log_2(n))$, how much time and/or space we must require to add them. I'm interested in the general cas...
I'm trying to organise a large reunion though facebook. Over the years we've all drifted apart, and so there isn't anyone who is still facebook friends with everyone. You need to be facebook friends to invite someone to the facebook event and I have invited all the people that I can. I also know that each of the uninvi...
i=n; while(i>0) { k=1; for(j=1;j<=n:j+=k) k++; i=i/2; } The while loop has the complexity of $\lg(n)$ the j value of inner loop runs 1,3,6,10,15... increase like 2,3,4,5,... But how to find the overall complexity ?
As I have studied, deciding regularity of context-free languages is undecidable. However, we can test for regularity using the Myhill–Nerode theorem which provides a necessary and sufficient condition. So the problem should be decidable. Where is my mistake?
I have a problem whose solution can be written as a binary string with a given length $N$, where $N$ is a given parameter. Standard GA works well on this problem. From runs of small values $N$, I found that optimal solutions are binary strings that contain only 01 or 011. For example, the optimal solution for $N=16$ is...
The classic example of a context-free grammar is $a^nb^n$. That is, $n$ occurrences of $a$ followed by an equal number of occurrences of $b$. Do such forms occur in the real world? Can you provide an example of a real-world case where there must be $n$ occurrences of something followed an equal number of occurrences of...
In the last 2 paragraphs of the paper about Hopcroft–Karp algorithm to find the maximum cardinality matching in bipartite graph: https://dl.dropboxusercontent.com/u/64823035/04569670.pdf The execution time of a phase is O(m+n), where m is the number of edges in G, and n is the number of vertices. Hence the execution...
I want know if compiler interacts with operating system during compilation process.And if yes then which part of compiler interacts with which part of operating system
The following array occupies 10000 slots in memory: a = [0,1,2,3,4,5,6,7,8,9,10,...,10000] But one could easily represent the same array as: a = {len:10000, get: λ idx -> idx} Which is much more compact. Similarly, there are several arrays that can be represented compactly: a = {a:1000, get: λ idx -> idx * 2} Is a de...
I have a set of elements U = {1, 2, .... , n} and a set S of k sets whose union form the whole universe. Each of these sets is associated with a cost. I have a fixed number of colors, C = {1 , 2, ... , m}. Some of the sets mentioned above interfere with each other. I cannot assign same color to both those sets together...
How do I iterate over all the $k$-element subsets of $\{1,2,\dots, n\}$ by switching one element at a time? 123 134 234 124 145 245 345 135 235 125 This comes from Ch2 of Combinatorial Algorithms by Nienhuis and Wilf. Equivalently I am asking for a Hamiltonian circuit on the Johnson graph of $k$ element subsets of a ...
In the sense of a string distinct from a null reference string, what is the importance of an empty string in CS (and specially in formal languages)? Why do you need a separate concept, that of 'empty string', which even has it's own Greek letter (ε)? Couldn't just an EOL character replace it?
When we look at the Actor Model and Communicating Sequential Processes we see that they are both trying to do concurrency based on message passing, yet they are distinct. (We see implementations of the CSP Model in go-lang's goroutines (and Clojure's core.async) and the Actor Model in Scala's Akka toolkit) I'm trying ...
I'm trying to understand this lecture, section 2.7. Why would the normal order sequencing print out "hello" "world" and not "world" "hello"? I may be misinterpreting the order in which the arguments are applied. It looks like the expression $$ ((Seq (display "hello"))\; (display "world")) $$ would evaluate to $$ \lamb...
I need a data structure which can include millions of elements, minimum and maximum must be accesable in constant time and inserting and erasing element time complexity must be better than linear.
I just read the Wiki article for Simon's Problem but I don't fully understand it because I don't follow the symbolic notation used to describe functions (I am not a computer scientist). Can someone just briefly explain it in simple language, like is it just XOR'ing two binary strings and trying to isolate each string?...
I have read about the hash function MD5. I found an online calculator which counts the value of MD5 for different data. But the MD5 function returns as result strings like 735b90b4568125ed6c3f678819b6e058, so I can't apply any numerical operation to this value, e.g. mod. How can I transform values like these into numbe...
Foldl and folr are 2 very important functions for FP and Haskell, but I have never heard much about the unsided fold: fold f [a,b,c,d] = (f (f a b) (f c d)) That is, a fold that operates on binary associative functions (so the order of application doesn't matter). If I recall correctly, this is very common in database...
I would like to be able to represent circles in x-y coordinates. Each circle contains an x and y coordinates and radius in double data type. My goal is to compare circles with each other whether they are partially or completely overlapping. I am looking for efficient ideas. Honestly the only idea that comes to my mind ...
I believe this question should be extremely easy but I am having a (embarrassing) hard time figuring out why its true if there exist OWF (computable in polynomial time) then there exits a OWF that is computed in $O(n^2)$. This is what I have/tried. Let $ \ f(x)$ be a OWF that can be computed in $k^c$. Then we can const...
Every nontrivial property of the recursively enumerable languages is undecidable. What exactly is nontrivial property?
In this paper (page 3 Theorem 1) the authors want to prove that their problem is NP-complete. Their method is as follows. Let their problem be known as $P$. They show that their problem can be written as a $0\text{-}1$ integer program. Then they claim that $0\text{-}1$ integer programs are NP-complete and therefore the...
Short version: I want to know where the $-2$ comes from in the formula on p. 221 of CLRS 3rd edition. Long version: CLRS (3rd ed.) give an algorithm for $O(n)$ worst case arbitrary order statistic of $n$ distinct numbers. The algorithm is roughly: Input: an array of $n$ elements and $i$, the number of the order stati...
Assuming P!=NP, there is a result that there are decision problems intermediate between P and NP-complete. That is, the class NP cannot be a union of two disjoint subsets: P and NP-complete. I could never quite understand the proof of the above result. The proof I saw in a textbook was starting with the assumption that...
I would like to refute my hypothesis that all safety-critical software (that is, software where errors can have catastrophical consequences, either in terms of human lives or high material costs) is a real-time software (where tasks have timing constraints) by finding interesting counterexamples: systems without timing...
I was asked this question in examination. A square matrix $M$ of size $10 \times 10$ is stored in memory with each element requiring 4 bytes of storage. If the base address at $M[0][0]$ is $1840$, determine the address at $M[4][8]$ when the matrix $M$ is stored row majorwise. I seriously don't understand this question ...
Given a turing machine $T$ that receives an encoding of another turing machine and a word $<M><w>$, can $T$ 'run' through the encoding and 'mark' specific transitions/states? For example, if I want to show that the language $L = \{<M><w>\}$ such that when we run $w$ in $M$ we will visit at least two unique states diffe...
I am curious how to do a line by line analysis of this piece of code using the "Big O" notation. i = 0; j = 0; while ( ( i < n ) && ( j < m ) ) { //do something i++; j++; } How I should represent number of iterations for the loop? Is good if I will do some assumptions or I should write min(n, m)? Sm...
Forgive this seemingly "troll-ish" question, but I must lack the ability to understand how one byte (two nibbles, eight bits, however you wish to describe it) can hold 256 different states, possibilities, values or such. First of all, one bit would look like this: Any way of being able to input two states (in the poor...
I have the following problem: In a 2D space with polygonal obstacles, find the shortest path between two given point. Without additional constraints, we can reduce it to a graph problem by constructing a visibility graph and then solve it by searching. If the following constraints are added, how can we solve it? Let'...
Sipser theorem 4.4* $E_{DFA} = \{ \langle A \rangle \mid \text{A is a DFA and } L(A)=\emptyset\}$ is decidable. I could not quite understand the solution, I'll quote it: On input $\langle A \rangle$ where $A$ is a DFA: Mark the start state of A Repeat until no new states get marked: Mark any state that has a tran...
I know that Idris has dependent types but isn't turing complete. What can it not do by giving up Turing completeness, and is this related to having dependent types? I guess this is quite a specific question, but I don't know a huge amount about dependent types and related type systems.
Pancake graph have least diameter & degree (log n/ log log n) pancake Graph with order-2 will be one single line with two nodes, labeled with permutation of node {12, 21}. pancake Graph with order-3 will be one single line with one hexagonal, labeled with permutation of node {123, 132, 213, 231, 312, 321}. Similarly fo...
Here is how deletion in B-trees is described: If the key k is in node x and x is a leaf, delete the key k from x. If the key k is in node x and x is an internal node, do the following. a) If the child y that precedes k in node x has at least t keys, then find the predecessor k0 of k in the sub-tree rooted at y. Recur...
Consider the 3-SAT problem where the formula is in conjunctive normal form and we restrict the Boolean formulas such that the number of clauses in the formula is equal to the number of variables. Is this problem still NP-hard? For example, this formula has $3$ variables and has $3$ clauses $(\lnot x_1 \vee \lnot x_2 \v...
What's the name of a complexity class of optimization problems that have "bounded error probabilistic approximation algorithms"? Bounded error probabilistic version of APX (as BPP is bounded error probabilistic version of P), or approximation version of BPP (as APX is approximation version of P).
I know that it can be proven PROLOG is Turing-complete by constructing a program that simulates a Turing machine like this: turing(Tape0, Tape) :- perform(q0, [], Ls, Tape0, Rs), reverse(Ls, Ls1), append(Ls1, Rs, Tape). perform(qf, Ls, Ls, Rs, Rs) :- !. perform(Q0, Ls0, Ls, Rs0, Rs) :- symbol(Rs0, Sym,...
I've just now studied about covariance and contravariance in static languages (more specifically C#). This concept is rather clear to me, however I'm in doubt on how this applies to dynamic languages like Python. Since Python is duck typed (or structural typed) it seems to me that there is not even a notion of variance...
Throughout the subject of reductions, I was wondering: If we take $L_1 = \Sigma^* $ and $L_2 = \emptyset$, is $L_1 \leq L_2$? is $L_2 \leq L_1$? What I mean is, Is there some sort of reduction between any of the two with the other one? I tried this: Let us try $L_2 \leq L_1$, we need to show that such a reduction e...
Posted this question on cstheory.SE where they said to go here: I read the demonstration of the Halting problem, it is done by reductio ad absurdum where the push to get to the absurd is to use the halting function "H(A,b)" (where A=another function, b=the A parameter) as its own parameter. This proofs that can'...
Assume having a graph $G_{variables}=(V,U)$ where $V=\{v_1,v_2,…,v_n\}$ is a set of variables; each variable $v_i\in V$ is associated with a set of possible values (it's domain) $dom(v_i)$. Let $P$ be a search problem (i.e reachability problem) over graph $G=(O,E)$ where $O$ is the cartesian product of the variables d...
This Github repo hosts a very cool project where the creator is able to, give an integer sequence, predict the most likely next values by searching the smallest/simplest programs that output that integer sequence. I was trying to approach the same idea using lambda-calculus instead of a stack-based language, but I was ...
The question is really confusing me. I know every context sensitive grammar is monotonic but not vice versa. e.g. AB--->BA is monotonic but not context sensitive. Can someone explain to me in simple terms why this is?
I have a graph G with 13814 nodes and 25190 edges. I am interested in finding a mathematical proposition that proves that my graph is disconnected. I know it is, because the visualization shows lonely clusters where they have no way of reaching the other nodes in the graph. This simply is a signature of disconnected gr...
I'm aware some ints have higher or lower Kolmogorov Complexities. For example, the number 5.41126806512 has a very low complexity as it can be expressed by 17/pi. I'm also aware that, though the KC varies depending on the expression language, it is always the same up to a given constant. So, I ask: is there a way to ca...
For example, how is it proven that any NP problem can reduce to subset sum, circuit satisfiability, etc.? Or could you link to a proof?
I was curious to know what limits the max RAM capacity for an OS while reading about microprocessors being 32-bit and 64-bit. I know that limit for 32-bit OS is 4GB and for 64-bit OS is 16 Exabytes, but my question is how do we get there? I found this calculation: $\qquad 2^{32} = 4\,294\,967\,296$ and $\qquad \frac{4\...
I have question on understanding the following neighborhood relation within a local-search approximation scheme. Let $M$ be a legal matching on any bipartite graph. Let $U_k$ be the neighborhood defined as follows: $$U_k := \{M' : |(M' \backslash M) \cup (M \backslash M')| \leq k\}$$ Can somebody give me an example o...
While solving some question, that involved the empty set $\emptyset$, I was really wondering, is $\emptyset$ reducible to any other language, i.e., $\emptyset \leq A$ such that $A$ is a language over a given alphabet $\Sigma^*$? I mean, one can never take $x \in \emptyset$, right? or am I missing anything? Maybe $\empt...
First and foremost, i know what a shell, kernel is. Now the dilemma. Today i had my systems viva in college. The examiner asked me is there a shell between the hardware and the kernel. Obviously, i said no, and the gave the usual explanation that the shell is an interpreter, it takes the user input, interprets the comm...
Way back in the day I took a course on discrete structures and learned about how the mathematical notion of an algebra is akin to the class data type. But I didn't know enough at the time to ask whether algebras are used to model classes or whether classes are actually derived from algebras (historically, technically....
This is a machine learning question. Given this series of categorical data, what program will derive the underlying algorithm and predict what comes next in the series? Here is the series: B, BA, BB, BAA, BAB, BBA, BBB, BAAA, BAAB, BABA, ... Anyone with knowledge of computer science may quickly realize that this series...
As far as I understand, a semi-decidable (recursively enumerable) problem could be: decidable (recursive) or undecidable (nonrecursively enumerable) This post made me wonder if this is not conventionally followed. This is my answer to it and as far as I understand it is correct: A semidecidable problem (or equiv...
Is there any algorithm which is very difficult to parallelize or the research is still active? I wanted to know about any algorithm or any research field in parallel computing. Anything, I searched for, has a 'parallel' implementation done. Just want to do some study on any unexplored parallel computing field.
I have a simple directed graph $G(V,E)$ that has a source $s$ and sink $t$. Each edge $e$ of $G$ has positive integer capacity $c(e)$ and positive integer cost $a(e)$. I am trying to find the minimum cost maximum flow from $s$ to $t$ using the successive shortest path algorithm. It goes something like this: Initialize ...
I am reading through Skiena's "The Algorithm Design Manual". He analyses the number of copy operations performed in a dynamic array. "Suppose we start with an array of size 1, and double its size from $m$ to $2m$ each time we run out of space. This doubling process involves allocating a new contiguous array of size $2...
We have an array of Integers, $A[]$ and we have to find the minimum number that is not the sum of a subset of array using the elements from $L$ to $R$ indices. I was thinking of using coin change DP approach, and outputing the min number with value infinity. But the problem is that the sum of ranges can be as large as ...
In directed graph, to find strongly connected components why do we have to transpose adjacency matrix (reverses the direction of all edges) if we could use reversed list of nodes by they finishing time and then traverse original graph. In other words, we would find finish times of all vertices and start traversing from...
i am new to compiler design, currently studying Ullmans book on this.He says: Problem with predictive parsing (both recursive and non recursive) is that Left recursive productions can go infinite loop.Thus, to make grammar suitable for predictive parsing we need to eliminate the left recursion by immediately or indirec...
I am having a plane in N dimension. Th distance between 2 points (a1,a2,...,aN) and (b1,b2,...,bN) is max{|a1-b1|, |a2-b2|, ..., |aN-bN|}. I need to to know how many K-sets exist(here K-set refers to set of points whose distance between 2 points of set is K).But as there can be infinite number of these K-sets. Thus, we...
Two strings $S$ and $T$ are said to be conjugate if there are two non-empty strings $A$ and $B$ such that $S = A+B$ and $T = B+A$ ($+$ is concatenation). How can I find if two strings are conjugate or not? Example: if S="tokyo" and T="kyoto", then the pair $(S,T)$ is conjugate, because we can find A="to" and B="kyo".
Given this set of question-answer pairs, what program will derive the underlying algorithm and provide the correct answer for any question of the same format. Question-Answer Pairs (training set): B:BA BA:BB BB:BAA BAA:BAB BAB:BBA BBA:BBB BBB:BAAA BAAA:BAAB BAAB:BABA Those familiar with binary may notice that the trai...
(I'm aware that software questions are better suited for stackoverflow, but since DFAs are not something that software developers usually care about, I hope it's alright if I ask here.) I'm currently working on a project to do with regular overapproximations for context free languages. For this purpose, I need to imple...
A comment over on tex.SE made me wonder. The statement is essentially: If I can write a compiler for language X in language X, then X is Turing-complete. In computability and formal languages terms, this is: If $M$ decides $L \subseteq L_{\mathrm{TM}}$ and $\langle M \rangle \in L$, then $F_L = \mathrm{RE}$. Here $...
I'm a little confused about the difference of the memory access and the write-back stage in a RISC pipeline. We learned in class these following assumptions: arithmetic & logic: IF, OF, EX, WB load: IF, OF, EX, MA, WB store: IF, OF, EX, MA branch: IF, OF, EX IF=Instruction Fetch, OF=Operand Fetch, EX=Execution, MA=Mem...
When studying operation systems, is context switch time included in CPU utilization time? For example, if 5 percent of CPU time is wasted to context switching, is CPU utilization 95 percent?
I did not understand why unconditional transfer of control instruction is used in cpu.So if we already know we have to jump to an instruction and skip some instruction irrespective of any condition then why do we not avoid writing those instruction as they will not be executed and replace them with instruction that wi...
Let's have an array where first half are of value 50 and the second half 100. What would be the asymptotic performance when sorting using Quicksort. I think it it should be $O(n^2)$ as for array of same elements the complexity is $O(n^2)$ and this particular problem could be rewritten as sorting the first half + sortin...
The term "Turing completeness" has been discussed in several of the Computer Science classes that I've taken. However, I've never gotten an intuitive feel for what Turing completeness actually requires. I found this question, but the answers are a bit more mathematical than what I am looking for. Take a common programm...
The first chapter of the book "Graphs and their uses" by Oystein Ore says that interval graphs can be used to resolve authorship disputes, but I couldn't find any details. How does this work? What is the algorithm? From the text (Chapter 1.7): Interval graphs have also been used to investigate the likely authorship ...
As seen in this recent XKCD strip and this recent blog post from Peter Norvig (and a Slashdot story featuring the latter), "regex golf" (which might better be called the regular expression separation problem) is the puzzle of defining the shortest possible regular expression that accepts every word in set A and no word...
Given two sets $A,B$ of strings over alphabet $\Sigma$, can we compute the smallest deterministic finite-state automaton (DFA) $M$ such that $A \subseteq L(M)$ and $L(M) \subseteq \Sigma^*\setminus B$? In other words, $A$ represents a set of positive examples. Every string in $A$ needs to be accepted by the DFA. $B$ ...
In a recent test, I was asked to recognize if the below language is context free: $\qquad\displaystyle L = \{0^{n+m}1^{n+m}0^m \mid n,m \geq 0\}$ I think it is context free, and can be accepted by below context free grammar, where $S$ is the start symbol and $Y$ is a non-terminal: $\qquad S \to S0 \mid Y$ $\qquad Y \...
So we have two problems: Problem A: Given a list of positive integers, decide whether the list contains a subset adding to a given number t. Problem B: Given a list of integers, decide whether the list contains a subset adding to 0. I have to prove that A can be reduced to B in polynomial time. And a really simple redu...
The following definitions are from Li, M., & Vitányi, P. (1997). An introduction to Kolmogorov complexity and its applications (2nd ed.), pg. 38. A language $A$ is called polynomial time Turing-reducible to a language $B$, denoted as $A\leq_T^P B$, if given $B$ as an oracle, there is a deterministic Turing machine tha...
Im learning the delete operation on Left-leaning Red Black Tree invented by Prof. Sedgewick. In delete operation, a node could be only deleted from a 3-node or a 4-node but 2-node. In order to ensure we dont end up at 2-node, we push the red link down when both the left and left of left of this node are black (if the c...
I have developed an algorithm which recommends geographical locations to users based on popular trends and their own interests. The dataset is created by my organization. So the user selects a few categories and based on his interest and rating by other people he is presented with recommended places for him. How do yo...
According to the dragon book, one of the first steps the source code of a program goes through during compilation is the Preprocessor. Assuming a language like C++ where there is no underlying virtual machine to abstract away the underlying platform, is there a way to deal with cross platform compilation without requir...