instruction
stringlengths
35
29.1k
I'm sitting an exam on Computer Architecture in a few days and i'm stuck on a particular type of question. I'm asked to: Provide a detailed schematic for a functional unti that implements the following micro-operations Any help would be great even just a nudge in the right direction.
I've recently started casually reading into combinatorial logic, and I noticed that a higher-order function that I regularly use is a combinator. This combinator is actually pretty useful (you can use it to define addition on polynomial equations, for example), but I never gave it a decent name. Does anyone recognise t...
Is there any difference between the two? As per Ullman's book, compilers convert one language to another (usually low level) language, and so does an assembler. How are the two different?
I am reading this article about compiler. I am facing some problem in understanding the content of the token file. Specifically, what is the meaning of the following lines: [ \t\n] ; [a-zA-Z_][a-zA-Z0-9_]* SAVE_TOKEN; return TIDENTIFIER; [0-9]+\.[0-9]* SAVE_TOKEN; return TDOUBLE; ...
As part of my continual improvement plans, I'm reviewing algorithm analysis and I've hit a roadblock. I cannot figure out how to determine the Big O complexity of $\log(n+7)^{\log(n)}$. I've spent the last few days rolling this over in my head and I still haven't made any progress in solving it. Could someone tell me w...
I do not understand the proof for this. I know that every word in $(A^*)^*$ is made up of words from $A^*$, and that this is made up from words in $A$. But how does this help with showing that $(A^*)^*$ is a subset of $A^*$.
Ramsey's theorem states that every graph with $n$ nodes contains either a clique or an independent set with at least $\frac{1}{2}\log_2 n$ nodes. I tried to look it up at a few places (including Sipser) but I could not make out a lot of sense from the proofs. I would appreciate it if someone can give me a proof (or cle...
Definitions: Alphabet $Σ$: finite, non-empty set Language: subset of $Σ^*$ Grammar: Unrestricted grammar (Chomsky Type 0) Language of a grammar: all words that can be produced by applying $P$ multiple times, starting from $S$ Grammars are finite, therefore there are only countable infinite of them. But there are unco...
If $u,v \in \mathbb{R}^d$ are two $d$-dimensional vectors, say that $u\le v$ if $u_i \le v_i$ for all $i=1,\dots,d$. In other words, comparisons on vectors will be pointwise. Let $S,T$ be two subsets of $\mathbb{N}^d$ of size $m$. Is there an efficient way to test whether there exists $s\in S, t \in T$ such that $s\l...
This is a Google interview question. I got it from a website. You have two arrays source and target, containing two permutations of the numbers [0..n-1]. You would like to rearrange source so that it equals to target. The only allowed operations is “swap a number with 0”. Find the minimum number of swaps? e.g. {1,0,2,...
Currently I am playing around with time series forecasts (specifically for Forex). I have seen some scientific papers about echo state networks which are applied to Forex forecast. Are there other good machine learning algorithms for this purpose? It would also be interesting to extract "profitable" patterns from the t...
Given this question: $L$ is an infinite language of encoded Turing machines who always halt. $L$ might be decidable $L$ might be in RE but not in R both 1. and 2. are correct I know the solution to this question is 3., but I seem to lack the understanding on how am I suppose to get to that solution. Could you expla...
I get that R is a set of languages that are decidable by a Turing Machines And that RE is a set of languages that a each language can be recognized by a TM, that is the machine will halt when given a word from that language and loop otherwise. But I can't wrap my head around co-RE. Is there a good way to describe it? ...
Suppose we have two entities $A$ and $B$ and some relationship between them. If there is an $M:N$ relationship between them (i.e. an $M$ on the line connecting $A$ to the relationship and an $N$ connecting the relationship to $B$), how do we read this? Would it be the following: A single instance of $A$ is related to $...
Most specifically, his use of small epsilon introduced at the end of section 1 of "Types, Abstraction and Parametric Polymorphism" is throwing me, but in general I would like references to symbols in the Type and Logical Relations literature.
I found something in my notes I don't really understand, maybe you could help. Let $A$ = Independent Set and $B$ = Clique. Then, we clearly have $A \in \mathsf{NPC}$ and $B \in \mathsf{NP}$. Now, the claim is that $A \setminus B \notin \mathsf{NP}$ with the following explanation. If it was in $\mathsf{NP}$ then $\mat...
For a language to be regular it needs to be recognized by DFA/NFA. Let $L = \{ xy^rzyx^r \mid |x| , |y|, |z| \ge 1 \}$ over the alphabet $\{0,1\}$. $x^r$ means the reverse of $x$. A DFA has no memory, so how can it handle the reverse check?
If you could include your thought process in determining why it's regular it would help me a lot. $L_1 = (0^*(10)^*11)$ $L_2 = \{ \langle M \rangle \mid M \text{ is a Turing machine that halts on all inputs from }L_1 \}$ $L_3 = \{ x \in \{0,1\}^* \mid \exists y \in L_2. xy \in L_1 \}$ Why is $L_3$ regular? It's a set...
Where can I find introductory books, articles, notes or slides on Game Semantics? I have searched a lot on the internet but I'm not satisfied by the material I found. It either is too informal, or it assumes too much knowledge of/attitude to other kind of semantics, and it's hard to follow for a beginner. Ideally the m...
Does anyone know where I could get an access to a project that contains all the artefacts (documents) that were created during the development? So I would like to get all the word, pdf, power designer, etc. files as well as all the source code. If possible, I would prefer that all this files are stored in some of the s...
Suppose we are using a dual core processor and we run 2 applications (1 with 80% resource requirements and the other with 20% resource requirements).Now the first program is parallelizable for 40% and the second one not parallelizable.My question is what would be the speed up achieved in this case.By speed-up i mean th...
I need help with deciding if $L$ is context-free. $$L = \{a^pb^{q+r}c^sd^{q+t}e^{p+r} \mid p, q, r, s \ge 0\ , s > t\}$$ Can be rewritten into: $$L = \{a^pb^qb^rc^sd^qd^te^pe^r \mid p, q, r, s \ge 0\ , s > t\}$$ When we see the first occurrence of $c$, we push the $c$:s onto the stack. But we can't make difference betw...
By a vanilla Turing machine, I mean a Turing machine with one tape (no special input or output tapes). The problem is as follows: the tape is initially empty, other than a string of $n$ $1$s and $0$s terminated by an end-of-string character. The tape head starts at the beginning of the string. The goal is for the tape ...
A shuffling algorithm is supposed to generate a random permutation of a given finite set. So, for a set of size $n$, a shuffling algorithm should return any of the $n!$ permutations of the set uniformly at random. Also, conceptually, a randomized algorithm can be viewed as a deterministic algorithm of the input and so...
Suppose I have two polynomials $f(x)$ and $g(x)$ and I somehow represent their coefficients. I have a couple of ways to hold a polynomial depending on how many significant coefficients the polynomial has. I want to determine the amount of significant coefficients in the results of $f(x) + g(x)$ ,$f(x) \cdot g(x)$ , $f(...
Given $n$ nodes in the plane, connect the nodes by a spanning tree. For each node $v$ we construct a disk centered at $v$ with radius equal to the distance to $v$’s furthest neighbor in the spanning tree. The interference of a node $v$ is then defined as the number of such disks that include the node $v$. The problem I'...
Given two integers $n$ and $m$, how many numbers exist such that all integers have all digits from $0$ to $n-1$, the difference between two adjacent digits is exactly $1$, and the number of digits in the integer is at most $m$? The integer cannot start with a $0$. All digits from $0$ to $n-1$ must be present. Example: ...
In other words, given a graph with nodes $N=\{n_0,n_1,...,n_j\}$, and a set of nodes in the graph $M=\{n_a,n_b,...,n_k\}$ with $M\subseteq N$, I'm looking for what to call the node or nodes $n'$ which minimize: $\sum_{m\in M}d_{min}(n',m)$ where $d_{min}(x,y)$ is the shortest distance from node $x$ to node $y$, as trad...
I'm a bit confused how worst case complexity is estimated for the DPLL algorithm. Is it in terms of number of clauses, number of variables, or something else?
I would like to sample a uniformly random point in a polygon... If sample a large number they'd be equally likely to fall into two regions if they have the same area. This would be quite simple if it were a square since I would take two random numbers in [0,1] as my coordinates. The shape I have is a regular polygon, b...
This is a homework question, so I am only looking for hints. I got a question in an assignment which states : Design a DFA that accepts strings having 1 as the 4th character from the end, on the alphabet {0,1} I have been at this for a few hours now, and I think that designing such a DFA is not possible. However, I a...
I want to construct a complete graph where each node is connected to every other node. The link between the nodes give a distance function (does not follow triangle inequality) between them. What I require is to merge the closest nodes, (bounded by a threshold) into a single node and recompute the graph each time, recu...
How is Quantum Algorithms and Complexity Theory essentially different from Classical Counterparts? Also how are non-deterministic Turing Machines(NTM) different from Quantum Turing Machines(QTM)? More precisely, Is there an QTM that can solve the SAT 'fairly fast'? I wanted to know how are QTMs different from NTMs, ...
I am not experienced in machine learning but I have been looking at the Python toolklit scikit-learn. I have thousands of mammograms and I have written an algorithm to find the outline of the images. I have some cases where the outline of the mammogram is not correct. I would like to be able to take these thousands of ...
When it comes to the design of algorithms, one often employs the following techniques: Dynamic Programming The Greedy-Strategy Divide-and-Conquer While for the first two methods, there are well-known theoretical foundations, namely the Bellman Optimality Principle and matroid (resp. greedoid) theory, I could not find...
In the edge-disjoint paths problem (EDP), we are given a (possibly directed) graph $G=(V,E)$, and a set of distinct source-sink pairs $\{ (s_i,t_i) \mid 1 \leq i \leq k \}$, and we want to maximize the number of pairs that can be simultaneously connected in an edge-disjoint manner. When we add the constraint that the p...
I'm studying for the computer science GRE, and as an exercise I need to provide a recursive algorithm to compute Fibonacci numbers and show its correctness by mathematical induction. Here is my recursive version of an algorithm to compute Fibonacci numbers: Fibonacci(n): if n = 0 then // base case retur...
I am preparing for my exam in formal languages and I need some help with one question from one old exam. I know that the number of equivalence classes of some regular language L, is the number of states of the minimal DFA for that language. But how do I give a DFA for one of the equivalence classes ? Thanks in advan...
Is there an "official" name for this slight variant of the well known Tag System model of computation, and/or has it been used somewhere? a finite alphabet of symbols $\Sigma$ a halt symbol $H$ an ordered set of production rules: $$P_i: \alpha_i \rightarrow \beta_i, \quad \alpha_i \in \Sigma^+, \beta_i \in \Sigma^* \...
The problem can be formulated as: $\min f(\textbf{x})=\sum_{i=1}^{n} \prod_{j \in N(i)}(1-F(x_i))$ s.t. $\sum_{i=1}^n x_i \leq B$ $N(i)$ is a set of i. And $F_{x_i}$ can be any function with range between [0,1]. if $F(x_i)$ is a convex function and $\prod_{j \in N(i)}(1-x_i)$ is concave, the objective function is a co...
I am looking for algorithms to classify words in a paragraph of text. I am particularly interested in a classification to determine if a certain word is noun, verb, etc., but also looking for any kind of word-classification algorithms. I am given a smaller input (e.g. 200 words) so there is no many options for machine ...
Is there any difference between free variable and global variable? Or they are just synonyms? In which situations I should use one or another?
I was wondering how many binary trees we have with height of $h$ with $n$ nodes(another question is how many binary trees we have with height $ \lfloor{lg (n)}\rfloor$). Edit: I forgot to add the number of nodes.
As far as I know idempotent operation is a operation that can be applied many times with the same effect. Also I learnt recently that updating a tuple in a database is also idempotent. I thought that an idempotent operation was like a read-only stateless call (thanks to HTTP world with its famous GET request example). ...
I have a system of mono-disperse spheres inside a cubic box. I am studying the volume distribution inside the sample, after tessellating it with either Voronoi and Delaunay tessellations. I am interested on some properties which should not depend on the tessellation. Currently, I am comparing with the values obtained f...
In trying to gain a better understanding of finite state machines, I stumbled across this idea and have been confused as to how to approach this case in terms of a DFA. The set of binary strings of length at least 3 where every substring of length 3 contains at least two 0s. So in other words, something like 100100...
I understand that $\Pi$ types are generalizations of functions and can be interpreted similar to $\forall$ in logic. I also know that $\Sigma$ types are generalizations of tuples and can be interpreted similar to $\exists$ in logic. But whereas I find it easy to imagine $\Pi$ type examples by thinking in Haskell, I am ...
I am new to Algorithms and am currently confused about the running time of the ThreeSum program. If we look at ThreeSum's count function: public static int count(int[] a) { int N = a.length; int count = 0; for (int i = 0; i < N; i++) <-- A for (int j = i + 1; j < N; j++) <-- B for (int k = j + 1; k...
The state space is decribed with 3 boolean variables $p,q$ and $r$ (so we have 8 states total). We have an action, let's say $a$. Action $a$ can be executed when $p=\text{False}$ and $q=\text{True}$ and the result is $p=\text{True}$, $q=\text{False}$ and $r=\text{False}$ How can we describe this action with STRIPS? My ...
I was trying to solve this problem on SPOJ: Given a sequence of $n$ numbers $a_1, a_2, \ldots, a_n$ and a number of $d$-queries. A $d$-query is a pair $(i, j)$, $(1 \leq i \leq j \leq n)$. For each $d$-query $(i, j)$, you have to return the number of distinct elements in the subsequence $a_i, a_{i+1}, \ldots, a_j$. S...
I formulate the question in terms of universal distributions. Fix a version of Solomonoff's universal distribution $\mathbf M$ and consider the following procedure for generating an infinite binary sequence $\omega$. Start with some $\omega_0$. Each subsequent element is given by $\omega_n=\arg \max_a\mathbf M(a|\omeg...
I'm interested in learning about how facial recognition works. I'm especially interested in the algorithms or approach that is used. What are the leading methods for facial recognition? Is there a good overview or source to learn about a few of the most widely used algorithms for facial recognition? What would be t...
Some humans can lip-read fairly well: by watching someone who is speaking, they can tell what the speaker is saying (even without hearing the speech). Has there been any work on building computer software to lip-read? In other words, given a video of someone speaking, is it possible to build software to infer what the...
For proofs by well-ordering principle the general template is to consider the negation of some predicate $P(n)$. Then assume the set of all elements that fulfill $\lnot P(n)$, i.e. $\qquad N = \{ n \mid \lnot P(n) \}$ has a smallest element according to WOP, say $m = \min N$, and if we manage to prove that there is ano...
What exactly is the job of a syntax analyzer? Suppose I have a mathematical expression. Is it true that the order of execution of the operations is found with the help of syntax analyzer? Any example on exact jobs of Syntax Analyzer?
I know that in an infinite language there are infinite number of strings. I want to know what type of the languages are C, C++ and JAVA? I can have infinite number of variables in all these languages, so I think all these languages are infinite. Please correct me if I am wrong.
Consider how one would represent the following image in vector graphics: Pretty simple, right? The entire shape can be represented by a single path element. But suppose additionally that you want to color the heart at the top red. The path element is an open shape, so trying to fill it results in an appropriately re...
I know finite-state machines can be used to solve yes/no kind of problems, such as finding whether a word is in language or not. Can somebody tell me exactly what FSM cannot do and why?
When a DFA is converted into an equivalent NFA, the NFA gives more convenience to many yes/no kind of problems (such as a word belong to a language or not?). I want to know in general at what price this convenience is achieved?
Given a regular language $L$ over a unary alphabet $\Sigma = \{ a \}$. How to decide whether there are two words $w,w' \in L$ such that the length of $w$ is relatively prime to the length of $w'$ ?
Multi-label classification is a machine-learning problem where each sample can have zero or more labels from a closed set of possible labels. This task has applications in several fields. For example, in dialog systems, each sentence that the human says may have several intents, and the classifier should detect all of ...
I am looking for advice in the following optimization problem. I have a website (system) that receives database updates. The updated information is later returned in queries made to the same system. In order to speed up the system the obvious solution is to cache data in each location. I have begun to decompose the tim...
There are n men and n women. I am unable to understand how stable matching done by simply searching through all the matchings takes n! steps i.e., I cannot figure out why there are n! matchings possible.
I have encountered a surprisingly challenging problem arranging a matrix-like (List of Lists) of values subject to the following constraints (or deciding it is not possible): A matrix of m randomly generated rows with up to n distinct values (no repeats within the row) arrange the matrix such that the following holds (...
I would like to check time complexity of two procedures for which I am not totally convinced that I got it right. Now the first procedure is this: public static int c(int n) { int i, j, s = 0; if (n > 1) { for(i = 0; i < n; i*=2) { for(j = n; j > 0; j/=2) { s++; }...
Let $B$ be a recursive enumerable set and $B = W_n$, where $W_n = \{x \in \mathbb N \mid \Phi(x,n)\downarrow\}$ and $\Phi^{(n)}(x_1, \ldots, x_n, y)$ is the value of the function at the terminal snaphot. There is a definition that leaves me really confused: $$n \in W_n \Leftrightarrow \Phi(n,n)\downarrow \Leftrightarro...
I was going through a past paper question but I don't have any answers to know if I'm working out the problems correctly or not. I need to find the time complexity for: i) repeat n:=n div 2; until n=1; ii) for i:=1 to n do begin for j:=1 to n do begin for k:=1 to ...
Let $B = \{z \mid (\exists x)\; P(x,z)\}$ and $P$ be a computable predicate. Show $B$ is a recursive enumerable set. My attempt As $P$ is a computable predicate then there is a program that computes it, therefore $B= \{z \mid (\exists x)(\exists t)\;\text{STP}^{(1)}(x,z,t)\} \Rightarrow B= \{z \mid \Phi(x)\downarrow\} ...
I'm trying to calculate $\text{pred}\, c_0$, where $\text{pred}$ is the previous church encoded number and $c_0$ is the number $0$ ($\lambda s. \lambda z. z$). The formula for $\text{pred}$ is $\lambda n. \lambda s. \lambda z. n (\lambda g. \lambda h. h (g s))(\lambda u.z)(\lambda v.v)$ My $\beta$ reduction looks like ...
Let's say we have an inequality, $p \le {a \choose b}$ where $p$ is a fixed constant and $a, b$ are variables. The problem is that, we are trying to find the minimum $a$ with respect to the inequality $p \le {a \choose b}$. Is there a closed form solution (can be approximate as well/doesn't have to be exact) for that c...
At my university, a degree is "Computer Science and Engineering" but at US universities I understand that the degrees are different so what is the fundamental difference? Is computer engineering lower level like hardware and operating systems while computer science is more like language technologies?
I am a newbie here I recently read tutorials on java about collection framework. The time complexity of various objects in reading/writing data What does it mean? what is O notations? can anyone make me understand these notations and about time complexity measures using these notations
I am trying to figure out the result of the concatenation among different language types (regular, context free, ...). I think the result strongly depends on the nature of the languages which will be concatenated, but I have some doubts on determining the category the result belongs to. Maybe troughout an example it wi...
Does anybody know whether the multiset of the determinants (possibly together with the order of the submatrix they refer to) of all the principal minors of the (symmetric) adjacency matrix of a graph is a complete invariant for graph isomorphism (i.e. that multiset uniquely identifies a graph up to isomorphism)?
I'll phrase my question using an intuitive and rather extreme example: Is the expected compression ratio (using zip compression) of a children's book higher than that of a novel written for adults? I read somewhere that specifically the compression ratio for zip compression can be considered an indicator for the inform...
Given complex number $C=a+ib$, I want to find two complex numbers $C_1=x+iy$ and $C_2=z+iw$ such that $C=C_1*C_2$ (a,b,x,y, z and w are all non zero integers). This problem is at least as hard as Integer factoring. Prime complex number has one as its only factor. Does this problem reduce to integer factoring? Is it NP-...
Let $L = \{xyx \mid \text{ for some }x,y \in \{0,1\}^+\}$. Is this language regular? So I was trying to construct a DFA, but I don't how to do this with this language.
What is the difference between approximation schemes and approximation algorithms? Why do we study approximation schemes?
Say you have n bottles. each with a ratio of $(a_i: b_i: c_i)$. ($a_i/(a_i+b_i+c_i),\cdots$ swap out the numerator for $b_i$ and $c_i$ respectively). Now you are given a ratio of $(a:b:c)$. Use Linear programming to find an efficient algorithm to this problem. If it's yes, you can output the parts of bottles that gave ...
Yesterday I wrote my undergraduate exam in complexity theory. I had to leave off one question, which bugs me since then. Consider: $$ HALF-SAT = \{ \varphi \mid \varphi \text{ is a formula which is satisfied by at least half of all assignments }\} $$ I'd like to know how I can prove NP-hardness. FWIW, here's what I fig...
I'm interested in the first appearance in the CS literature of the data structure described here which is used to answer Range Queries. Although I have come across the same data structure many times with the name segment tree (mostly in algorithmic competition sites), it seems that the same name is also used for this d...
For inclusion to hold between two cache levels L1 and L2 in a multi-level cache hierarchy, which of the following are necessary? L1 must be a write-through cache. L2 must be a write-through cache. The associativity of L2 must be greater than that of L1. The L2 cache must be at least as large as the L1 cache. This was...
At many places I have read that the following language is not a regular, and thus it is impossible to express this in terms of Finite Automata. L={0^i1^i | i>=0} But I tried this as follows. Can somebody explain the fallacy?
In order to use large size page table hierarchical paging is done . In case of two level page table scheme . for : logical address space - 32bit - $2^32$ page size - 4kb i.e $2^12$ It is mentioned that page number is divided evenly : i.e page number p1 - 10 bits page number p2 - 10 bits page offset d - 12bits....
Apart from $2SAT$, what versions of SAT problem is complete for the class NL? Is there dynamic programming algorithm to solve the $2SAT$ Problem?
Part (a): Let $L = \{x \in \{0,1\}^* \mid \#0(x) \neq 4\times\#1(x)\}$, where $\#0(x)$ means the number of 0 in string $x$ and $\#1(x)$ means the number of 1 in string $x$. So I want to use the pumping lemma. But I'm having a hard time choosing a string so that I can show that it is not regular. I've been thinking abo...
I'm trying to understand how Automatic Differentiation (AD) works. For simple algebraic operation, I get the chain rule thing. But, when the code contains conditional statement like 1: test_sign = x*y < 0 2: if test_sign : 3: biggest = max(x,y) 4: else 5: smallest = min(x,y) Does AD work? If it works, can you...
I'm having difficulties understanding lambda calculus, specially identifying what's a redex. Which redexes are there in $\lambda s. \lambda z. (\lambda u. z)(\lambda v. v)$? The book uses $(\lambda u. z) [u \to (\lambda v. v)]$, but isn't $(\lambda s. \lambda z. (\lambda u. z))[s \to (\lambda v. v)]$ valid too?
Is there any formula for computing the number of 5-cycles and 6-cycles in a simple undirected graph?
As I understand it when doing a DFS run when every new node is discovered and edge is added to the DFS tree from the parent of the new node to the new node. If that's the case how are back edges are created?
Suppose we have some regular language $L$, then can we say that $$L_{half} = \{w : \text{for some } z \in L, x \in \Sigma^*, z = wx \wedge |w| = |x| \} $$ is also regular? I have a 'feeling' that it is, but I can't sketch a proof for it.
as the title states, I am trying to figure out if my approach to solving mapping reduction from $E_{TM}$ to some other language is correct. As you surely know, $E_{TM} = \left \{ < M> \mid M \ is \ a \ TM \ such \ that \ L(M)= \emptyset \right \} $. What i am trying to check is whatever a string x is in L(M). My idea i...
Suppose that there is an algorithm which sorts a sequence of $n$ elements $$a_1, a_2, ..., a_n$$ Each of the $a_i$ is chosen with probability $1/k$ from a set of $k$ distinct integer numbers. Is it true, given that $k \to \infty$, that: The probability that any two of incoming sequence elements are equal, tends to $0...
When inserting an item into a splay tree, rotations are performed in pairs based on either a zig-zag or zig-zig pattern. When there is an odd number of rotations to be performed, one could either do the extra rotation beginning at the leaf or save the extra rotation and do it at the root. Does it matter? For example, i...
I'm thinking of an application for diabetics, that, given previous values of blood glucose and insulin dosage, predicts the glucose level for the next few hours. I know a few things about neural networks and perceptrons, but not much. And there are probably whole other worlds of other machine learning methods. So I'd l...
The junta problem is the following: we have a boolean function $f:\{0,1\}^n \to \{0,1\}$ that actually happens to depend on only $k$ of its input variables. Given the value of $f(x)$ for many random values of $x$, we want to identify the $k$ input variables that $f$ actually depends upon. In other words, secretly $f(...
I have already posted this question on Stackoverflow, but I'm starting to think that this is the right place. I have a problem where I am required to associate unique combinations from a set (unique subsets) to a given value. e.g.: Let S={a, b, c, d}, the required data structure should perform the following: Key -> val...
Now I tried tackling this question from different perspectives (and already asked a couple of questions here and there), but perhaps only now can I formulate it well and ask you (since I have no good ideas). Let there be $k, n \in\mathbb{Z_+}$. These are fixed. Consider a set of $k$ integers $S=\{0, 1, 2, ... k-1\}$. W...
We have a tree with $N$ nodes. $N \le 10^5.$ Each node has a value $V$ associated with it. Now we have $Q$ $(\le 10^5)$ queries. There are two types of queries: Q X Y: in this type of query we have to decrement each node of the subtree rooted at $X$ by value $Y$. C X: in this type of query we have to count the number ...
Given a Turing machine $M$, we say that $L(M) \in P$ if the language decided by the machine can be decided by some machine in polynomial time. We say that $M \in P$ if the machine runs in polynomial time. Note that there can be machines that run needlessly long but still decide a language in $P$. By Rice's theorem, we ...