instruction
stringlengths
35
29.1k
Assume that for each building in a city there is a known subset of the city's buildings that can be seen from that building (being in a building counts as "seeing a building" as well so for every building you can see at least one building, the building you are in). Develop an efficient algorithm for visiting the minimu...
I understand that knapsack problem is solved with dynamic programming in O(nW) time which is not polynomial but there is a greedy solution for knapsack problem which solves it with O(nLgn) time so how is it that there exists an algorithm with polynomial time for knap sack but it is still considered a npComplete?
Find the asymptotic bound in terms of $\Theta$ (Theta) using the master theorem for the following recursive equation. Assume that $t(n)= \Theta (1)$ for suffucuently small $n$. $$t(n)=t(\frac{n}{5})+t(\frac{n}{17})+n$$ I am a bit confused on how to approach such question, I did solve questions such as $t(n)=3t(n...
I have got confused in undressing the informal definition of LTL below: $$G(\phi \Longrightarrow\psi)\Longrightarrow(G\phi \Longrightarrow G\psi)$$ in many literatures I have seen implies is said as replies like for LHS we can say Always/Globally $\psi$ replies to $\phi$. is it correct? Does the LHS implies the RHS if...
The naturals lack subtraction, but SZ polynomial identity testing needs subtraction... I think it's applicable, but how to prove it? Perhaps: SZ shows natural polynomials are equal iff it shows those polynomials are equal over integers. Integer polynomials are equal iff some sequence of algebraic manipulations transfor...
in many lecture notes, I have seen the LTL idempotent law for until and its equivalence is described as $\phi U(\phi U \psi) \equiv \phi U\psi$ and also $(\phi U \psi)U\psi \equiv \phi U \psi$ . Also by definition of $G$, some formula holds in every state. So if globally $\phi$ holds until we see $\psi$ does it make ev...
When I read the word "state" I think of a global object with a bunch of properties like the "application state". But it seems that in automata that the state is pretty much just an empty value. Wondering what specifically the data structure is for automata states in general. For example, the following comes from here: ...
I was trying to find a cf-grammar for $L = \{a^{2^n}| n \geq 1\}$ but I cannot seem to find one. Is there a cf-grammar or does it not exist because of the quadratic-exponent?
I've read that the maximum boundary edges amount of union of $n$ rectangles, named $p$, is bounded by $p \leq n^2 + 4n$ I tried to prove this by induction, but it's seems too difficult to me, can anyone help me with the proof? thanks. an induction try: $n = 1$, $p = 4 \leq 1^2 + 4$ is clear. assume when $n = m$, $p ...
I have an undirected weighted graph like this one My task is to find the fastest path (with least weight) that goes from specified vertex goes through all vertices and returns to the starting vertex without repeating a vertex. Graph 1 3 time 5 3 2 time 5 2 4 time 5 4 1 time 5 4 3 time 4 1 2 time 5 Starting vertex 3 P...
Wondering what the differences are between Tree Automata and Tree Transducers. Wikipedia says: Tree transducers extend tree automata in the same way that word transducers extend word automata. And about word transducers it says: A finite-state transducer (FST) is a finite-state machine with two memory tapes, followi...
Given a number $N$, I need to make a new array $B$ of size $n$ (index-1 based) such that the product of $B[i]-(i-1)$ for $1 \le i \le n$ is equal to $N$ and $B[n]$ is minimum and $B[i] \ge B[i-1]$ and $B[i] \ge 1$. I found the prime factors of $N$ and sorted them in decreasing order and if they are greater than $n$ th...
What method(s) can I use in general to proof HALT doesn't reduce to given language?
I have a few basic questions about how the states work in Tree Automata. Example 1.1.2. Let $F = \{f(,),g(),a\}$. Consider the automaton $A = (Q, F, Q_f, \Delta)$ defined by: $Q = \{q,q_g,q_f\}$, $Q_f = \{q_f\}$, and $\Delta =$ \begin{align} a &\to q(a)\\ g(q(x)) &\to q(g(x))\\ g(q(x)) &\to q_g(g(x))\\ g(q_g(x)) &\t...
I've been asked to prove the correctness of the following recursive formula. The formula is trying to define, how many ways you can spend your money C on the i amount of beers. I did the following recursive formula where you either bought a beer and losing $P-i$ money, or passed the beer and went for the next in the ar...
The Wikipedia page on the time hierarchy theorem states: A similar theorem is not known for time-bounded probabilistic complexity classes, unless the class also has advice. However, wouldn't the usual time-hierarchy theorem suffice in this case? For instance, we know that $BPP \subset EXP$, and since the ordinary tim...
I run across this problem: Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always preferred. For example, given [1,2,3,4,5], k=4, x=3, we should have [1,2,3,4]. There is one soluti...
Imagine a chord-like network $N$. each machine $m \in N$ is directly connected to $N_m \subset N$. Without relying on official timeservers, I want all machines to synchronize to some time with millisecond precision. my algorithm is executed some time after a machine joined the network, and works as follows: the machi...
Simply typed lambda calculus has a combinatory logic equivalent with the same expressive power without the need of defining names via lambda abstraction. Is there a formalism as powerful as System F but based on combinatory logic?
for $e\leftarrow1$ to 8 do for $e\in[1,8]$ do for $e\in\{x\in\mathbb{N}|1\le x\le8\}$ do What is more preferred?
Given some binary operator $\otimes : X\times X\to X,$ and list $x_1,\dots,x_n$ where $x_i\in X,$ can all possible expressions in $\otimes$ be computed within a number of operator applications polynomial in $n$? We say an expression in an operator $\otimes$ and list $x_i$ is formed by placing $\otimes$ between all $x_i...
I don't really understand why is statement 1 ≥ statement 2 in the attached picture. From what I understand the negative term in statement 2 must be greater than or equal the negative term in statement 1 if statement 1 ≥ statement 2 but I don't really know how. Any help on this matter will be really appreciated. Thanks!...
Is time complexity and running time of the program/algorithm one and the same thing? Also, running time sounds like 'computer complexity'. As, it utilizes all the resources and give tangible time that program took to run. So, can we say that running time is same as computer complexity?
My question is: Given a planar graph defined by its adjacency matrix. Can I always find a set of points, so that the dual graph of the voronoi diagram of that set of points is the same as the planar graph?
I was studying disjoint set data structure. I studied path compression and union by rank. Initially all the elements are single in their own set and by performing unions we can combine different sets. Now since we are performing union by rank the height of the resultant tree is always minimum. At this point i think th...
I'm trying to reduce this example from Circuit-sat to 3-Sat, but I got stuck. Can some one give a brief explanation step by step? Tree: schema My attempt:
Is it true that if a connected graph has a bridge then it has a cut vertex? In my point of view, I don't think it is true to consider that a graph having a cut edge will definitely have cut vertex. Consider a graph with a single edge $uv$; if we remove this edge, the graph will get disconnected but if we remove $u$, th...
Wikipedia says Every class which is low for itself is closed under complement, provided that it is powerful enough to negate the boolean result. This implies that NP isn't low for itself unless NP = co-NP, which is considered unlikely... . This line of reasoning is a bit abstract for me. Is there a concrete example o...
Suppose we have a neural network (such as google uses for instance) which detects an object in images, which could be a cat or car. Suppose that it is instead an alien artifact that we dont have pictures of. What methods are there given this neural network to produce an image of the object it detects in images?
This famous paper proves the existence of both oracles $A$ and $B$ such that $\textbf{P}^A = \textbf{NP}^A$ and $\textbf{P}^B \neq \textbf{NP}^B$, therefore proving that any resolution to the P versus NP problem must be nontrivial in the sense that it cannot relativize. I understand the significance of the oracle separ...
Why does the Turing Machine allow for multiple final states when it would be simpler yet equivalent to work with just one? Why allow additional unnecessary states? Is there some historical reason for this? Is the concept of multiple final states useful in any way? (Perhaps something akin to the ease of use of multi-tra...
Consider the stable marriage problem, where both sides want to match with multiple individuals from the other side (perhaps a fixed number, or perhaps within some range). Something like, if doctors could choose to go to more than one medical school at the same time. Is there a variation on the deferred acceptance algor...
The original paper describing splay trees Self-Adjusting Binary Search Trees by Sleator and Tarjan claims that: Splaying not only moves x to the root, but roughly halves the depth of every node along the access path. What is the intuition for this claim? The paper includes some figures (splaying in a tree of all zig...
I was wondering how I can find all the vertices in a graph that are part of a cycle. To determine this for one vertex, I could just start a DFS from that vertex, but this seems unefficient to me when I want to know for all vertices. Thanks for your help!
It's a complex situation, where I want to balance groups of numbers based on the average of these numbers, while keeping the group size unchanged and not breaking elements constraints. Let me explain in detail what I mean: I need to switch elements between the groups in order to balance the group average. However the ...
Here is a popular proof of the halting problem theorem: Suppose there exist a procedure h(x, y) so that for any procedure p(x) and any data d, the execution of h(p, d) will halt, where halt means return by a "return" statement so a system crash means doesn't halt, and if h(p, d) returns 1 then the execution of p(d) wil...
I'm studying Digital Logic and Design. And in the first chapter, there's all this information about various binary codes. I did some searching on youtube and found this awesome video - https://www.youtube.com/watch?v=lKTsv6iVxV4&t=5s. Now, my question is, If 2's complement is the best way to represent numbers in comput...
How is an ISA written? Is it just a bunch of binary combination encoding presets that is stored onto RAM? In other words, is it basically a “dictionary” of binary being defined as an instruction ‘word’ such as add? Once the instruction ‘word’ is recognized, does that mean an action is defined/assigned in that ‘word’? F...
I have a language that contains all encodings of the Turing machines that accept at least one word. Is this language recursive, recursively enumerable, or neither?
I thought of a problem but have no idea how to solve it. The problem is as follows: Given 2 numbers, n and r, find the side length (S) of the smallest square that encloses n circles each of radius r without any overlap among any of the circles. I though about a greedy approach that would find the optimal position for ...
Is there any algorithm for finding the minimum weight maximal independent set? Instead of finding all maximal independent sets and keeping the one with less weight, is there any easier method to do it?
After reading Lamport Algorithm for Mutual Exclusion, I can not understand the purposes of reply messages. I think they are not necessary because the assumption of the algorithms is that all messages are delivered in order and no message is lost. In addition to that, the algorithm uses Lamport logical clock, so the req...
Assuming $L \in NP$, meaning that L could be verified by some $V(x,y)$, such that there exists a polynomial $P(X)$ such that $|y| \leq P(|x|)$ for every $x \in L$. I was wondering - can I assume something about the possible witness space? My intuition says that this number is bounded by $O(2^{P(|X|)})$ (all possible su...
What does $\mathsf{AC^0}$ many-one reduction mean? I know about polynomial time reductions, but I'm not familiar with $\mathsf{AC^0}$ reductions.
Under the assumption that a PSPACE-hard problem A can be solved in polynomial time, is the following argumentation valid? Since every problem in PSPACE can be reduced to A in polynomial time, every problem in NP which is a subset of PSPACE is included. That means that each Problem in NP is solvable in polynomial time ...
I decide to learn more about dynamic programming, so I started reading the Dynamic Programming chapter from the CLSR book. The first example problem presented there is Rod Cutting (15.1). Given a rod of length n and a list of prices for rods of any sizes figure out how to cut the rod so that the price of the pieces wil...
The question is pretty short, but I've been thinking about it quite some time: Are terminal symbols that are not in the defined alphabet still valid?
The paper "Model Checking TLA+ Specifications" published in 1999 explained how TLC (Temporal Logic Checker) checks safety properties written in TLA+ developed by Lamport. At that time, TLC did not yet check liveness properties. Today, TLC is able to check liveness properties. I want to know: What liveness properties ...
Counting sort is originally like below code. for (int i = 0; i <= 5; i++) c[i] = 0; for (int i = 1; i <= 8; i++) c[a[i]]++; for (int i = 1; i <= 5; i++) c[i] = c[i] + c[i - 1]; for (int i = 8; i >= 1; i--) { b[c[a[i]]] = a[i]; c[a[i]]--; } In the above, last for loop iterates from last index because of stabili...
I am trying to infer the type and prove that this is well-typed: let $f =\lambda x.x$ in $f f$ Obviously the $f$ is the identity function, so it's the same as let $id =\lambda x.x$ in $id$ $id$ I am trying to use these rules to infer the type, going bottom-up: First I am using (T-LET') and on the left-hand side it's e...
I'm a bit confused about the definition of the Minimum Cost Flow problem, in terms of the edge cost (or weight) values. I don't remember a integral requirement on the cost/weight values for the edges when first learning the problem. But when I start to look for implementations, most algorithmic code I found require th...
I have a book from my university that claims: There is an linear algorithm that can convert BDD to CNF in linear time, and generate CNF in linear length of the BDD size (number of nodes). Then they wrote an exercise to find one... Actually I tried to do so, I thought to find the paths that brings me to 0, and then ...
$$L=\{uv\in\{0,1,2\}^*\mid u\in\{0,1\}^*,v\in\{1,2\}^*, \text{ and }u\text{ has the same number of 1s as }v\}.$$ Here is my attempt solution, but it is not completely correct, any hint is appreciated (not sure how I can ensure that $u$ and $v$ to have the same number of 1). \begin{align} S &\rightarrow S_l \mid S \mid...
Edit: I've pinpointed that the difference between solutions occurs when I apply the $H$, up to there, the solutions match. So, perhaps it is better to phrase my question as: how to apply an $H$ gate to one qubit in a 2-qubit system? End Edit I have the following quantum circuit, and I need to calculate the values of th...
I've been learning about the Halting Problem and the proof that it is undecidable in its general case. The proof that it cannot be solved generally goes something like this: Assume that some machine $H$ exists that can solve the halting problem on a given machine $A$ with input $x$ ($H$ determines whether the machine ...
To answer the question below, 4-SAT: Given a formula in Conjunctive Normal Form, where each clause contains exactly 4 literals, does it have a satisfying truth assignment? I was going to prove that 4-SAT is in NP-complete. But I saw that the way to prove CNF-SAT is in NP-complete is a bit different to the way of provi...
I've read some posts about counting the number of assignment inside code of finding the maximum value in array like this: FindMax(L): n = len(L) max = L[1] for i = 2..n: if (max < L[i]) max = L[i] (**) return max According to this post and post, it's about the array that elements are stric...
Solving $T(n) = \frac{1}{n}(T(0)+T(1)+...+T(n-1)) + cn$ for all $ n \geq 1$ Subbing few numbers in we get $T(1) = T(0)/1 + c(1)$ $T(2) = \frac{T(0)+T(1)}{2} + c(2) $ Which is kind of going backwards as I am going back to finding T(n) So I am kind of confused about it, any idea? Are we even able to unroll this reccurenc...
Show that the following language is NP-complete $$ L = \{ \langle G,k \rangle \mid \text{$G$ is a graph with a set $S$ of $k$ vertices hitting every edge of $G$}\}. $$ I know I should reduce the problem to SAT. But how I can do it?
In the 2004 paper "A Read-Only Transaction Anomaly Under Snapshot Isolation" by Alan Fekete et al. (which can be found here and here) the authors state: We also note that any execution of T1 and T2 (with arbitrary parameter values) without T3 present will always act serializably. I have tested this claim inside Postg...
Assuming (hypothetically) someone proves $P=NP$ by providing a polynomial time algorithm for a $NP-Complete$ problem the Polynomial Hierarchy collapses. What are the other (important) questions that are still left in complexity theory in respect to the remaining complexity classes? If possible can someone help with a l...
I'm interested in the following variant of Travelling Salesman Problem sometimes called Partial TSP. I'm particulary interested in the euclidian version : Input : A set $\{x_1,\dots,x_n\}\subset \mathbb{R}^2$ of $n$ points in the plane, and an integer $k\le n$. Output : A tour of $k$ points $x_{i_1},\dots, x_{i_k}$ Min...
$k$-Weight Independent Set Input: A vertex weighted graph $G=(V,E,w)$ and an integer $k$. Question: Is the a set $V'\subset V$ such that $V'$ is an independent set and $\sum_{v\in V'} w(v) \geq k$? Showing that this problem is in NP is trivial, but I'm suck on showing that $X \Longleftrightarrow Y$. The forward d...
Do you know where Can I find an algorithm to sort a set of binary strings in colex order? Recall, that two k−element subsets A and B of a set with strict linear ordering $<$ are said to be in co-lexicographical order (colex order) if, for the sequences, a and b of their elements sorted in ascending order, there exists ...
I'm currently working on an algorithm that requires me to come up with unique matrices. Two matrices are considered equivalent if one's rows and columns can be swapped to make it match the other. For example, $\begin{bmatrix} 0 & 0 \\ 1 & 1 \end{bmatrix} \equiv \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \not\equiv \b...
I have decent enough experience with programming to be able to tackle most things but I want to know how you recommend making the jump from just programming to computer science. I still have a couple years till college, I'm only a sophomore right now although I am taking Calc over this summer which should help with som...
A tree is provided which has $n$ nodes and each edge of that tree has a certain length. There are $M$ persons on the tree, numbered 1 through $M$. For each valid $i$, person number $i$ starts at time $t_i$ from vertex number $u_i$ and runs straight to vertex number $v_i$ with constant velocity $s_i$. Before time $t_i$...
I have a question about follow sets. Suppose there's a rule, A -> XBCD B -> $\beta$ | $\epsilon$ C -> $\gamma$ | $\epsilon$ D -> $\delta$ What is Follow(X)? Is it (First(B) - $\epsilon$) $\cup$ (First(C) - $\epsilon$) $\cup$ First(D) = {$\beta$ , $\gamma$, $\delta$ } ?
Let $A = (a_1, a_2, \dots, a_n)$ denote an array of distinct values with an order defined. Consider the following randomized sorting algorithm. Let $m := 0$. Select a pair $(i, j)$ with $1 \le i < j \le n$ uniformly at random. If $a_i > a_j$, swap $a_i$ and $a_j$. If $m < m_{max}$, let $m := m + 1$ and go to step 2. ...
I was going through graph theory and came across the term Euler path or some people prefer Euler trail as vertices can repeat. According to the definition from wiki (https://en.wikipedia.org/wiki/Eulerian_path), Euler path is defined as under In graph theory, a Eulerian trail (or Eulerian path) is a trail in a graph w...
Let $L$ be a regular language, and $Pre(L)$ be the set of all words that are prefix of some word in $L$. Prove that $Pre(L)$ is regular. My proof: Let $M = (\Sigma, Q, \delta, q_0, F)$ be an automata such that $\mathcal{L}(M) = L$ and $Q' = \{ q \in Q \ | \ (\exists q_f, w \ | \ q_f \in F \ \wedge \ w \in \Sigma^{*}: ...
Can a neural network be used to find the genus of a 2-manifold given for instance as a CW complex?
I'm looking to design an algorithm for a problem I have, and was hoping there may be someone that could provide some insight on where to start. In my picture above, the grid is the area they needs to be explored by the circles. Each cell is a unit of work, so currently I've got lat/lng coordinates for the exact center...
I'm confused as to why we can't write formulas of infinite length in FO. For example, to express reachability, I understand the proof that there cannot be a single formula for it, but it is expressible with a set of formulas? Since any formula has an equivalent formula in CNF, if we transform a formula of infinite leng...
I'm a cs student and i've just started learning about binary arithmetic.I have to do this homework assignement to get prepared for exams..I'm having some trouble figuring out how to convert a negative floating point number in binary system....I was thiking about IEEE-754 representation but i must use only two's complem...
Basically, I'm interested in doing 2 things. Let's say we have a mesh M. 1. Find the minimum number of points(inside M) required to see the whole M. 2. Decompose M into polyhedrons which can be seen by only one point inside of them. There are many articles on 2, for example I've found algorithms on convex decompositi...
I was looking at a tutorial for recurrent neural networks in Python, and I have a question in regards to multiplying matrices of different sizes. Specifically, why does S[t] have 100 elements in it? s[t] = np.tanh(self.U[:,x[t]] + self.W.dot(s[t-1])) Earlier in the tutorial, the author lists the dimensions for each v...
Are pushdown automata without $\varepsilon$-transitions as powerful as those with them? Intuitively, if we need to make such a transition, we could just add the letters on the next transition we take, but I'm not convinced by that reasoning.
Let's say a person took an image like this I have access to all image attributes (like for example image format, resolution and so on), and I know the location of the person - basically the place where he made the photo. Also I know all the data about the camera - model, resolution and others. Is there an algorithm th...
I have taken one basic class in complexity and understand the fundamentals. E.g. P, NP, NP-hardness. But I can't understand how to interpret $BPP^{NP}$. I believe it means "BPP with an NP oracle" but how should I interpret that? Does this mean that members of this class are problems for which there exist randomized al...
I know many algorithms that can be analyzed using master theorem, but the only algorithm I know where the time is dominated by the leaves is fast matrix multiplication. Are there other recursive algorithms (not necessarily master-theorem-style -- can be akra bazzi/something similar) where the time is dominated by the l...
The paper for BIRCH (a clustering algorithm) contains definitions of a Clustering Feature (CF) where the notation is unclear (cf. PDF page 3 / section 4). A cluster contains N d-dimensional entries $ \{ \vec{X}_1, \vec{X}_2, \dots, \vec{X}_N \} $ and its CF is composed of three values. N the number of elements (straig...
Let $L$ be the set of strings of length $n$ (say $n=400$, for example). Let $N = \{0,1,\dots,|L|-1\}$. I am looking for a function $f : N \to L$ with the following properties: $f$ is efficiently computable $f$ is a bijection $f$ is pseudorandom (not necessarily cryptographically) Given some interval $[a,b]$ and a regu...
In the following MIT open course, it is claimed that min-cost circulation reduces to min-cost max-flow: ... The second part of the proof is showing that min-cost circulation reduces to min-cost max-flow. Consider a network G for which we want to find a min-cost circulation. Add a source s and a sink t to the netwo...
I've been recently dealing with a problem which, when worst case is considered, results in exploration of $B_{n}$ options, where $B_{n}$ is th $n^{th}$ Bell number. I am trying to rigorously prove, that dealing with $B_{n}$ possible solutions results in exponential (or worse?) computational complexity (in terms of $n$)...
I am studying cache coherence MESI protocol with "intervention" (cache can send to other cache without use the Main Memory). On my notes I wrote that in case of a processor has a block in M (modified state) and read on the bus a Write operation done by an other Cpu, the processor sends the block directly to the cache t...
I am trying to solve a problem- Longest repeated substring in a string. Firstly, I built a suffix tree that takes O(n) time and then I traversed the suffix tree to find the deepest internal node. I am not sure whether traversing in a suffix tree would be O(n) or not? These are the properties of a suffix tree- A suffix...
I am currently studying the Erdos-Reyni model, the $G(n,p)$ model to be specific. Its easy to understand that all graphs with $m$ edges have generating probability of $p^{m}(1-p)^{n(n-1)/2 - m}$ where p is the probability that there is an edge between a pair of vertices. What I am not able to understand is the followin...
(Pre-note: I'm learning Theory of Computation on my own, so bear with me if I'm saying something wrong/stupid.) Why is $L := \{b^2a^nb^ma^3\mid m,n \geq 0\}$ a regular language? This question appeared in a problem set, whose answer is the following: The language is regular. Indeed, it can be expressed by the regular...
I have a graph consisting of about 5000 vertices, with density around 0.5. I'm trying to find two disjoint 6-cliques, which are not connected by an edge. I have tried bruteforcing this, by firstly looking for any 6-cliques, and then checking pairs for being non-adjacent. However, although it finds a lot of 6-cliques it...
I have a set of source bins, each with some number of items, and a set of target bins. I want to move all of the items from the source bins to the target bins, using the minimum number of moves. Each move can move any number of items from one source bin to one target bin. The bins do not have the same size, but the t...
I came across this classic question and found may many solution to it. for loop and DP/ reclusive + memorization. Also found a twisted version of the questions asking to print all possible path instead of counting. Wondering for the twisted version, if we have DP solution ? Q: If there are n stairs, you can either tak...
There's a list of (unknown) integers, in [0...20]. They are generated from a uniform distribution via a RNG. The input is observations of the form: in a subrange [i,j) of the list, and some given threshold T in [0...20], how many sextuples exist (not necessarily of consecutive numbers) consisting of numbers that are l...
I have implemented a branch and bound algoritm for finding a Hamiltonian cycle in my software, but I actually need to find a shortest route from fixed vertex through all verticies ending at any of them. As far as I understood, I can reduce closed-cycle TSP to open-cycle with fixed starting point by adding dummy vertex...
Max weighted independent set returns a set of nodes that form the maximum weighted independent set. K-independent set returns yes/no if the graph has a independent set of size k. How would you go about proving this?
so I have a problem on one of my computational structures final reviews, and I cannot seem to figure it out. It's been driving me crazy, so I would like to post it here for some insight. Prove that the following CFG is ambiguous. S-> begin A end A-> A;A / a / S Terminals: begin, end, ;, a. Variables: S, A. I cannot see...
I have no detailed questions actually. My question is about a (maybe possible) generalization for reductions. We defined reduction as following (If I translate a term false please correct me.): $ L_1, L_2 \in \{0,1\}^* $ two languages. One may reduce the language $L_1$ to $L_2$, if there is a total function: $f: \{0,1\...
In the Rabin Karp algorithm the rolling hash is calculated as follows: H1= c1*a^k-1 + c2*a^k-2+c3*a^k-3+…+ck*a^0 where a is a constant. On what basis is this a selected? In Cormen they have used a value 10 and at some other places it is 26. By observation, when the string is of digits they have taken a = 10 and when t...
The term abstraction as I understand it, is used in many different contexts, but has one essential meaning, namely that it refers to the “general properties of some class of objects that doesn’t rely on their details”. For example, abstraction in programming is e.g. interfaces that allow you to constrain a set of objec...
Let G be a graph that forms a cycle on $n$ vertices, with non-negative weights on the edges. Can you give each vertex v a vector $\mathbb{R}^m$ (for some $m\in \mathbb N^+$) such that the L1 distance (taxicab distance) between two vectors is the same as the distance between them in $G$? Prove for a general circular g...