instruction
stringlengths
35
29.1k
What are some examples of non-enumerable languages whose complement isn't either? I.e., a language L such that L is not Turning-recognizable and L’ is not Turing-recognizable either. Update: Found some examples: Is the below language Non R.E?
I was watching video Lec 2 | MIT 6.046J / 18.410J Introduction to Algorithms (SMA 5503), Fall 2005, where professor Erik Demaine said that $a^{\log_b n}$ is the same as $n^{\log_b a}$. Can someone please explain me why bringing "the $n$ downstairs" and "the $a$ upstairs" is possible?
I need to write a function that gets an array of numbers $a$ as an input and returns an index $i$ such that $a[i]<a[i+1]$ if it exists, if such $i$ doesn't exist return $-1$. (return any index $i$ if there are multiple). We know that: in $a$ there are at least $2$ elements, $a$ may or may not be sorted and the first e...
In Arora and Barak's textbook, in chapter 18, p.366-367, they prove the following theorem: Theorem 18.7 if $(L,D)$ is reduced to $(L',D')$ and $(L',D') \in disP$, then $(L,D) \in disP$ The proof goes by just following the definition of average-case reduction and disP. I.e., suppose there is an efficient algorithm $A'...
in my Complexity class I have to present the 1/2 MaxSat approximation algorithm that appears in the Vazirani, Vijay V - Approximation algorithms-Spring (2011) [Image attached]. The problem is that it is not clear to me where and how the weights are assigned. The example talks about considering the weights as a unit but...
I saw this question on the internet and found many solutions actually but none of them really persuade me that much. Question: Given language $L$ which is accepted by a Turing machine $M$, provide a 2-PDA that describes $L$. End of the question. Note: A Turing machine is given by $M=\{Q,\Sigma,\Gamma,\delta,q_0,q_{acc...
An alternative way of deciding within a nondeterministic complexity class is to present a verifier-prover pair. To recall, let $\mathsf{L}$ be a language, and let $\mathsf{w}$ be a word. To decide whether $\mathsf{w} \in \mathsf{L}$: The prover, a magical machine, will immediately find a proof that $\mathsf{w} \in \ma...
Are Unit Tests Required if you have a good End to End Test? If you find problems, couldn't you always just update the end to end test to make it more robust?
I'm looking at a problem similar to an assignment problem. There are both agents and tasks. Each agent has a list of tasks they are able to do, and cannot do any task not within that list (note that agents do not have a preference for what task they do, only a list of tasks they are able to do). A task can be assigned ...
If $A$ and $B$ are languages, let $A\bowtie B$ denote the set of strings made by concatenating any word from $A$ and any word from $B$ of equal length. $$A\bowtie B \equiv \{ ab : a\in A,\;b\in B, |a|=|b|\}.$$ You can prove using regular grammars that if $A$ and $B$ are regular, then $A\bowtie B$ is context free. I am ...
I was watching video 7. Binary Trees, Part 2: AVL, where professor Erik Demaine stated that $$2N_{h-2} = 2^{h/2\text{ (or maybe with floor or something... maybe it's ceiling)}}$$ where $N$ stands for the number of nodes in a subtree of height $h-2$. Can someone explain me in more detail why this recursion can be solved...
Is there a communication protocol that ensures that both parties can read the other one's message at the same time (or at the very least, only after sending their own message, thus no party can read a message and then send their own).
In the operating systems that make use of the execution-time address binding who is responsible for the creation of logical addresses? EDIT I'm thinking that the logical addresses are generated by the compiler and are included in the relocatable code
With C# I can convert an array of bytes to a decimal value: //F4 6C 56 7D AE C6 4B 40 var bytes = new byte[] { 244, 108, 86, 125, 174, 198, 75, 64 }; var value = BitConverter.ToDouble(bytes, 0); //=55.5522 I would like to know how this works and be able to express it by hand on paper.
Exchange sort is similar to selection sort, just swaps "overly eagerly" instead of finding the minimum and doing only one swap. And the swaps affect how often the if ... is true. For example for 8000 random numbers, in exchange sort it's true ~270 times more often: trues in trues in n exchangeSort sel...
I recently submitted a paper where in part of the paper I derived a bound on a function (note it is an upper bound). The benefit of the bound is that it is much less complex to compute in contrast to the actual value of the function. So, the bound can be used as a cost for optimization instead of the actual value of th...
Say that a Context Free Grammar is red when it accepts every word of length 3 that begins with a, and extremely red when it accepts every word that begins with a. Is redness decidable? or Semi decidable? will the algorithm go into an infinite loop when presented with certain invalid statements? Also what about extreme ...
The question will be hard to understand without an example, so let's given an example first: Let's say I have a 2 dimensional concave polytope, defined by a circular sequence of its vertices: $(0,0), (1, 4), (2, 0) (1, 1), (0, 0)$ Let's say I wanted to find the polytope I get if I considered only points s.t. $y>=0.5$,...
Pumping Lemma : For any regular language $\mathbb{L}$, there exists an integer $n$, such that for all $x\in \mathbb{L}$ with $|x|\geq n$, there exists $u, v, w \in \Sigma^*$, such that $x = uvw$, and $|uv| \leq n$ $|v| > 0$ $uv^iw ∈ \mathbb{L} \space\forall i\geq0$ My question is, what exactly is the "Pumping Length"...
An accountant in a big firm would like to find the median of the salaries of all employees. The data they received is a list of size n containing the tuples $\left\{s_{i\ },f_{i\ }\right\}_{i=1}^{n}$, where the number $s_i$ is the salary and the integer $f_i$ is the number of employees that got salary $s_i$ in the fir...
So I am studying PTAS algorithms. For a maximazation problem the difinition says that an algorithm that has value A , is a ptas if : $A \geq opt(1-\epsilon) \; ,\forall \epsilon > 0$ (and I guess also $\epsilon < 1$ (?) ) Obviously for any constant $c>0 : opt(1-\epsilon) \geq \frac{opt}{c}(1-\epsilon)$ So when I prove...
I was looking at an example of grammar from the website: grammer example which is as follows: S → aB / bA S → aS / bAA / a B → bS / aBB / b I believe they forgot to write: A -> a Next, we are going to derive the string: aaabbabbba I did it by myself and found the following: Left derivation: S -> aB -> aaBB -> aaaBBB ->...
I have a set of line segments (say 1000 of them) and a query point. I want to find the segment which is the closest in the Euclidean sense (if the point does not project on the segment I accept two options: 1) just ignore the segment - infinite distance - or 2) consider the distance to the closest endpoint). Preprocess...
This is a problem that I have found from Introduction to automata theory, languages and computation by John Hopcroft and Jeffrey Ullman. PDA P=({q0, q1, q2, q3, f)}, {a, b}, {Z0, A, B}, δ, q0, Z, {f}) has the following rules defining δ: δ(q0,a,Z)=(q1,AAZ) δ(q0,b,Z)=(q2,BZ) δ(q0,∈,Z)=(f,∈) δ(q1,a,A)=...
I'm trying to solve following modified knapsack problem using dynamic programming. What we know: Total number of items Item weight, value and type Knapsack capacity Aims Find Maximum weight of knapsack List taken Items Constraints Only one item of each type can be taken For example, in my problem, the item list w...
Hello I am struggling with proving a lemma, it goes as follows: Suppose we have a vector r = (r1....rn)^T where rj is either 0 or 1 which is selected uniformly at random with probability 1/2. Suppose now we have a n x n matrix called M (which has at least one non zero element). I need to prove that the Pr[Mr = 0] <= 1/...
Suppose a real-valued function class $\mathcal{F}$ with pseudo dimension less than $d$, I am wondering what is the pseudo dimension of the following function class \begin{equation} \mathcal{F}_2 = \{\min(f_1, f_2), \text{with } f_1,f_2\in \mathcal{F}\} \end{equation} where for any $x$, $\min(f_1, f_2)(x) = \min(f_1(x),...
I understand why L2 is not a regular language. We can use the pumping lemma to prove it In the case of L2: assume n = 1 and string = ab We assume that L2 is regular, so it has "pumping length" property and it can be divided into 3 strings, x = empty string, y = a, z = b Now we pump y, so after pumping once we get the s...
I try to determine if the following statement is true: for any given language $L \subseteq A^*$ if $L$ is a context-free language then $L_1 = \{u^Rv^R \ | \ uv \in L, |u|=|v| \}$ is also a context-free language. Initially I tried to come up with a counterexample but now I start to believe this statement could be true. ...
For open addressing, I know that once you have around 70% table being filled you should resize because more than that you get collision. But for closed addressing, I read that load factor should not exceed 1 (m/n where m = number of items in the buckets and n = size of the table) otherwise trigger rehashing to grow the...
What is the most efficient data structure for a dynamic set of words over a finite alphabet $\Sigma$ which supports the following operations? Add a word. Remove a word. Determine a shortest word which is not in the set. Does it help if all words have the same length? A real world example: I was thinking about link sh...
Case:1 Suppose l have one DFA which accepts the set of all strings over {a, b} which starts with aand it's complement is not starts with a. From the above image we see that in the second diagram represents the DFA which accepts the strings which belong to complement of the language accepted by first DFA. Case:2 Now co...
Im trying to build my own learning track Currently I am working on becoming a unity developer to make game or whatever is needed. I use C# within the system. I don't feel satisfied just working within the engine and want to make my skills more broad and flexible to be able to solve a wide number of problems. if someon...
I am having a hard time to prove it, what i know is we cannot prove that a language is regular by using pumping lemma cause even if the "pumped string" is in the language the language could still be regular. But since we already know that ww^r is a context free language cause we can design a pda for it, we should be ab...
the expression "graphs" in the title refers to graphs as they are thought in computer science: Let G = (V(G), E(G)) be a graph. It is a tuple with a set of vertices and edges.
Assume a bloom filter that is composed of $H = \{H_1, ..., H_k\}$ hash functions, and uniformly maps elements from an input set $X$ to an array $A$ of size $n$. Let $X_1, X_2$ (not same) be two input sets of size $m$. After applying the same bloom filter to both input sets, we receive the arrays $A_1$ and $A_2$ (both o...
Let's say there is an unfair coin with $P[head]=p$. We do not now $p$ but we know that $p \geq a$ for a known $a$. After $n$ trials we get $bn$ heads. Now, we want to estimate $p$ so that $P[|p-b|\geq gp] \leq \epsilon$, where $g, \epsilon$ are known Here is what I have got so far: We know that $\mu = np$ not sure i...
I have the following problem: Let Alice and Bob be two people playing games. Alice and only Alice owns a special device, Robo, that is capable of generating one truly random number $k \in \mathbb{N}$ per game, within any range given by Alice at some moment of the game. The game Alice and Bob decided to play today ta...
I would like to show a language is in not recursive (not in the family $R$) without using a reduction from a language that is known to be non-recursive. In other words, its as if I am discovering the first non-recursive language. I have 2 languages I would like to show it for. These are: $L_{AC}$ - the pairs $\left<M,...
In 1949 Shannon proved, using a non-constructive counting argument, that some boolean functions have exponential circuit complexity, see [1] and many texts on computational complexity. This result has been strengthened later, showing that, in the limit, almost all boolean functions have exponential circuit complexity. ...
I know that for $n \times n$ matrix, it takes $O(n^2)$ time complexity to compute the largest eigenpair of the matrix using Power method or etc. I'm interested to further extend the case so that now we're interested in finding $d$ largest eigenpairs, but for a "symmetric" matrix. What is the time complexity of this alg...
I'm trying to gain a better understanding of Big O. Here is something that I'm unsure about. Say we have an array containing N elements that is inputted by the user. From my understanding iterating over each element from this array gives O(n) as we are looping over the array N times. Now we do the same thing, we iterat...
We know that $L = \{ xy | x, y \in (0 + 1)^*, |x| = |y|, x≠y\}$ is context free. But my question is how we check $x ≠ y$ in $PDA?$ For example $x=0^n1^n$ and $y=1^{2n}.$ We can easily draw $PDA$ by checking one $0$ against three $1s$ but how can we check $x ≠ y?$
In shannon capacity, it uses log operation. bandwidth * log2(1 + SNR) Why they use log operation instead of just using SNR?
I have to find equivalence classes for different languages based on Myhill-Nerode. I'm struggling a little bit finding these equivalence classes; for example, the language $L=\{b^*a^n\mid n≡0\pmod5\}$ with alphabet $\{a,b\}$. My first solution would be: $[\epsilon],[b^∗],[b^∗a],[b^∗aa],[b^∗aaa],[b^∗aaaa]$. Would these ...
I am a student want to study randomized algorithm. Someone recommend cs271 to me, but it's restricted now. Can someone recomend a good resource to study randomized algorithm, thank you a lot.
Can we determine in polynomial time if the language accepted by an NFA is infinite? The case of DFA is simple, but converting an NFA to a DFA may take exponential time. Also, I ran into this post, Determine if an NFA accepts infinite language in polynomial time. But there is no solution.
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,\cdots,x_n \\ U...
Suppose I have a variant of the knapsack problem: $$\max_{x} \sum_{i=1}^n v_ix_i$$ $$(\sum_{i=1}^n w_ix_i - W)^2 \leq k$$ for $v_i, w_i \in \mathbb{R}$, $x_i \in \{0,1\}$ and $k \in \mathbb{R}, k > 0$. Is it known if the decision problem $\sum_{i=1}^n v_ix_i > V$ for some $V$ is NP-Complete?
I've been going through some questions on old homework. Here was a question that confused me somehow. Question: Given a language $$L=\{\langle M\rangle\ |\ M \text{ is a Turing machine. } M \text{ goes through some configuration } (q,s,i) \text{ infinite times on input } \epsilon\}$$ determine whether it's decidable, i...
Consider a deterministic finite automaton $M(k) = (Q, Σ, \delta, 0, F)$, with $k ≥ 2$ and $Q = \{0,1,...,k-1\}$ $Σ = \{0,1\}$ $\delta(q,a) = (q+a) \space mod \space k$ $F = \{0\}$ If $L$ is the language recognised by $M(k)$, describe a deterministic finite automaton that recognises the concatenation $L ⋅ L ⋅ L ⋅ L ⋅ L ...
I came across the below question where the polynomial time solution to the "Set Cover Problem" is discussed when the subsets are of size EXACTLY 2. Set cover problem with sets of size 2 The solution described involves constructing an Edge Cover for a slightly different graph (Create a graph of keys and each edge links ...
I'm having a problem with an exercise, I'm supposed to calculate the exact worst case runtime and the worst case runtime in Big O Notation for a given algorithm. This is what I'm struggling to understand, I think I know how to recognize what's the runtime using the big O Notation as it's only a nested loop but what ...
From my understanding, a CPU register is a temporary storage or working location built into the CPU itself. The CPU includes some functional units such as the ALU (which is part of the chip, as far as I know). In a 64 bit architecture, we have 16 general purpose registers, that seem to be often used in ASM programs to ...
Background In the classic formulation of the knapsack problem with both weight and volume constraints, we are given a collection of $n$ items where item $i$ has weight $w_i\in\mathbb{N}$, volume $u_i\in \mathbb{N}$, and value $v_i\in\mathbb{N}$. We aim to fill a bag with weight capacity $W$ and volume capacity $U$ such...
In the MTD-f algorithm: function MTDF(root : node_type; f : integer; d : integer) : integer; g := f; upperbound := +INFINITY; lowerbound := -INFINITY; repeat if g == lowerbound then beta := g + 1 else beta := g; g := AlphaBetaWithMemory(root, beta - 1, beta, d); if g < beta then ...
Suppose I have a set of N*L elements. I wish to generate a sequence of k partitions of size L such that I maximize the number of pairs of elements that share membership of the same partition. What kind of algorithm would optimize this? To make it easier to understand, imagine an icebreaker situation: Suppose I have a n...
More out of curiosity than anything else. I know you can always generate a list of random numbers and then sort it, but I was wondering if there exists a (pseudo)random number generator whose output is already in sorted order? I found this, but it and everything else I found only generates integer lists. Is there an eq...
I want to prove that the language of all regular expressions is not a regular language. I'm having trouble to approach this problem. I thought maybe to show that the parenthesis language is a part of it, and then I can rule out the regularity.
In Michael Sipser's Introduction to the Theory of Computation, Example 1.56 shows how to convert $\left(\text{ab }\cup\text{ a}\right)^*$ to an NFA. It builds up from the smallest subexpression to larger subexpressions until the required NFA is obtained: My question is: why is the NFA to recognize $\text{ab}$ not a si...
Graph Homomorphism is a well-known NP-complete problem. Given graph $G$ and $H$, $G$ is said to be homomorphic to $H$ if there is a mapping $f: V(G) \mapsto V(H)$ such that $(u,v) \in E(G) \implies (f(u), f(v)) \in E(H)$. The mapping in above is unrestricted -- and hence, multiple nodes of $G$ can map to a single node ...
I'm trying to flip a triangle like this in the following image: there are two constraints in flipping it: 1- flip it with the minimum circles moves 2- the circles is sliding from a place to another and can't jump over another circle. 3- the circle can move vertically or horizontally 4- the circle can move any number ...
Let us be given a function $f(x_1,\dots,x_{10})$ of multiple variables $x_1,\dots,x_{10}$ given that $\sum_{i=1}^{10} x_i \leq 7$. How do we solve the following problem? $$ \begin{equation} \begin{aligned} \max_{\{x_i\}, i=1,\dots,10} \quad & f(x_1,\dots,x_{10})\\ \textrm{s.t.} \quad & \sum_{i=1}^{10} x_i \leq 7\\ & ...
I need to define a grammar for $L=\{a^ib^ic^jd^j| i \ge j \ge 0\}$ as I wasn't told about any restrictions for the grammar, e.g context-free or context-sensitive, I assume any derivation rules can be used here. Because the number of $a$s and $b$s is greater than, or equals to, the number of $c$s and $d$s I have this fi...
How would one count the amount of solutions to quantified formulas that have universal quantifiers? For example, for a boolean formula $\Phi(X)$ with a number of solutions $\#\Phi(X)$ let's construct a quantified boolean formula $\forall y \ \exists X: y \lor \Phi(X)$. In this case $X$ represents $n$ boolean variables....
I have been unable to find any literature on average-case complexity for coNP, other than a folklore conjecture that most tautologies are hard for any given propositional proof systems and some analysis of random k-SAT refutation. Am I missing something? Is the following not a simple characterization: no paddable coNP-...
You can refer the problem on later part of section 4.1 in "Algorithm Design Book by Jon Kleinberg and Éva Tardos" Problem: We have "n" lectures and we our job is to assign all of the lectures using least amount of classrooms Let d be the list of resources required, initially we would have resources equal to "n" cause a...
I am trying to figure out the time complexity for "Regular Expression Matching" problem. Problem statement is simple, only meta characters allowed are '.' and '*'. Actual problem statement can be found in Link The solution is in java and I have solved it using memoization, but having difficulty to compute the time comp...
Hello, Im new to learning epsilon nfas, and I have been wondering if we could leave certain epsilon transitions out, and if so would it still be a valid epsilon nfa? For example regarding the image, couldnt I just delete the marked epsilon transition and the state that it leads to, thus only having the unmarked epsilo...
I am a little confused when it comes to linear boolean functions. According to this post: What is a simple way of explaining what a linear boolean function means in boolean algebra and relating it to the standard definition of linearity? We have that a function is linear if: $$f(x \oplus y) = f(x) \oplus f(y)$$ which (...
For a language $\mathcal{L}$ over an alphabet $\Sigma$, define $$\mathcal{SW(L)} := \{ y ∈ Σ^∗ \mid \exists x \in Σ^* \text{ such that } xyx \in \mathcal{L}\}$$ How can I prove that if $\mathcal{L}$ is regular, then $\mathcal{SW(L)}$ is also regular?
If $R$ is an arbitrary decision problem that is reducible to $S$, which is an NP-complete problem, what can be said about $R$? I think we should be able to say that $R$ is in NP since an instance of $S$ can have a certificate verified in polynomial time and from the reduction $R \le S$, we could say the same about $R$....
Let $α \in [0, 1)$ be a constant. For a rooted binary tree $T$ and a node $x$ in $T$, we denote by $|x|$ the number of nodes in the subtree of $T$ rooted at $x$ (if $x$ = $NIL$ then $|x|$ = $0$). We say that $T$ is $α$-good if, for every node $x$ in the tree with children $y$ and $z$, it holds that $|y|$ − $|z|$ ≤ $α|x...
Summary. A data structure maintains in constant time a sorted list of counter values, for a dynamic set of counters. I am interested in references using this structure, and in possible improvements. Problem and motivation. Consider a set of counters that may be increased (by 1), decreased (by 1), deleted (when at 0), ...
I was recently reading about Fourier dimension of Boolean functions. What I understand is that if we take the Fourier expansion of $f: \{\pm1\}^n \to \{\pm1\}$ and consider the monomials with non zero Fourier coefficients as vectors in $\mathbb{F}_2^n$, then the Fourier dimension is the dimension of the span of these v...
Recently I studied a MIT open course. In lecture2, it is stated that Rectangle Packing is NP-hard. I can understand this because the problem can be reduced to 3-partition problem But I don't know why it's an open problem whether it's in NP. In lecture2 it is stated that: it is complicated to encode rotations efficient...
I have an interesting problem I need to solve. I have a list of about 200k two player matches containing about 22k unique players. I need to find the largest set of players that never played against each other. The first approach I did: pair each player with a set of players he played against sort them by number of pl...
Consider a rooted tree $T$. A matching in $T$ is said to be proper if for every unmatched vertex $v$ it holds that the parent of $v$ is matched to one of the siblings of $v$. It is known that every tree admits a maximum-size matching that is proper. Consider a rooted tree $T$ over a set of vertices $V$ and a proper mat...
The following problem is based on the section about dynamic table as part of the discussion about amortized analysis in CLRS Problem: We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that when the ar...
I am trying to understand the concept of synchronised DFAs. I have a question where all the states in the DFA after reading that particular word from the alphabet will reach a particular state with the alphabet (A to Z). And I should prove that a language which accepts any random number of alphabet combinations followe...
Set theory depends on a set membership function $\epsilon$ which is a class of ordered pairs. Is it possible to construct the ordered pair from an undirected graph of unordered pairs? Alternatively, is there a way to construct a undirected graph that represents a directed graph? The graph may be traversed from either...
In class we were talking about the decidability and acceptability of languages by Turing Machines but a doubt arose in my mind, "is any language containing a finite number of strings decidable by Turing Machines?" My first answer could be no, since there are finite languages that are undecidable.
Now, $\color{blue}{\text{Exponentiation}}$ is defined as Exponentiation is a mathematical operation, written as $b^n$, involving two numbers, the base $b$ and the exponent or power $n$, and pronounced as "$b$ raised to the power of $n$". $$b^n = \underbrace{b\times b\times\cdot \cdots \times b}_{n\text{ times}}$$ No...
i recently have been practicing constructing Turing Machines for languages. But i can't seem to figure this one out. I've seen a few videos on constructing 3 equal length strings (a^nb^nc^n) But i can't figure out this one. Can anyone help out how i can do this. Please don't give the answer outright, i want to actually...
Consider a variant of the TSP problem where the cost function $c$ is not only symmetric but also satisfies $c(u, v) ≤ 2c(u, w) + c(w, v)$ for arbitrary vertices $u, v, w ∈ V$ . Give a polynomial time algorithm that achieves a constant factor approximation ratio for this problem. I think the algorithm itself is the same...
Consider the following problem: Input: A Turing Machine M and a DFA D. Question: Is $L(D) \subseteq L(M)$? Of course, this problem is not decidable. Because it is known that judging whether a word belong to a Turing Machine is not decidable. If this problem is decidable, then we can write the word as regular expres...
How can the result of the execution of $ \rightarrow RL$ differ from that of $\rightarrow LR$? In turing machines
Are there other advantages to linked lists over arrays other than constant time removals of the first element?
For one dimensional, continuous binary search most effective algorithm would remember boundaries. For example if boundaries are 0.7 and 0.9, point to check would be 0.8. And if result is 'too small', then boundaries become 0.8 and 0.9, and point to check is 0.85. This algorithm is fast and simple. But it doesnt do well...
Suppose that we're given a connected, undirected graph $G = (V, E)$ with edge weights $w_e$ and a subset of vertices $U \subset V$. We want to find the lightest spanning tree in which the nodes of $U$ are leaves (they may be other leaves as well). We want to do so in $O(|E|\log(|V|))$ time. I was reading: Spanning tr...
I am creating a tool for validating, parsing, and interpreting flowchart diagrams on diagrams.net, and it is necessary to give users an opportunity to define a set of rules for the diagram. So, in the end, I want to achieve something like ANTLR for diagrams with the following features: Some kind of DSL for defining pa...
Given an array of characters, I need to delete all the characters that got repeated 3 or more times (consecutively) and add '0' at the end of the array for every deleted character, The restrictions: $O(n)$ time $O(1)$ memory Can't overwrite a cell in the array more than once Examples: "aacccbbddde" --> "aabbe000000" ...
Let $G=(U, V, E)$ be a biparite graph, with $U$ and $V$ being the two sets of nodes. I am trying to find the smallest set of nodes $\hat{V} \subseteq V$ such that, for every node $u \in U$, $\hat{V}_u$ contains at least one element and is different from $\hat{V}_{u'}$, $\forall u' \neq u \in U$, where $V_u \subseteq V$...
According to Exponential Time Hypothesis there does not exist a deterministic algorithm to solve SAT over $V$ variables in time $o(2^V)$. However, let's say the number of literals $n = \omega(poly(V))$. The real input size in the worst case is $\Theta(n)$, therefore for an asymptotic analysis one can assume $n$ to be t...
I have been struggling for a few hours in terms of finding the right solution for the following problem: Suppose we have a file that contains integers where each represents a user of a service. By reading that file we want to find how many times the service was accessed and by how many different users. My code should ...
I have two set of points in the plane or space, which could be for instance radar contacts over two successive scans. I'd like to pair them so that the sum of squared distances is minimal. One difficult case, if for instance there is a serie of aligned and equidistant points in the first set, can be found in the second...
Problem You are given two integer arrays nums and multipliers of size n and m respectively, where n≥m. The arrays are 1-indexed. You begin with a score of 0. You want to perform exactly m operations. On the iᵗʰ operation (1-indexed), you will: Choose one integer x from either the start or the end of the array nums. Ad...
I have a metric space $(V,d)$ described by a tree $T$. And I have $k$ pair of vertices $\{s_i,t_i\}$ ($i \in [k]$) s.t. each of the vertices $s_i$ and $t_i$ are leaves of $T$. There is a car at one of the leaf $s$ of $T$. The car has to deliver a package from $s_i$ to $t_i$ (for each $i$). But at any time the car can ...
I am a bit confused in the following definition: what does comma mean. I know I(X;Y) is the mutual information between X and Y but I am not sure how to interpret the I(X_1,X_2;Y)).
Bentley, J.L. [1977]: Solution to Klee's rectangle problems, unpublished manuscript, Dept. of Computer Science, Carnegie-Mellon University, 1977. Is it classified or not archived at all?