instruction
stringlengths
35
29.1k
Show that L = $\{0^{2^n}| n\geq 0\}$ is not a context free language. Let string $s = 0^{2^p}$. Then we know we can write $s$ as $s = uvxyz$. I know that |vy| > 0 and $|vxy| \leq p$. So how do I show that $uv^2xy^2z$ is not in $L$.
C++11 has a convenient Bernoulli RNG, illustrated at http://en.cppreference.com/w/cpp/numeric/random/bernoulli_distribution . However, distilling an entire random integer into a single random bit seems inefficient when the expectation parameter $p$ is rational with a small or power-of-two denominator. Is there a reaso...
(1) $L_1 = \{a^ib^{i+j}c^j|i,j\geq 0\} $ (2) $L_2 = \{xy | x,y \in \{0,1\}^*, x \neq y, |x| = |y| \}$ I doubt that $L_1$ is CFL. I've been trying to go with the string $s$ = $a^pb^{2p}c^p$. Thus, we can write $s$ as $uvxyz$. Now I'm trying to show $uv^2xy^2z$ is not in $L_1$. I really have no idea how to approach (2)....
I've read that MAJSAT is PP-complete. Under what type of reduction is this true? What kind of reductions are usually used in order to prove PP-completeness?
Suppose I have a program p that has time complexity $O(n)$ and a second program q that calls program p $m$ times. If we know the input size of p will be the same every one of those times (n), we can say that the complexity of q is $O(m \times n)$. This case sounds pretty simple to me. However, suppose the input size of...
Prove that for any finite set $X$, $|P(X)| = 2^{|X|}$. The solution should use induction.
An NFA $M$ contains a cycle if there is a state $q$ and a string $x$ such that if $M$ is in state $q$ and reads string $x$, $M$ can return to state $q$. Prove: If $M$ recognizes an infinite language, then $M$ has a cycle.
Forgive me if I am new, I am trying to learn how to solve recurrences. I have the following recurrence: $$T(n) = 2 T(\lfloor\frac{n}{3}\rfloor) + \frac{1}{2} T(\lfloor\frac{2n}{3}\rfloor) + n^2 \text{ if } n>0$$ Now from my understanding is that I am not able to use the following methods. Master Thereom (because it's ...
Consider a bipartite graph with vertex set partitioned into $X=\{u_1,u_2,u_3\}$ and $Y=\{v_1,v_2,v_3\}$. Consider the graph has the following edges: $\{u_1,v_1\}$, $\{u_2,v_2\}$, $\{u_2,v_3\}$, $\{u_3,v_2\}$ and $\{u_3,v_3\}$. The perfect matchings are $\{\{u_1,v_1\}$, $\{u_2,v_2\}$, $\{u_3,v_3\}\}$ and $\{\{u_1,v_1\}$...
In my descriptive complexity class, we've been asked to find a formula that characterises the language $(aa)^*$ (over the alphabet $\{a\}$) with a first order formula over the language $\{<, P_a\}$. This was the first class, so I will recall what we've learned to be sure that I understood. To a $L$-formula $\phi$ we as...
We have a DAG. We have a function on the nodes $F\colon V\to \mathbb N$ (loosely speaking, we number the nodes). We would like to create a new directed graph with these rules: Only nodes with the same number can be contracted into the same new node. $F(x) \neq F(y) \Rightarrow x' \neq y'$. (However, $x' \neq y'\nRigh...
The theorem of structured programming says that any algorithm can be expressed by those three control structures: Sequence Selection Iteration Isn't it possible to rewrite any loop using a finite sequence of statements and choice between statements? Isn't this what compilers do? Can't we thus omit the third structure...
I'm working on a NFA to DFA conversion tool that is different from the Subset Construction and I need to test this tool. In order to be sure that the immplementation has no bug I'd like to generate a random NFA with these properties: The NFA should be connected The NFA should have one initial state and one or more fin...
Let L be language of balanced parentheses. (a) Prove If there are equal number of ('s and )'s and every prefix of w contains at least as many ('s as )'s, then w is in L. (b) Prove If w is in L, then there are equal number of ('s and )'s and every prefix of w contains at least as many ('s as )'s. After much thought, I d...
$L = \{0^i1^j0^i1^j|i,j \geq 0\}$ I've tried letting $s = 0^p1^p0^p1^p$. But not sure where to go from here. Help would be appreciated.
I'm presented with two snippets of code, and I need to determine their time complexity. I'm pretty convinced that both of these are $O(n^2)$, but I'm not 100% sure 1.) 2.)
I'm having trouble with this question about regular expressions: Let $L_1$ be the language of passwords containing at least one lowercase letter, at least one uppercase letter, and at least one number. Write down a regular expression that describes $L_1$. This is my answer, but I'm not too sure about it. I let $\...
I have a question related to the hardware protection needed to implement an operating system kernel: Identify at least three hardware level mechanisms that are necessary to protect an operating system kernel from malicious or erroneous user programs. I can't work out what that would be from the Wikipedia article.
I'm doing some research on game semantics using these notes. Currently I'm trying to prove that the definition of composite-strategy is indeed a strategy. I have already proved all the conditions of strategies except that it is prefix-closed(for even-length prefixes) and respects the alternation rule. Can somebody giv...
I am trying to understand what is meant by "deterministic" in expressions such as "deterministic context-free grammar". (There are more deterministic "things" in this field). I would appreciate an example more then the most elaborate explanation! If possible. My primary source of confusion is from not being able to tel...
Im studying for the computer science subject GRE test, as an exercise i need to implement the followin algorithm in java, any idea on how to aproach it?. Given a set $X$ and $z$ not in $X$, indicate between which would be the immediate positions $z$ in $X$
I am trying to store an existing 2D triangulation (of which I have all of the vertices and edges) in a DCEL data structure. Using the algorithm described in this answer, I was able to store a part of the triangulation, but not the "half-edge" representative for each triangle. The algorithm is reported below Algorith...
Well, forgive my ignorance about the matter as I have been playing with ASP for the last couple of days. Consider this simple example p. s :- p. And the corresponding output generated after running the program in clingo: $ ./clingo.exe ex.lp --number=0 Answer: 1 p s SATISFIABLE Models : 1 ... Where possible mo...
The TCP(Transmission Control Protocol) delayed duplicate problem is discussed in Tannenbaum's "Computer Networks." The discussion references Tomlinson (1975) improved by Sunshine and Dayal (1978). Basically, from what I could make out it uses a ToD (Time of the day) clock to uniquely number packets and ensure that, if ...
Why is the reduction $\textbf{SAT} \leq_P \textbf{3SAT}$ possible, but $\textbf{SAT} \leq_P \textbf{2SAT}$ not possible, given, that $\textbf{SAT}$ is $\textbf{NP}$-complete, $\textbf{2SAT} \in \textbf{NP}$ and $\textbf{3SAT} \in \textbf{NP}$?
I guess at the heart of this is that I don't really understand hash functions. One article says any function mapping objects to an object of fixed size: A hash function usually means a function that compresses, meaning the output is shorter than the input. Often, such a function takes an input of arbitrary or alm...
From CLRS (3rd edition), I came have this question on page 626: Given these definitions from the text, DEFINITIONS: Given an undirected graph G = (V,E), 1. A CUT (S ,V-S) of G is a partition of V, 2. A LIGHT EDGE over a cut is any edge crossing the cut with a weight smaller than or equal to any other edge crossing tha...
I've been reading Saxe's proof that 1-embeddability of integer weighted graphs is NP-Complete (http://www.math.columbia.edu/~dpt/RigidityREU/Saxe79EmbedNPHard.pdf Theorem 3.2). I don't understand how this proof works. First of all, does "1-embeddability" mean mapping each vertex to the real line? What is meant by a...
I am reading a paper and it uses the expression "polynomial delay" which I don't understand. It is used in conjonction with the big O notation, which I'm familiar with. Here is a example sentence showing how it is used: The loop is executed in time $O(n^2(e+n))$, which makes a polynomial delay for the output of the d...
$L = \{ \langle M \rangle \mid \text{there is at least one input string on which the \(M\) does not halt} \}$ Here, for a Turing machine $M$, the notation $\langle M \rangle$ denotes an encoding, over some alphabet, of the code of the Turing machine. To which of the following language classes does $L$ belong? Regular....
I am trying to understand how to solve complex recurrence relations and whether there is a general method or technique to help me. That being said I am not talking about recurrence relations that can be solved using the (generalized) Master Theorem or the Akra–Bazzi method. This is by no means a "I have some homework t...
I'm reading Sipser and I'm finding it hard to understand what the process is such that if you give me k Turing machines with k tapes, I can spit out an equivalent Turing machine with only one tape. An example would be nice. Actually, a worked out example that shows how to go from TM that has $k$ tapes to one that has 1...
I am perpetually confused when it comes to static scoping and dynamic scoping and their differences and Wikipedia isn't of any help, so here's my question: Given the following pseudo code in a hypothetical programming environment, what are the outputs under the following conditions? call by need using static scope ca...
What would be the equivalent math concept for associative arrays/maps/dictionaries? EDIT: Disregard mutability. FYI,off topic, the reason why I ask this question, is that I want to calculate the distance(or similarity) between two maps given that I have a distance function for each entity(or key) in the map.
I was looking at this: http://www.cs.odu.edu/~toida/nerzic/390teched/tm/othertms.html At the very beginning, they show a 2d tape and (I assume) it's 1d equivalent. However, I cannot figure out they got from the 2d case to the 1d case. I was hoping someone could elaborate.
Can anyone give me some hint on solving $T(n) = T(\frac{n}{2} + \sqrt{n}) + n$, with any method, master method, substitution.... I have came up with this : $T(n) = T(\frac{(\sqrt{n} + 1)^{2} - 1}{2}) + n$ and then substituting $n = 2^{m}$ but things gets really messy ! any idea?
Alloy's front page doesn't mention ASP, but the description sounds like ASP (finding solutions consistent with a logical spec). And Alloy isn't listed in the Wikipedia ASP article. Yet ASP systems and Alloy both seem to built on top of SAT solvers. So how do they differ? [edit: Would it be fair to say, for example, ...
I am using neural networks to predict a time series. The question I'm facing now is how do I encode date/time/serial no. of each input set as an input to the neural network? Should I use 1 of C encoding (used for encoding categories) as described here? Or Should I just feed it the time (in milliseconds since 1-1-1970)?...
if a,b are both binary bit. a=0, and b=0, what is least significant bit,and most significant bit of a+b, which means 0+0? if c is the carry bit, and c=1, what is the least significant bit,and most significant bit of a+b when a=0,b=1 My thought is 0+0=0, thus least significant bit,and most significant bit are same, whic...
In Chap 34.3 NP-completeness and reducibility of the book, Introduction to Algorithm(3rd Edition), the author states(the original text): We call the function f the reduction function, and a polynomial-time algorithm F that computes f is a reduction algorithm. In my mind, function should be a machine dependent implemen...
I have a simple looking question. What is the most efficient conversion of $\sum_{i=1}^n x_i = y$ to 3-sat? Here $x_i$ is either $1$ or $0$ and $y$ is some positive integer. Can you do better than making a SATISFIABILITY instance with $\binom{n}{y}$ clauses, each of which is the conjunction of $y$ positive literals a...
Can anybody give me a way that i can use to calculate Complexity Time problems, i mean a way that will work on any complex code whatever it was. I can solve basic problems, but whenever the problem gets a little complex i freeze which means that my way of thinking and solving is wrong. for example like this:
A question on the interesting result in http://arxiv.org/pdf/1110.6126v1.pdf It is shown $\Pi_2^P \not\subset P^{NP}$. But http://en.wikipedia.org/wiki/Polynomial_hierarchy says $\Pi_2^P = CoNP^{NP}$. Does this mean an oracle in NP under which $P$ is not $CoNP$ has been shown? Could someone elaborate?
Wiki (http://en.wikipedia.org/wiki/Sharp-P) says 'In computational complexity theory, the complexity class #P (pronounced "number P" or, sometimes "sharp P" or "hash P") is the set of the counting problems associated with the decision problems in the set NP'. Is there a counting version for CoNP problems?
I am currently studying the pumping lemma for regular languages and I am trying to come up with an example where even if the language can be pumped it is not regular. Which condition of the lemma should be broken such that I can find a language like that?
How to solve the recurrence relation below? $$T(n) = \begin{cases} 2T(\sqrt{n}) + \log n/\log\log n & \text{if } n > 4\\ 1 & \text{if } n \leq 4. \end{cases}$$ Preferably by the master theorem; otherwise by any method. I know the Master Theorem fails, but is there any extension for t...
I have come across a question that I am having quite a hard time with. I am to draw a design of an SRAM chip with an organization of 2M*128 SRAM that uses 1K*1K arrays of D latches. And then the questions ends with saying, "if this design is not possible then explain why." I have looked at other SRAM designs and have n...
I need to analyze the time complexity of an online algorithm to keep track of minimum $K$ numbers from a stream of $R$ numbers. The algorithm is Suppose the $i$th number in the stream is $S_i$. Keep a max heap of size $K$. If the heap contains fewer than $K$ elements, add $S_i$ to the heap. Otherwise: if $S_i$ is sma...
I have to create an algorithm for homework, but cant figure out where to start. The divide and conquer algorithm muse be O(nlgn) and returns a pair of numbers p and q in an array A. p must appear before q in the array, and q-p must be the highest possible value heres and example I made up: A=[1,4,12,5,9,1,3,8] the ret...
Given a hypothesis $h:X\rightarrow Y$ ($h$ is returned by an Empirical Risk Minimization (ERM) strategy with realizable case i.e. $h$ is consistent with the sample examples) over $X=[0,1]\subseteq R$ where $Y=\{0,1\}$ and $D$ is the uniform distribution over $X$. How can I prove that for the accuracy parameter $0\leq\e...
What would be the best introduction to Per Martin-Löfs ideas about type theory? I've looked at some lectures from the Oregon PL summer school, but I'm still sort of puzzled by the following question: What is a type? I know what a set is, since you can define them by the usual ZF axioms and they have a very intuitive co...
(If I am posting this in the wrong StackExchange site, then please direct me to the correct one) Okay, so some small background first: I am currently third-years student in Computer Science on the university. I have big interest in Artificial Intelligence and I was wondering if I could practice it somewhere, for exampl...
I am studying "An Introduction to the Theory of Computation" by Sipser -- there is a problem *3.17 (p.161) which I can not solve. Any hints (not answers) from which side to attack it? Let $B=\{M_1, M_2, ...\}$ be a Turing-recognizable language consisting of TM descriptions. Show that there is a decidable language C c...
We have started learning about analysis of recursive algorithms and I got the gist of it. However there are some questions, like the one I'm going to post, that confuse me a little. The exercise Consider the problem of multiplying two big integers, i.e. integers represented by a large number of bits that cannot be han...
I am stumped as to how to print the longest path from the root of a binary tree to a leaf, essentially traversing the height of the tree. I've got the following for finding the height of a binary tree: if (root == null) { return -1; } return 1 + (Math.max(heightOfTree(root.leftNode), heightOfTree(root.rightNode)))...
I'm a bit confused about these concepts. As far as I understand, something is Turing complete when it can simulate a Turing machine. And there is this thing called a Universal Turing machine which is universal because it can simulate a Turing machine. Which to me, implies there are Turing machines that are not universa...
I'm thinking this should be just one or two things, since lambda calculus is so tiny and still Turing complete. Probably just recursion (something like "MY_QUERY(param) = select * from param UNION MY_QUERY(DO_SOMETHING_WITH(param))"). But I don't see how I could define aggregate functions with this. Any idea?
I have seen web sites that purport to "prove" that HTML5+CSS is Turing Complete. I have seen web sites that purport to "prove" that SQL is Turing Complete. I have seen a bunch of web sites that purport to "explain" what it means to be Turing Complete. Enough! Where can I find a book (written by an expert in computabili...
I'm trying to prove that the language: \begin{equation*} L = \{ w \in \{ 0, 1 \}^* : w \text{ contains more 0's than 1's} \} \end{equation*} is irregular using the Myhill-Nerode theorem. I've been through all the basic examples in the book, and thought I understood them, but I'm having trouble with this one. So far, I...
I was asked to perform merge sort by iterative method. I solved it as follows: I first stored each of the elements of the array given in another array say $A$. Then I sent entries of $A$ two by two for merging(was given that the function for merging is known and it merged two arrays at a time). This function returned t...
Imagine I have an ordering on a bunch of elements like so: Where an arrow $X \leftarrow Y$ means $X < Y$. It is also transitive: $\left(X < Y\right) \wedge \left(Y < Z\right) \implies \left(X < Z\right)$. In order efficiently answer queries like $A \stackrel {?}{<} D$, some sort of labeling or data structure is requir...
Suppose I have a set of small subgraphs $A=\{G_i\}$ of an original directed acyclic graph $G$, typically $|G_i| \ll |G|$, which together span the original graph $$ G= \bigcup_i G_i $$ My question is if I take a arbitrary subset of these graphs $A′ \subset A$, and a single subgraph from this graph, $ a \in A′$, is there...
I have an array of positive integers, $A = (a_1, a_2, ..., a_n)$. Let $s(A)$ denote the sum of elements of array $A$. I also have an integer $t$, such that $1 < t \le s(A)$. I want to split the array $A$ into $m$ contiguous subarrays $(A_1, ..., A_m)$, for which I'll get a minimum of function $f$, defined as $$ f(A_1, ...
I know Gentle Boost, an adaption of the AdaBoost algorithm, can be used for binary classification. However, I need to do $n$-ary classification. How do I modify or extend the GentleBoost algorithm so it can be used for $n$-ary classification?
I have in mind a particular 3D object. Given an image taken by a camera, I want to check whether that image contains an instance of my object. For instance, let's say that the object is a bathroom sink. There are many kinds of bathroom sinks, but they tend to share some common elements (e.g., shape, size, color, func...
I have a bijection problem that I cannot get my head around. It goes like this: let f: A -> B and g: B -> C be functions such that g o f is a bijection. Prove that f must be one-to-one and that g must be onto. And also an example showing that it is possible for neither f nor g to be a bijection. This is the problem. ...
u is defined to be a substring of a string v if v = xuy for some string x and y. Either or both possibly empty. How to you prove that a substring relation on any set of strings is a partial order?
I'm interested in building an AI algorithm to play a board game. This is a sequential two-player game, where they alternate taking turns, so minimax or alpha-beta algorithms sound natural. However, the twist here is that the game is randomized. There is a deck of cards that is shuffled randomly; each turn involves dr...
Using the following recursive Fibonacci algorithm: def fib(n): if n==0: return 0 elif n==1 return 1 return (fib(n-1)+fib(n-2)) If I input the number 5 to find fib(5), I know this will output 5 but how do I examine the complexity of this algorithm? How do I calculate the steps involved?
Let $S$ be a convex polygon on $n$ points. Given two points $A$ and $B$, where $A$ is left of $S$, and $B$ is right of $S$, what's an algorithm to find the shortest path from $A$ to $B$, that avoids the interior of $S$? What about the longest path?
One naive approach in solving multiple pattern matching problem is to call single pattern matching procedure on each of the pattern. There must be some drawbacks in this approach, given the variety of multiple pattern matching algorithms such as Aho Cornsick algorithm, which prove to be more efficient. So what are the ...
This may be a naive question but I am a bit clueless. I was under the opinion that given two NP complete problems, $P1$ and $P2$, if $P2 \in APX$ and $P1 \notin APX$, then we cannot have a direct reduction $P2\leq P1$ but we can have a reduction $P1\leq P2$. In this paper on page 165 http://www.lancaster.ac.uk/staff/le...
I have a doubly link-list like this typedef struct Record { int i; Record* next; Record* prev; }Record; I have over 5 trillions of records that I need to handle, now that I need to retrieve all of them and sort them out. If its size was small, I could borrow stl's vector or list to do the job but now that it ...
Consider the following random process. We have a $10\times 10$ grid. At each time step, we pick a random empty grid cell (selected uniformly at random from among all empty cells) and place a marker in that grid cell. As soon as we have five contiguous markers in a line (in a row, column, or diagonal), we stop. I'm g...
Assembly language is converted in to machine language by assembler. Why would a compiler convert high-level language to assembly? Can't it directly convert from the high-level language to machine code?
I am doing bachelors in Electronics & Communication Engg.. But most of my work happened to be in Web development.. I am thinking to do my bachelor thesis which very closely overlaps with my recent work. Are there any specific areas in CS, EE (may be Computer Networking in broad terms) that I can take up?
I am looking into Hindler-Milney type system and I am trying to add support for the pair type. In Pierces book, he introduces special language constructs for creation of pairs and getting their elements. What I am interested in is the following. What if I don't introduce new constructs, yet use special functions with t...
In some paper I read, A theoretical worst case study shows that a single regular expression of length $n$ can be expressed as an NFA with $O(n)$ states. When the NFA is converted into a DFA, it may generate O($\Sigma^n$) states. The processing complexity for each character in the inpuyt it $O(1)$ in a DFA, but ...
The CLIQUE problem -- problem of finding the maximum clique in a graph -- is NP-complete. That is, CLIQUE is in NP and there is an NP complete problem, 3-SAT for one, that reduces to CLIQUE in polynomial time. Part 2. above is fine -- all over in every resource and very well explained. For Part 1., from what I know,...
(I've been stuck on this homework assignment for far too long) I need to find the number of independent sets in a tree. For example, say the set of nodes in a tree is {A, B, C, D, E}. B and C are children of A and D, E are children of B. This tree has 14 independent sets. I assume that the algorithm will be recursive...
Suppose I have a compressed file and it is not possible to compress it more without loss of information. We say that this file is random or pseudorandom. So, if the randomness means not comprehensible and not compressible, I don't understand why ths file is, at the same time, information that my computer and I can unde...
For analyzing the running time of an algorithm , I'm stuck with this recursive equation : $$ T(n) = \log(n) \cdot T(\log n) + n $$ Obviously this can't be handled with the use of the Master Theorem, so I was wondering if anybody has any ideas for solving this recursive equation. I'm pretty sure that it should be solved...
I have a question regarding counting DFAs: Given a Σ = {0, 1} input string, with the state set Q = {1...n}, how would I find the total number of DFAs that can be constructed? I believe this is a combinatorics problem, but I am not really sure what I would have to multiply. Thanks.
Just like there exists binary and integer Semaphores, does the Event Counter play an integer version of a Barrier? Event Counters are described in the paper Reed, DP; Kanodia, RK: Synchronization with eventcounts and sequencers. Commun. ACM 22(2):115-123, 1979, http://doi.acm.org/10.1145/359060.359076 There is an onl...
Is the set of all syntactically valid C programs countable or uncountable?
Let $\Sigma$ and $\Delta$ be alphabets. Consider a function $\varphi: \Sigma \rightarrow \Delta^*$. Extend $\varphi$ to a function from $\Sigma^* \rightarrow \Delta^*$ such that: \begin{eqnarray*} \varphi(\varepsilon) & = & \varepsilon \\ \varphi(w\sigma ) & = & \varphi(w)\varphi(\sigma ), \textrm{ for any } w \in \Si...
This is a kind of follow-up to a question I asked on superuser, where I asked for the definitions of a 'distinghuisable state' and a 'memory cell'. My questions where properly answered, but I was still confused about a certain matter. I'm reading this little paper, and in particular these sentences: To perform useful ...
I'm searching for a reference of an undecidability proof that is as simple as possible and starts "from scratch". With "from scratch" I mean that it does not use some other undecidable problem to prove some undecidability (which is the usual case), I cannot wrap my mind about how proving undecidability that way (withou...
Is there an incremental directed graph data structure that has the following properties: Keeps an internal graph structure as a DAG, and the graph is accessible (notwithstanding other helper data-structures) The accessible DAG is kept as a transitive reduction (notwithstanding other helper data-structures) It should ...
I'm clojure user myself. I'm trying really hard to learn haskell and to better understand the type system. However, I feel that trying to 'type' everything is quite restrictive when the problem or the data is less defined. I intuitively feel that godel's incompleteness theorem offers some insight into the typed/untyped...
I have the following problem: Does inserting a node into a red-black tree and then immediately deleting it always result in the original tree? Prove that it does or give a counter-example if it does not. Does deleting a leaf node from a red-black tree, then reinserting the same node always result in the original tree?...
Let $a$ one decision problem and $A$ one algorithm solving it in $O(n^k)$. But, to construct $A_n$ we need to compute certain thing (strategy path, magic numbers, ...), we can compute that using certain general algorithm $R$ in $O(2^n)$. Obiously, $A$ is polynomial (then, all $A_n$ are in P) and $R$ is exponential. We ...
I didn't know how to ask this question before but now that I'm reading about typed lambda calculus I think I've got a better idea. There is this answer to a question asking whether CSS is Turing complete or not (note that this question is NOT about CSS at all), which I consider is not (at least in certain way, and thi...
Let $x=(x_1,\dots,x_n)$ and $y=(y_1,\dots,y_n)$ be $n$-vectors of boolean variables. I have a boolean predicate $Q(x,y)$ on $x,y$. I give my friend Priscilla $Q(x,y)$. In response, she gives me $P(x)$, a boolean predicate on $x$, and she claims that $$P(x) \equiv \exists y . Q(x,y),$$ or in other words, that $$\fora...
Does anybody know how would I approach calculating the maximum number of 1 child nodes (nodes that have exactly 1 child) in a binary tree with n nodes. Please don't give me the actual answer as this is one of the homework problems, I would like to solve it by myself, but I simply don't know where to start. Any help is ...
This is a bit of a weird question, but I was wondering earlier if QR codes are Turing-complete when interpreted as initial states for Conway's Game of Life. My intuition is "yes", as there are infinitely many QR codes (they just get bigger as you add more information), and the Game of Life itself is Turing-complete. Ho...
Big-O notation hides constant factors, so some $O(n)$ algorithms exist that are infeasible for any reasonable input size because the coefficient on the $n$ term is so huge. Are there any known algorithms whose runtime is $O(f(n))$ but with some low-order $o(f(n))$ term that is so huge that for reasonable input sizes it...
Scott Meyers describes here that traversing a symmetric matrix row-wise performes significantly better over traversing it column-wise - which is also significantly counter-intuitive. The reasoning is connected with how the CPU-caches are utilized. But I do not really understand the explanation and I would like to get ...
Reading the Appendix A (Binary numbers) of Structured Computer organization by Tanenbaum I've found this exercise: Signed decimal numbers consisting of $n$ digits can be represented in $n + 1$ digits without a sign. Positive numbers have $0$ as the leftmost digit. Negative numbers are formed by subtracting each digit ...
Suppose we are given an M×N matrix, with some elements are zero, some non-zero. We know the co-ordinates of non-zero elements. Now, if I am allowed to multiply a whole row or a whole column by zero one at a time what will be minimum number of operations (i.e multiplications) I will need. For example, for the matrix $\b...