instruction
stringlengths
35
29.1k
I'm looking for implementations of approximation algorithms (or algorithms that would be meaningful to implement for use in practice) for the minimum-cost multicommodity flow problem as defined in e.g. Section 2.1 of Andrew V. Goldberg, Jeffrey D. Oldham, Serge Plotkin & Cliff Stein An Implementation of a Combinatoria...
I am trying to build a parser for lambda expressions. I have implemented a capture-avoiding substitution using the algorithm below ($e[d/x]$ means replace $x$ by $d$ in $e$) $x[d/x] = d$ $y[d/x] = y$ if $x\neq y$ $(e_1 e_2)[d/x] = (e_1[d/x) (e_2[d/x])$ $(\lambda x.e')[d/x] = \lambda x.e'$ $(\lambda y.e')[d/x] = \lambd...
I have found that when drawing two trees having different structures, we can get the same in-order sequence and pre-order sequence. But I haven't found if two different binary trees can have an identical post-order sequence. Is it possible?
This is probably a computer science history question. Is there an algorithm which was originally invented to solve a contrived problem but later found practical use?
Question Description I’m facing a problem asking me to construct a (deterministic) Turing Machine that can accept such a language: $L = \{ w \in \{a,b\}^* \mid \mbox{for any non-empty prefix $w'$ of $w$}, n_a(w') > n_b(w')\}$ The problem isn’t expressed in English originally. To make sure I’m translating correctly, I’l...
I am running a simulation on my computer. I tried to multiply two polynomials $g(x), h(x)\in GF(2)[x]$, with $degree(g(x))= 8165$, and $degree(h(x))=25$. This multiplication took almost $20$ minutes on my computer. Now, I have to multiply all $h(x)\in GF(2)[x]$ of $degree(h(x))\leq 25$ with $g(x)$. I estimated that it ...
Question: Given a language L, L = {⟨M, x⟩ | M(x) terminates with an empty tape}, show that Lu is m-reducible to L by finding a computable function f: Σ* -> Σ*, where for every w, w ∈ Lu if and only if f(w) ∈ L. (Recall Lu = {⟨M, x⟩ | x ∈ L(M)}) My general understanding of m-reducibility is that if you can assume there ...
Is it always possible to know if there's an equivalent Turing machine to a given machine such that it'll have a smaller number of states? (1-tape machine, minimizing it) My intuition says that finding such machine in the general case is not possible, but what about just knowing if there's a simpler machine? Is my quest...
To prove that a new language is Turing-complete the authors need to show that it can simulate any other (already known) Turing-complete language. I wonder what Turing-complete language is the simplest to simulate? Bitwise Cyclic Tag looks very easy. Are there better candidates?
I am looking for an algorithm to compute the furthest point Voronoi diagram and I don't seem to be able to find anything decent. The most complete one I have found are these slides and this terribly written wordpress site with a cool tool: But I am not finding any well written text explaining and proving an algorithm t...
I have a problem where I'm iterating through a series of tasks and each task requires that a specific file is loaded into memory. The files are not allowed to be unloaded until all of the tasks that use it are complete. E.g. say I have 6 tasks. I will represent each task as a Python dictionary where "files" indicates t...
Let's suppose we have language $Y = \{a^ib^j:i,j \in N^*\}$ defined over the alphabet $\Sigma^{}_{} = \{a, b\}$ If we want to define this language $\Sigma^{*}_{}$ \ $\ Y$ such that we don't have the case of $a$ preceding all occurances of $b$, one way I found it defined is like this: $ \Sigma^{*}_{}$ \ $\ Y = \{w_1baw_...
Imagine a Problem $A$ with input size $n$ for which you can get a proof certificate (polynomial number of bits). Next you try to use this string to verify if your problem is solved or not. You know that verification gets almost as good as if you'd try to verify an $NP$-problem in the sense that the verification process...
I've been working on this question for a few hours now and I've been trying to figure out the question above. My biggest problem is that I don't know what to do with the $>$ and $\geq$ symbols when determining the language. My current work is below. Also, if you have any resources on how to adequately learn pumping lem...
While working through the book Parameterized Complexity Theory of Flum and Grohe, I encountered exercise 1.42: Let $H = (V, E)$ be a hypergraph. A basis of $H$ is a set $S$ of subsets of $V$ with the property that for all $e \in E$ there are $s_1, \dots, s_\ell \in S$ such that $e = s_1 \cup \dots \cup s_\ell$. The par...
Given an array of N elements, I need to split it into k subarrays, where k can be between 2 <= k <= N. A sub-array's score is determined by: (left boundary point - right boundary point of the subarray)^2 + max(subarray). Left boundary point would be the index of the element and right boundary point would be the (index ...
I was solving a coding question which boiled down to this problem. Given a bipartite graph $G=\{V\cup U,E\}$. There is a positive value given for every node in $U$. Now we have to find the matching in which the sum of value of every node in $U$ which is also in the matching is maximum. Consider an example, Let valueAr...
Problem description: Given a P-time function(program) pchk:{0,1} ⃰ -> {0,1}. A function f, f:pchk×ℕ -> {0,1}: f can only simulate pchk with arbitrary argument x. And, f(pchk,n)==1 iff ∃x, |x|<=n, pchk(x)==1. Obviously, the time complexity of f is in O(2^N) (the length of pchk can be assumed a constant). f∈NP and f∉P....
We are running a restaurant. Unfortunately due to mysterious reasons, we cannot tell our chef what recipes to make, we can only prepare him the ingredients for the meals. Fortunately our chef has memorized all possible recipes, therefore if we carefully designate separate tables on which we put recipe ingredients (e.g....
I am solving a problem that involves finding a pow(x, n) without using a pow library function. Following is the algorithm that works (apart from negative n and some edge cases) but trying to understand the math logic behind it. 2^5 -> x = 2, n = 5 (101) The idea is to multiply the answer with 2 ^ (2 ^ i) such that i i...
According to O'Donnell's book ``Analysis of Boolean Functions", in order to determine the Fourier coefficient of a boolean function $f$ on a subset $S$, we take an inner product of $\chi_S$ and $f$ and then divide the result by $2^n$. In the paper by Beigel [1], a different formula is given. Specifically, $c_{S}^{fouri...
Given two disjoint rectangles $(a,b]\times (c,d]$ and $(e,f]\times (g,h]$ in $\mathbb{R}^2$ how can I check with a decision tree of least depth if a given point $(x,y)$ lies within the union of the rectangles? I think that I need 4 decisions to check if $x$ is within $(\min(a,e),\max(b,f)]$ and if $y$ is within $(\min(...
Why the following proof is invaid? Using C-like pseudo-program: Definition: bool S(Func, UInt): S(f,n)==true iff ∃x, x<=n, F(x)==true F is defined in ℙ as a certificate function, so S is in ℕℙ. Now, if S∈ℙ, then, there exists a function F∈ℙ: bool F(UInt n) { return !S(F,n); } Given an UInt m: If F(m)==true, t...
In the standard framing of the traveling salesman problem, we're given a complete graph, meaning every pair of vertices has an edge in between them. And this might be close to accurate when the salesman is flying between cities. If he's driving however, road networks tend not to be dense. You can drive from any city to...
In many computer architecture books (e.g. Computer Organization and Design), the memory layout that is seen by a program is as the following figure. But I wonder about multitask computers, in which many programs execute simultaneously, how the memory layout is. Is the layout actual or simulated for each program?
Given an ordered sequence of $n$ elements, you have to choose a family $A$ of subsets of consecutive elements, such that each subset of consecutive elements (not necessairly in $A$) can be represented as a disjoint union of at most $k$ elements of $A$. Let $A$ be the minimal set with this property, define the function ...
So, consider I have a toy imperative language which ofcourse supports assignment operations. I want to convert each statement of this language into an equivalent turing machine transition. So, the operation y:=x can where I have y and x spread out on a tape (with > marking the start and a trail if infinite $ marking th...
Given a list of intervals with integral endpoints, we want to find out if we can choose one integer from each interval so that no two chosen numbers are adjacent. Can we do this in polynomial time? My attempt is the following greedy strategy: Sort the intervals by the smaller left endpoint, breaking ties by the smaller...
During my self study for graphs, I'm currently learning about topological sorting and ran into a question I'm not sure how to solve. There are typically more than one order of a topological ordering for any given DAG. Some vertices will always be in the same index regardless of the ordering. Find a linear algorithm to ...
How clock rate is doubled in the Manchester encoding? clock cycle depends on bit interval time . In NRZ , Manchester encoding and every other Encoding the clock cycle time is same as bit interval is same. How it is doubled clock rate? ISRO | ISRO CS 2020 | Question 67 To send same bit sequence, NRZ encoding require (A)...
I'm trying to find a regular expression to describe the following language: $\{a^n xa^n | n≥1,x ∈ Σ^* \}$ where $Σ$ = {a,b} So far I've come up with $aa^* (aUb)^* aa^*$ but I don't think that accounts for $n$ being the same.
My Problem is having to work with real-time server in a DES model. I have the following situation: I want to build a discrete event simulation model (Using event scheduling world view). However, this model needs to be connected to another real-time program. Within this model, the event routines create next events based...
I've read that the number of distinct paths in a graph can be exponential in relation to the number of vertices, later I encountered a problem which I spent some time trying to solve on my own. The problem asks to find a family of undirected graphs in such a manner that every graph has a pair of vertices $s$ and $t$ su...
Today I am reading paper Unsatisfiable Linear k-CNFs Exist, for every k by Dominik Scheder, 2007. But I have some problem to understand the proof of Theorem $3.2$. I don't know how to understand the underlined part: How do we create variable-disjoint copies of $F$? Why is the number $2^m$? Theorem 3.2. For any $k\in...
I'm self studying complexity theory and want to prove that SAT is in NP, so I came up with this verifier for SAT: \begin{align*} V &= \text{"On input $w = \langle \phi, c \rangle$}:\\ & \quad \text{1. Test whether $c$ is an assignment for $\phi$} \\ & \quad \text{2. Test whether $c$ satisfies $\phi$}\\ & \quad \text{3....
We are learning about encryption (e.g. RSA) in class at the moment and our teacher told us about a paper he had read (and didn't remember the name) which presented an interesting encryption method. The premise was that the method didn't require the exchanging of any key (no public key of the recipient of a message requ...
Say I have a big matrix, ~50000 rows, ~80000 columns. I want to split it up and solve subproblems on different machines (horizontal scaling). But I need to make sure every column can be combined with every other column. Thinking about, I can't really think of an efficient algorithm that could split the matrix up and st...
Let $A$ be any unary language. Prove that if $A$ is NP-complete, then P=NP. Approach 1: We just have to prove that we can decide $A$ in polynomial time. Consider a Turing machine that on input $w$, scans all the symbols of $w$. If they are all 1s, accept; otherwise, reject. This TM runs in polynomial time, so $A$ is in...
Section 10.1.2 of Sanjeev Arora and Boaz Barak's Computational Complexity: A Modern Approach defines random self-reducibility and proves hardness of the discrete logarithm by reducing a worst case input to a series of random instances. The proof is rather straight forward, but I am having trouble replicating the final ...
I just got a small confusion here, I have a graph for which i need to get number of minimum spanning tree, So, in graph i have 3 edges with weight 2 and 4 edges with weight 3, in such a way that AE = AB = BE = 2 and ED = DC = EC = BC = 3. The solution provided is 3C2*(2+3C2). Initially taking any 2 edges from edges wi...
I am looking for answers creating 500 samples of non-stationary Time series based on its probability distribution preferably using monte-carlo simulation. DATA LINK Secondly, the most example available on any platform are considering normal distribution for creating the sample (like Monte Carlo) which sees fitting wit...
The multi-source shortest path problem for unweighted and undirected graph is as follows: Given an unweighted and undirected graph, find the length of the shortest path between any pair of vertexes. A straightforward method is to use BFS starting from each vertex, as the time complexity of BFS is O(V+E), the total time...
So, I have N sets of objects of various sizes. I want to put them in order, in a way that's as much "alternative" as possible. For example, if I have 5 A, and 6 b, that's easy: B A B A B A B A B A B If I have 5 A, 6 B, and 2 C, it could be something like that: B A B A C B A B C A B A B Any idea how I could compute that...
The problem is: split the given array with $L$ elements, $A$, into $K$ subsets such that maximum sum of all subsets is minimum. I have known that the problem that partitioning the multiset $S$ into two subsets $S_1$, $S_2$ such that the difference between the sum of elements in $S_1$ and the sum of elements in $S_2$ i...
Given a series of n numbers, I need an algorithm that runs in worst case O(n*k) to figure out how many arrangements of those n numbers will give me a score of exactly k. Note that the series does not contain duplicate elements. The score of a series of numbers is calculated by the number of smaller numbers an element i...
I would like to ask a very fundamental question regarding distance-regular graphs. Denote $d(u,v)$ as the distance between node $u$ and $v$. Distance-regular graphs are graphs such that for any pair of vertices $u,v$ with $d(u,v)=i$, there are always $b_i$ neighbors $w$ of $u$ with $d(w,v)=i+1$ and $c_i$ neighbors $w$ ...
My professor mentioned that if we already know the divide and conquer algorithm for the closest pair of points in 2 dimensions it's easy to think of a similar algorithm for the 3 dimensions. But I am a bit confused as to what changes we have to make. I think we'll divide the points in two sets based on the x coordinate...
Conflict-Free Replicated Datatypes (CRDTs) are a class of distributed data structures where replica states are allowed to temporarily diverge, but will eventually converge (in the absence of network partitions). 2 Specifically, the class of CRDTs known as state-based (or convergent) achieved the above by requiring the ...
There are integer tuples which index cells of a sparse multi-dimensional array (points inside n-parallelepiped), $n \le 32$. The array itself is a BST with keys formed as $key = (...((a_0 * S_1 + a_1) * S_2 + a_3 ) * ... + a_{n-2}) * S_{n-1} + a_{n-1}$, such keys preserve the order of tuples and can be compared in cons...
I would like to ask this question as I am not sure about the answer. Let $G=(V,E)$ be a connected, undirected graph, and let $x,y\in V$ be two different vertices. Let $A$ be the problem of finding the shortest simple path between $x$ and $y$, and let $B$ be the problem of finding the longest simple path between $x$ and...
I am looking for an algorithm to find the best order of items to fit on pages. Consider the following case, we have a page with the height = 300 We have images with the following heights - [150,200,100,150,300] So I want to find the best order for this images in order to fill the page. For example: First page: 150 - 15...
A bit confused about the term minimum bottleneck spanning tree. I thought it was the spanning tree with the cheapest maximum edge, but the example I was given seems to contradict this. In the example above, my material says: For the given graph G, the above figure illustrates all the spanning trees for the given grap...
I'm the author of GateBoy (a gate-level simulation of the original Game Boy hardware) and Metron (a C++ to Verilog translation tool). One big issue I had to work around for both projects is the inability of C++ (or really, any current procedural programming language) to express atomic state change in a way that is both...
Suppose we have a matrix $A$ of dimension $n \times n$ and two vectors $\vec{u}$ and $\vec{v}$ of dimension $n$. Then we have $A\vec{v} = \vec{x}$ with time complexity $O(n^2)$ and space complexity $O(n)$ with the naive algorithm (since the output is a vector of length $n$). (Forgive me if there is a better runtime. I ...
About few ago in my freshman year of college I stumbled across an an old blog post on r/programming posing a programming challenge. Here is the short version of it: Hundreds of ships would like to dock to each other to build a floating city of ships. Although they are all bound to each other, any ship must be able to ...
how to count all pairs such that w^x=y^z, where 1<=w,x,y,x<=n and 1<=n<=1000000 for example for n=3, there is 15 solutions 1^1=1^1 1^1=1^2 1^1=1^3 1^2=1^1 1^2=1^2 1^2=1^3 1^3=1^1 1^3=1^2 1^3=1^3 2^1=2^1 2^2=2^2 2^3=2^3 3^1=3^1 3^2=3^2 3^3=3^3
I am research scholar currently working in complexity theory. Recently, i have started working on hard proofs and reductions. It is very well established that there is a polynomial reduction from every known hard problem to a possible hard problem. So, while proving the hardness of a problem, it does not matter which h...
I build a python script which uses OpenCV implementation of KNN Backgroud Segmentation/Remover. I know the basics of how KNN works, but not how the background segmentation works. For the MOG algorithm I found lots of papers, but I havn't found a single one for KNN background segmentation. Apart from wanting to understa...
I got the following question from my academic instructor and since I am new to graph algorithms I would be happy if someone could review my solution. Given undirected graph $G = (V,E)$, suggest an algorithm that determines whether or not it is possible to assign directions to edges in a way that the indegree of each v...
Let's say we have a graph $G$ with $|V|$ nodes. We wish to select the smallest set of nodes $S$ that: $dis(i, j) \le k, \forall i \in S, j\in V-S$, where $k$ denotes a certain distance threshold. Smallest means the least number of nodes.
Consider an ambiguous context-free grammar $G$. Define $A(G)$ the set of ambiguous words, meaning: $$A(G) = \{u\in L(G) \mid u \text{ has at least two derivation trees for }G\}$$ Can we say something about $A(G)$ in the general case? In particular, is $A(G)$ a context-free language?
Godd afternoon, We have set C of k coins; For example C = (2, 3) We have positive integer n. In how many ways we can represent n using those coins? Example: If n = 12; C = (2, 3) we can represent 12 as 3+3+3+3, 3+3+2+2+2 or 2+2+2+2+2+2, so in three ways. Introduction: For any predefined set of coins, there exists fo...
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i...
Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 s...
T(n) = 2T(n/4) + sqrt(n) I am trying to solve this question and ended up with the answer O(√n.log√n). But when I checked online the answer was supposed to be O(√n.logn) or √n.logn base 4. I am not sure how to remove the square root from n.
I am bit confused on these terminologies. While studying Paging of Operating System we study about Page and Frame. Size of one Frame of Main Memory = Size of one Page of a Process While studying Cache Memory Mapping in Computer Organization we study about Memory Block. Size of one Block of Main Memory = Size of one ...
As we know, Quickselect chooses a 'random' element in order to partition the array around that element in every iteration. Assume the random element is at most the $\frac{1}{k}\cdot n$ largest element, and at least the $\frac{k-1}{k}\cdot n$ largest element, for some constant $k>1$. I'm asked to prove that under those ...
I am reading the paper HyperEnclave. I have a few questions about the OS in general. Is is safe to assume that attackers cannot mount physical attacks during boot process of the OS? Can we assume that the OS is benign during boot process? Is it possible to remove some parts of the OS and disable DMA capability of pe...
I know that regular languages are closed under closure properties. But, for example, we know if $L$ is regular, then its complement $L^\complement$ is also regular. If we have $L_1$ and $L_2$ as regular then $L_1 \cap L_2 = L_3$ makes $L_3$ regular. Now for the case of when $L$ is not regular, then its complement $L^\c...
Lets say I have n lists from different sources, each contains m possible location of the user. I need to choose the most probable prediction of the user location. My idea was to pick one location from each source that so that those n locations are closest to each other. The average of those n locations will be my estim...
This is problem 88 from Miscellaneous exercises of Kozen's "Automata and Computability". The shuffle $A||B$ of two languages $A$ and $B$ is defined as $\{w \mid w = a_1b_1\ldots a_kb_k,$ where $a_1\ldots a_k ∈ A$ and $b_1\ldots b_k ∈ B,$ each $a_i,b_i ∈ Σ^∗\}$. Show that if $L$ is context-free and $R$ is regular, the...
I don't really need hands on coding help, I need to clear my concepts of some of the more complex topics of DS and Algo like NP-Completeness, Computational Geometry, String Matching, Multithreaded Algorithms and Backtracking Algorithms. I have so far read CLRF(Cormen) as my go to book. But sometimes I just can't wrap m...
I have a bag of sets which overlap, and I am looking for an efficient (if possible, optimal) way to leverage that overlap to store those sets with minimal space requirements. For example, consider these two sets: S = {1,2,3,4} T = {2,3,4,5} An efficient storage solution would somehow make use of the overlap, e.g. X = ...
So I'm writing a software that generates random MIDI tracks based on a given mode, tonal etc. As for now the randomisation works on tones building sequences of equal duration. What I'd like to do is also randomise the duration of each note in a sequence, but at the same time I'd like it to fit with the time signature. ...
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next day or moving to a different island. All the islands are connected to each other by routes. Each evening of the day the pirate steals some gold on the ...
If $L ⊆ \{0, 1\}^*$ is a language, then we denote by $ \overline{L}$ the complement of $L$ For example, the definition of $coNP$ is $coNP =\{L | \overline{L} \in NP\}$ The complement of $SAT$ language is $\overline{SAT} = \{\phi | \phi$ is not satisfiable$\}$ Of course, there are other $P$ languages What I want to ask...
I'm looking for a context-free grammar that recognizes precisely the numbers 1 - N in order: 1,10,11,100 valid (numbers 1 - 4 in base-2) 1,1,10,11,100 invalid (duplicate 1) 1,10,100 invalid (missing 3) 10,1,11,100 invalid (has all numbers but 1 and 2 are not in the correct position) I'm not sure where to start to creat...
Take $s = a^{10}$ for our example string. Compute the set of all potential grammar reducing variable-rules: $$ A \to aa \\ B \to aaa \\ C \to aaaa \\ D \to aaaaa $$ There is always exactly $\left\lfloor \dfrac{|s|}{2}\right\rfloor - 1$ of these over a singleton alphabet, or in other words $O(|s|)$. Now enumerate all...
Setup I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint subsets, $B_j$...
I feel like I am understanding P ≠ NP fairly well, but there is one issue I feel like I am missing. It seems like a search for an answer generates information that a check does not. Is this a correct way of looking at it, and if so, how does that not already imply that P ≠ NP? Example for Clarification Let's take the w...
Consider the following schedule S.Is S conflict–serializable? Append the commit operations of these transactions at the end of the schedule in an appropriate order such that S is recoverable. How many such orders are there? $$S: r1(X); r2(Z); r1(Z); r3(X); r3(Y); w1(X); w3(y); r2(Y); w2(Z); w2(Y);$$ I have already foun...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To give some con...
I'm currently enrolled to a CS course about programming languages and we learned about structural induction. In a question from our home assignments we need to proof that the following CFG has balanced parentheses: My initial solution used simple induction and following the derivation rules of the CFG but the TA told ...
In Tomasulo's algorithm, is there only one reservation station per functional unit (even with multiple same-function FUs like, say, 3 adders)? Can there be more?
I'm facing this problem for some time now, I've tried a greedy approach yet I result to trying a DP-ish approach, only to get stuck at a standstill. Given a board of length $n$, and an increasing monotonic "price" function $p:\mathbb{N}\rightarrow\mathbb{R}^+ $, an acceptable partition (Notated by $X=\{x_1,x_2,\ldots x...
Consider the set of all linear programs of the form: maximize $c x$ subject to $A x \leq b$ $x \geq 0$ where there are $m$ variables, $n$ constraints, and all coefficients in $A, b, c$ are integers from a given finite set $K$. Since the number of such programs is finite, the number of possible optimal values of these p...
I'm looking for an algorithm that is closely related to the 2-dimensional nesting problem (also known as lay planning, bin packing, and the cutting stock problem). The main differences between this and normal nesting are: A fixed number of elements to be placed The elements cannot rotate The elements must be placed in...
When we speak of a variable, sometimes we will mean the string it expands to, and other times, the variable itself. Let $t \leqslant s$ mean substring. Take the string $s = a^6$. Then its compressible substrings are $aa, aaa$. Now assign positioned variables $A_i \to aa$, $B_j \to aaa$, for $i = 1...5, j = 1...4$ lik...
I'm stuck here, how can i prove this: $$L_1 \cup L_2 \subseteq L_1^*L_2^*$$ $$\begin{array}{rcl} x\in L_1\cup L_2 & \Rightarrow & x\in L_1^* \lor x\in L_2^*\\ &\Rightarrow &x\in L_1^*\cup L_2^* \end{array}$$ What's next?
How can I calculate the complexity of computing $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$? $$MD(s) = \max(s)-\min(s) + \min(MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\}))$$ where $s$ is a finite multi-set of numbers with base case $$MD(\text{one element})=0.$$ Thoughts: I think the time complexity is $O(n^2) $ beca...
Given a graph G = (V, E) with edge lengths c : E → R, and a number d ∈ R, is there a Hamilton cycle of length l ≤ d in G? Show that the Travelling-Salesman problem is contained in the complexity class NP. I am somewhat struggling with this exercise because I have little problem understanding the formality. I know that ...
Let's say that I have a Las Vegas algorithm for a given problem (whose answer is true/false for simplicity) with a chance of answering p, and a Montecarlo algorithm for the same problem which is q-correct (it gives the correct answer with a probability of at least q) Could there be any way to combine them both in order...
If we have this language $ L = \{a^mb^nc^n:m,n \in N\}$, would its complement be $\{a,b,c\}^* \setminus L = L^\complement = \{c^nb^na^m:m,n \in N\}$? This was the professor's answer, which I find incorrect, because it doesn't include for example $aba$, which should be in the complement as well. Since the given language...
Description Similar to the encoding of a Turing Machine, we can encode a Push-Down Automata. Denote $\langle M \rangle$ as the encoding of PDA M, and a natural number n, is language $L = \{ \langle M \rangle | \text{ M is a PDA, L(M) contains at least 1 string w that } |w| \leq n \}$ a recursive language? Question By t...
Let $A \subseteq Z$, where $Z=\{1,2,3,\cdots,n\}$. Now given any $B \subseteq Z$, we need to check whether $A \cap B =\varphi$ or not. I am looking for a randomized algorithm. I am trying to implement it using a bloom filter. Create a bloom filter for $A$ and $B$ respectively. Now consider the intersection of $A$ and $...
I guess the question does not apply just to CS as I'm trying to understand how it applies to RAIDs, but I guess it's maybe the most suitable place to ask anyway. There's a lot of info that RS codes are often used to implement second parity for RAID-6. There are some systems that implement triple-parity. Am I right that...
I work with elements that have a representation in two different vector spaces and I would like to compute an indicator of how similar the neighbors of the elements are in these two spaces. To do so, I start by computing the list of the $n$-nearest neighbors of all elements, then I use a sequence similarity measure th...
I am creating a database on students' interests using the Entity-Relationship Model for a University assignment. Should I implement the circled stuff as attribute, or an entity set?
Problem definition I have a directed graph $G = (V,E)$, with positive weights $w(e)>0\:s.t\:\forall e \in E$ I would like to find the longest walk (i.e. edges and nodes may be repeated) in terms of most accumulated weight, under the condition that once an edge $e$ is traversed, its weight will become its own negative ...
Given an array $A=\{\frac{S_1}{K_1},\frac{S_2}{K_2},...,\frac{S_n}{K_n}\}$ whose any $S_i$ and $K_i$ are positive floating-point, and an positive floating-point $R$, how to select a set of element $C=\{\frac{S_{p_1}}{K_{p_1}},\frac{S_{p_2}}{K_{p_2}},...,\frac{S_{p_m}}{K_{p_m}}\}$ such that the absolute value of the dif...