instruction
stringlengths
35
29.1k
Why do most implementations of arrays have constant access time and linear insertion time?
Title is self explanatory. I have searched here on this site and haven't found any discussion about this. Is it somehow related to Turing's Halting problem (which is undecidable)?
I'm trying to prove that some problem, A, is in NL. I have found a logspace reduction from A to 2-SAT - am right in thinking that this is not sufficient to prove that A is in NL? If so, how does one formally go about proving that a language is in NL - is the only way we can do this by providing some deciding non-determ...
I am preparing for an exam and I came across this question in one of the tests. Halting problem of Turing machines which recognize recursive languages is undecidable. (True / False) The solution given says the statement its False. But I think the statement is True. Halting problem in itself is undecidable. We can't...
I would like to construct a Minimum Distance Spanning Tree (Dijkstra) for the graph below: MDST: {(a,c), (c,h), (c,f), (a,d), (h,g), (a,b), (d,e), (h,j), (h,i), (j,k), (e,m), (i,l)} Is my understanding correct? The total cost would be 49 (sum of the distance from the root for each node).
Consider the decision problem: given formulas of propositional logic $\phi_1, \ldots, \phi_n, \psi$, determine whether $\phi_1, \ldots, \phi_n \vdash \psi$ intuitionistically. This problem is well-known to be decidable, for example using an algorithm derived from the LJT* sequent calculus. I was wondering if the comp...
Consider the following problem : Given a set of sets of integers, $\Sigma = \{S_i, i \in I\}$, and a set G, determine wether $\Sigma$ contains a partition of G, i.e. a set $J \subseteq I$ such that $G = \bigsqcup_{j\in J} S_j$. This problem is (if i'm not mistaken) in NP. I'm trying to determine wether this problem i...
I was given the following algorithm as a solution to one of my problems. However, I am baffled at understanding how c' is ever initialized. The first if statement can never be reached, as c' is never set the first time. Can someone explain this to me? Am I just missing where c' gets set? This is for Kleinberg and Tardo...
My question relates to a video I watched on YouTube. The pipeline is a 5-stage pipeline which include fetch, decode, ALU, Mem (data), and Write. It mentions that nothing is fetched until we're sure what to fetch. How can that be though? Won't you need to fetch and decode an instruction first to know what to fetch? He ...
I'm starting to dabble in the world of approximation algorithms and had a question about the convention many papers will use when talking about the approximation factor. I know that an approximation factor will give the factor within which the algorithm will perform with respect to the optimal solution. This is pretty ...
In the book Reinforcement Learning An Introduction,Chapter 8.5,there is an example that compares the efficiency of expected and sample updates: According to the author, "In this case, sample updates reduce the error according to $\sqrt{\frac{b-1}{bt}}$ where $t$ is the number of sample updates that have been performed ...
Traditionally, the usual definition you find for model of computation is "an abstract description of how an output is computed given an input" (Wikipedia and my TCS course are my sources, but the other websites I've seen seem to agree). To me, this seems really close to the informal notion of algorithm, which is "a ste...
I have started reading about COP, but can't really get a grip of it. What I understand is that you use layers to let the software dynmically adapt depending on the context, and this would result in less code duplication. But other than that, what are the advantages of COP (what can I do with COP that would be hard to d...
Given the following predicate formula $F$: $$\forall x \forall y [(\text{italian}(x) \Rightarrow (\text{winWC}(y) \Rightarrow \text{happy}(x))]$$ I am having trouble understanding whether $x$ and $y$ must be different elements. Also, I have been given the following statement: "Italians are happy if the Italian Nationa...
I am searching for a data structure that can capture a database, which is consisted of one column of intervals (like [0, 2], [4, 6]) and one/two columns of keys (like {'a', 'c'}). I want to be able to do efficient indexing in both ways such as queries like the following are computationally balanced: "give me the keys ...
Matrix chain multiplication problem:- Given a sequence of matrices, the goal is to find the most efficient way to multiply these matrices. This problem is solved using dynamic programming. Similarly GCD chain operation is defined as:- Given a set of $n$ integers, what is the most efficient way to find the gcd of all t...
According to the textbook by Silberschatz, A relation schema R is in third normal form with respect to a set $F$ of functional dependencies if, for all functional dependencies in $F^+$ of the form $\alpha$ → $\beta$, where $\alpha$ ⊆ R and $\beta$ ⊆ R, at least one of the following holds: $\bullet$ $\alpha$ → $\beta$ ...
Is it correct to say that: "A complete graph is a graph in which each vertex is connected to all other vertices in the graph" That's how I always thought about it, the official definition is different (I know that).
I have a source undirected colored graph $G$ and a base query graph $g$. I know $g$ is subisomorphic to $G$ and now I want to identify which edges I can add to $g$ to preserve subisomorphism. That is, for any pair of vertices $(v_i, v_j)$ in $g$ if $g' = g \cup e_{i,j}$ is $g'$ still subisomorphic to $G$? what I'm tryi...
Given two strings $S_1, S_2$, we write $S_1S_2$ for their concatenation. Given a string $S$ and integer $k\geq 1$, we write $(S)^k = SS\cdots S$ for the concatenation of $k$ copies of $S$. Now given a string, we can use this notation to 'compress' it, i.e. $AABAAB$ may be written as $((A)^2 B)^2$. Let's call the weight...
I'm interested in balanced base $B$ representation for fixed point arithmetic. The paper Fixed-point arithmetic in SHE schemes (Costache, Smart, Vivek and Waller, in Proceedings of 23rd International Conference on Selected Areas in Cryptography (SAC 2016), Springer Lecture Notes in Computer Science, vol. 10532, pp. 401...
Recall that a Monte Carlo algorithm is $p$-correct if it outputs a correct answer with probability at least $p$. In the case of decision problems, where the answer is binary, repeating the MC algorithm can increase the confidence that a correct answer is obtained. However, in the case where more than 1 possible answer...
I want to construct a LOOP-computable program for the integer division (quotient): x = a DIV b The LOOP specification can be seen here: https://en.wikipedia.org/wiki/LOOP_(programming_language) I don't know how to do this without a while.
from what wikipedia says shearlet is a successor to wavelets(whatever that is) and that they are extremely good at representing complicated data efficiently. But neither wikipedia nor other articles that i found have any layman definition of shearlets in it. A layman definition would be great and algorithm to implement...
I am stuck at the complexity of the following problem: Given a multiset $S = \{x_1,..., x_n\}$ of $n$ integers and a natural number $k$. Can $S$ be partitioned into multisets $S_1,... S_j$ such that for all $S_i \subseteq S$ there is $\sum_{ s \in S_i} s = k?$ I have found out that this may be somehow related to the Eq...
Can someone please help me understand why(the derivation) "and m = 2n+1 for each n."? I am trying to follow the logic of the solution provide while myself have a different approach. Here is my thinking (questions state below): The inner for loop runs m times from 1 and the outer for loop runs n times from 1. Moreover,...
I need to prove that the following language is in $\mathsf{P}$: $$ L = \{\langle x,y,z,d \rangle : xˆy \equiv z \pmod{d}\}.$$ I'm assuming I just have to prove with an algorithm or negate that it's part of NP. But I don't know how to do it with this mathematical formula.
I know that it isn't necessary that cross product automaton for two minimal DFAs be minimal, but according to my analysis, if two DFAs do not have any common string then their cross product of minimal DFAs would be minimal. What should I do to prove this?
I have a set of investors (say n), and a set of startups (say m). At the start, I have all the investors say either yes or no to the startup (which corresponds to whether they want to interact with them or not). Now, I have to conduct a networking event of r rounds considering this scenario. In each round, I match inv...
Knuth's original attribute grammar paper (title: Semantics of Context-Free Languages) apparently had a flaw where circularity is always detected but some noncircular AGs may be reported to be circular. Knuth later constructed an exact algorithm which is exponential in time. I am wondering what was the fix? which part o...
int ChromaticNumber(Graph G) { for (int i = 0; i < G.Vertices.size(); ++i) { //initialize vertex color to 1 ++G.Vertices[i].Color; bool Match = true; //loop while there is an adjacent vertex with the same color while (Match) { Match = false; ...
Preface I've asked a very similar question already on stack overflow in a different wording and gotten a working answer under the assumption that there is no way to go through all possibilities (np-hard). After doing further research (because this is my bottleneck atm), I stumbled upon this similar question, but again...
You are given a function $F$, which can take one or more positive integer operands. Let $L=\{a_1,a_2\ldots a_n\}$. We need to compute the function $F(L)$ using the least number of transformations/steps. Computing $F(L)$ is not the main goal. Computing it in the fastest possible way is the goal. Following rules are allo...
I have a problem to resolve: A Bayesian Network structure is given to me, with a dataset of values for each variable. I also have a set of queries, like P(A=1 | B=0) or P(L=0, B=1 | C=1). The goal is to find the parameters of the model. The first task was to use the frequentist approach. So, for the first query P(A=...
I am studying lambda calculus for the first time and I was trying to do the reduction beta of the lambda term $(\lambda x.xy)y$. Can I assume that these two free variables $y$ are the same? Or do I need to rename the rightmost $y$?
Forgive me for my ignorance as I am self-teaching myself some of this theory... I am having some trouble understanding how to systematically/algorithmically compute FOLLOW sets, given that I have computed the FIRST sets. For the following grammar: E -> TE' E' -> +TE' | ε T -> FT' T' -> *FT' | ε F -> (E) | id I found...
I'm studying Quick-Sort and I am confused as to how it works when the first element is chosen as the pivot point. I am trying to trace the first step in the Quick-Sort algorithm, to move the pivot (15) into its appropriate position. Example: [15, -7, 22, 7, 21, 34, -13, 19] My understanding: 15, -7, 22, 7, 34, -13, 19 ...
We have a set of problems involving date ranges - a pair of dates representing a start date and an end date. In some places, we have say 1000 of these and need to find the ones that overlap a separate set of 1000 of these. But a linear search is exponentially expensive. So is there an algorithm that is more efficient? ...
I have an array of sorted numbers: arr = [-0.1, 0.0, 0.5, 0.8, 1.2] I want the difference (dist below) between consecutive numbers for that array to be above or equal a given threshold. For example, if threshold is 0.25: dist = [0.1, 0.5, 0.3, 0.4] # must be >=0.25 for all elements arr[0] and arr[1] are too close to ...
I'm trying to solve an integer linear program (ILP) in which a constraint of the following kind must be met: $x_1 \oplus x_2 \oplus \cdots \oplus x_n = 1$ where $\oplus$ is the binary xor operator. The answer to this question shows how to represent $y = x_1 \oplus x_2$ with linear inequalities. In an answer to this qu...
I have a problem in error-correcting codes. Say we have a generator matrix of a linear binary code $$g=\begin{pmatrix} 10011 \\ 01101 \end{pmatrix} $$ Q1: How many different codeword do we have? How many code bits can the code correct? Say the generator matrix of a $(6,2)$ binary code is $$g=\begin{pmatrix} 101001\\...
Given a language L, I've shown that L is not regular. Can I conclude that it is not decidable or are there non-regular languages that are decidable?
I am trying to write an efficient Parallelised algorithm for Data Averaging. By this I mean I have a list of tuples (K, V1, V2, V3) and in the end, I want a dictionary mapping K to the average of all V1, V2 and V3 present in the list with K. If anyone can think of something it would be much appreciated. Thanks, Harris ...
I am supposed to find a language $$L\subseteq \Sigma ^*, \Sigma \subseteq \mathbb{N}$$ that fullfills the pumping lemma and is not in RE and not in coRE. I've never constructed a language with a given constraint, I've only shown that a certain language satisfies a given one. Not wanting to waste a bunch of time guessin...
So the complement of L1 = $\{a^{n}b^{n}c^{n} \mid n \geq 1\}$ would be L2 = $\{a,b,c\}^* \setminus \{a^{n}b^{n}c^{n} \mid n \geq 1\}$. In other words, any combinations of a,b and c where we dont have an equal number of all three letters and w = $\varepsilon$ is also legit. However, while I'm certain that there should ...
Is there a trick for computing the expression $x + (exp(x)-x)/(exp(2*x) + 1)$ while avoiding an overflow? Currently, computation seems to fail for any $x \geq 710$, presumably because computing $exp(2*x)$ leads to an overflow. The expression as such never produces particularly large numbers, but exponentiation seems ...
I know that every DPDA (deterministic PDA) is a PDA (more specifically, non-deterministic PDA). But I found it hard to understand, not that every DPDA is an NPDA, but some results that contradict this fact: In PDA we have two modes of accepting the language, which are "empty stack method" and "final state acceptance m...
I am looking for an algorithm to solve the following variant of interval scheduling : schedule some tasks on multiple machines, which are only available during a given interval of time. Two tasks cannot be performed at the same time by the same machine. I am trying to maximize the number of scheduled tasks. More form...
I have a set of touching rectangles (Initial problem), and an associated graph relating the rectangles through the edges. I want to reduce the rectangles through graph operations to the minimum internal border (Optimal solution). Sub optimal solutions which can be solved quickly are also acceptable. The reason why the ...
Lamport timestamps and vector clocks sound like almost the same thing. Both are used to determine the order of events in a distributed system. What are their key differences?
Before I found out about FFT https://m.youtube.com/watch?v=spUNpyF58BY but having seen and been impressed by spectrograms/sonograms, I developed my own algorithm for converting to the frequency domain from the spacial domain. The following sudocode describes the approach. // epsilon_n constants are small adjustable val...
So I know that these are both true, but if I change the values would they still be true? Do these statements hold for any value? A) Suppose f is a flow of value 50 from s to t in a flow network G. The capacity of the minimum s-t cut in G is equal to 50. Suppose we were using 100 or maybe 75 instead of 50. Is this stil...
I'm looking for an efficient solution to the problem of tracking the number of connected components in a general graph under edge deletions. General connectivity algorithms like that from Holm, Lichtenberg and Thorup solve this problem and also feature edge insertion and connectivity queries, which I dont really need,...
I'm trying to understand cache misses/iter and came across this that I couldn't understand or reason out. For ijk iteration, my slides say that there are 2 loads and 0 stores. for (i=0; i<n; i++) { for (j=0; j<n; j++) { sum = 0.0; for (k=0; k<n; k++) sum += a[i][k] * b[k][j]; c[i][j] = sum; } } Sim...
I provided my answers in the "answer your own question" bit. I have applied the same logic for my answers to a&b and c&c which seem to be essentially the same questions. Am I right though? a) Suppose f is a flow of value 50 from s to t in a flow network G. The capacity of the minimum s-t cut in G is equal to 50. b) Su...
Threads called the "unit of dispatch" but what does that mean? I was looking over the web and two operating systems books but I can't find the answer. It seems that processes are defined by two characteristics: resource ownership and scheduling/execution. I understand that threads are within processes, and that there m...
Consider the $\text{CTL}^*$ formula $E[pU(qUr)]$. It is not hard to show that it is equivalent to the $\text{CTL}$ formula $E[pU(EqUr)]$. The informal reason is that a path where $p$ is true until $qUr$ is true is the same as a finite branch where $p$ is true along it, followed (concatenated with) by a path (starting ...
For comparing two images, one can use the Peak Signal-to-Noise Ratio (PSNR) metric, defined as follows: $\mathrm{PSNR} = 10 \cdot \log_{10}\left(\frac{\mathrm{MAX}^2}{\mathrm{MSE}}\right) = 20 \cdot \log_{10}(\mathrm{MAX}) - 10 \cdot \log_{10}(\mathrm{MSE})\ dB.$ with $\mathrm{MAX}$ being the maximum gray-scale value (...
For a certain parameter $k$, is the algorithm with the running time of $O(k.n^{\log{n}})$ in class $FPT$? I would appreciate if you can kindly guide me through.
If there's no deletion, we can use $2$ balanced trees to maintain $2$ half convex hulls(up and down). In this way, we can insert $n$ points in $O(n\log n)$ time.(In the beginning, there are no points) A completely dynamic convex hull means that I can insert and delete a point without rebuilding the whole convex hull, w...
I'm studying $\lambda$-calculus and came across a problem that I'm not sure how to understand. More specifically, it's about evaluating $\lambda$-calculus expressions using $\beta$-reduction. I was taught that the basic steps for performing $\beta$-reduction are to Find reducible expressions in the form of ($\lambda ...
Let $G$ be a graph such that $V$ denotes a vertex set and $E$ is an edge set of the graph $G$. Let us consider that for the input graph $G$ it is the case that $|E| \le O(|V| \log |V|)$. Given a graph $G$, I want to answer whether $(u,v) \in E$. If the input graph is given by adjacency representation then I can answer ...
This question is related to Amazon's QLDB, but my question is about the generic architecture of such a software system. The question arises from the fact that Amazon advertises the service as "highly scalable". System Definition So, let's forget about Amazon and dive into the abstract software system. We want to develo...
I am trying to find the total number of distinct minimum weight spanning trees(MWST) in a simple, undirected, unlabeled and weighted graph but I am confused whether should I have to consider Isomorphic trees(if it is present) as a single minimum weight spanning tree or not while counting the distinct MWSTs because grap...
It seems that there's no end to knapsack variations… here's the one I bumped into (at work): There are: N items, each with the usual value and weight properties. M bins, each with an upper bound and a lower bound on the total weight of the items that can be assigned to it. (That is, the total weight of the items assi...
Many sources for good software architecture will use objects, pointers, memory allocation in their solutions. The PLC programming language 61131-3 Structured Text is really limited in this regard, more like a limited version of Pascal. Reasons for this are often cited as i.e. safety and determinism. Here are some of th...
I apologise if this is not the right place for this question... I didn't want to ask on Stackoverflow or CodeReview as it will closed in minutes as "too broad". A client of mine is writing an API that takes a piece of personal-identifying information as the parameter in the URL, and has asked that the value is hashed u...
I'm trying to determine whether it is possible to decide if a system of $n$ linear equations with integer coefficients and $n$ variables has a solution in $\{0, 1\}^n$ in polynomial time. Additionally, all of the coefficients of $A$ are in $\{-1, 0, 1\}$, but I couldn't find a way to use that. The trivial case is if th...
Wikipedia lists the following algorithm for normalizing a lambda calculus term $t$: If $t$ is not in head normal form, beta reduce the beta redex in the head position to get $t'$. Then normalize $t'$ to get $t''$. $t''$ is the normal form of $t$. If $t$ is in head normal form, normalize each of its subterms to get $t'...
I'm currently learning some things about BSS RAMs. For sake of simplicity, please imagine them as a Turing machine over the reals. Now, this machine gets some real numbers as input. The input values form nearly a string, but are not of finite length as decimal representation. Additionally, there are infinitely many rea...
Consider this problem: you are searching an array of elements and are comparing the square of the current element to some number K. Essentially, you are looking to see if the square root of K is in the array. With this algorithm, chances are, you will not search the entire array because you will either find the square ...
Suppose $G$ is a connected graph and $S$ is a vertex cover. Prove that $S$ is also a dominating set. Can I get some help with proving this? I know that a dominating set in an undirected graph $G=(V,E)$ is a subset $S$ subset of $V$ such that every vertex is either in $S$ or has a neighbor in $S$. I know that a verte...
This question is about file-hashing/fingerprinting algorithms (similar to SHA-1 and MD5 and so on). Those algorithms are handy because they give you a small (and fixed-sized) hash code for any file, which can be later used to efficiently determine if that file is different from another file, and (if we are willing to ...
I have recently read that turing machine can be remodeled to perform as PDA now, i have a question that since DTM = NDTM ( non deterministic Turing machine) then every DTM can remodeled to be NDTM thus taking same analogy to PDA , we have DPDA = DTM( remodeled) = NDTM = NPDA thus creating DPDA = PDA . there is no debat...
I'm trying to show that the language {(m,n)|m has exactly n divisors} is in NP. The input (m,n) is in binary. The non-deterministic Turing machine for the language would be: 1) Guess the prime factors of m. 2) Verify that ∏i(di+1)=n. The problem is that I can't find a way to factorize in polynomial time (in the input) ...
I tried looking this problem up for quite a bit now, but can't seem to find a whole lot of discussion about this. At first it sounded like the TSP to me, but I don't think so (it's much harder to do I believe). Maybe I am over thinking this though? I'm not looking for the fastest solution, but I fear a brute-force algo...
Undirected graph is given which has M edges and N vertices we have to convert every edge from u−v to u→v or v→u such that the total outdegree of every vertex is even. For example, consider a graph which has the edges 1-2, 1-3, 2-4, 3-4. We can direct it as 1→2, 1→3, 2←4, 3←4, so outdegrees of 1,2,3,4 are respectively 2...
I've been asked to solve this problem, but I'm completely stuck now. Is the set $\{G \in\text{CFG} \mid L(G)\supseteq L(A) \}$ where A is DFA fixed beforehand decidable? I know I've to find a reduction, and as a hint they told me that it is related to Acceptance Problem or Post Correspondence Problem, or probably wi...
Consider the following languages: $$ \begin{align*} L_1 &= \{ 0^p 1^q 0^r \mid p,q,r \ge 0 \}, \\ L_2 &= \{ 0^p 1^q 0^r \mid p,q,r \ge 0, \; p \neq r \}. \end{align*} $$ Which one of the following statements is false? A. $L_2$ is context-free. B. $L_1 \cap L_2$ is context-free. C. $\overline{L_2}$ is recursive. D. $\o...
Is it true to say that $\Sigma^* \cdot$ {$a^nb^n: n>=0$} = $\Sigma^*$ Becuase if we take $\Sigma^*$ and concatenate it to {$a^nb^n: n>=0$} we don't get any "new" words than those we had in $\Sigma^*$ in the first place.
Let's say we want to build data structure able to perform two operations. First one, query is asking for the sum of values in the range $[i, j]$. And the second one, the update is setting all values on the range $[i, j]$ to have value $1$. On the beginning all elements of the array are $0$. What is the fastest data str...
Can someone explain to me if this is true or not?
Whenever a caller or client modifies a library collection class, all iterators are made invalid (with the exception of the iterator through which the change was made, in the case of remove). Give a reason for this rule in the case of an array list (using a dynamically sized array, in which an iterator has a pointer to ...
Let relational schema R(A,B,C,D,E,F,G,H,I). The functional dependencies are: A -> BC, AD -> BE, C ->F , A->F , D-> E Find the number of non-trivial functional dependencies ? I know that R has only five non-trivial functional dependencies but i do not know how to prove this(How to think)?
I am having a hard time understanding if this would be true or false, can someone point me in the right direction?
If this question is completely garbage I apologize because I am new to CS and haven't understood at how programming languages (Python specifically) work. I was reading about how in a standard two-byte representation of a number, if one was to increment 65,536 times, the integer would wrap back to one. Would this case o...
I run a testing application that, using Selenium, runs testing "scenarios" each of which visits a bunch of pages on a website. Each page is modeled by a Java file that contains locators, each of which are used to locate certain elements on the page maybe to verify that they exist or, beyond that, that they work as inte...
What would be a regular expression for the language of words containing a single 1 and an even number of 0s?
Consider $\mathsf{REGULAR_{TM}} = \{\langle M \rangle \mid \text{$M$ is a TM and $L(M)$ is a regular language}\}$. Let $S$ be the following algorithm, which solves $\mathsf{A_{TM}}$: “On input $\langle M, w \rangle$, where $M$ is a TM and $w$ is a string: Construct the following TM $M_2$: $M_2$ = “On input $x$: If $x...
If I know that problem $A$ is NP-hard, but know nothing of problem $B$ and I know that the following Karp reduction is true: $$A \to B \, .$$ Is it correct to conclude that $B$ must also be NP-hard?
Here is exercise 1.5.15 in Algorithms 4th Edition by Robert Sedgewick and Kevin Wayne. Show that the number of nodes at each level in the worst-case trees for weighted quick-union are binomial coefficients. Compute the average depth of a node in a worst-case tree with $k = 2^n$ nodes. Here are my questions: 1) What i...
Can we use recursive algorithm to find the greatest element of a finite list when numbers are unsorted. How to use recursive algorithm to find the least element of a finite list of unsorted numbers where repetitions of number is allowed. How can Mergesort calls itself n^2 times on a list with n numbers. Is it true if...
Suppose there is a statement - Some students in this class has visited Mexico. Solution given is: considering the universe of discourse for the variable $x$ consists of all the people. Our solution becomes $\exists{x}[S(x)\land{M(X)}]$ where the predicate $S(x)$ tells $x$ is a student in the class and $M(x)$ tells $x...
It is given that for a relation R all the attributes of the relation appear in some of the candidate keys. It is also given that there is only one compound candidate key which exists for a relation, all the other candidate keys are simple candidate keys. What can be said about the normal form of R? In my opinion, since...
The wikipedia page on computational resources states that there are many different resources that have been defined: In computational complexity theory, a computational resource is a resource used by some computational models in the solution of computational problems. The simplest computational resources are computati...
Is there a data structure or an algorithm or a combination of both to allow me to filter a set of documents based on the number of missing words (compared to another list)? Problem Definition We have a list of documents $D = \{d_1, d_2, \dots, d_n\}$. Each document $d_i$ consists of a subset of words from a word pool $...
The requirement is that two adjacent vertices have different colors, and max. 42 colors. I show that $ \text{42-COLOR} $ is in NP and then I must reduce it from $ \text{3-COLOR} $. Here it becomes complicated. Is it similar to $ k\text{-COLOR} $ for any $k$?
I got that I can get (1) followed by not (1) like this $$ (0+2)^*1(0+2)^* $$ From this point I'm actually stuck. I can't set the (0) to be somewhere in expression. The only expressions I get are ambiguous (where I can get the same word different ways from regex) and quite long. Is there more elegant and right way to w...
I am confused about how denormalized numbers work in floating point representation. I was referring to Stallings book and this article. The book initially explains floating point number format in general and then explains IEEE 754 floating point format. I will tell explicitly when I am talking about floating point form...
I could not figure out an efficient way (better than $O(n^2)$) to count the number of contiguous subsequences of an array of both positive and negative integers summing up to a given number $k$. For example, if $A = \{2,5,6,-1\}$ and $k = 5$ then the answer is $2$, since both $5$ and $6,-1$ sum to $5$.