instruction
stringlengths
35
29.1k
I’ve searched for a solution for this problem for some time now, it is out of an algorithm question sheet. We know that in order to find the minimal amount of edges in a flow graph’s min-cut we need to find the maximal flow, $c_o$,set the capacity of the edges of the min-cut to $1$ and for for the rest $e\in E$ set $c(...
I was studying algorithms, and that problem below came up. Write an efficient algorith that calculates the biggest single positive forward change in value given the values. There is a second image with some pseudo code with the resolution, I think. But I couldn't even understand it as well. What does the problem mean...
Kolmogorov said "It seems natural to call a chain random if it cannot be written down in a more condensed form, i.e., if the shortest program for generating it is as long as the chain itself. " So for example (in bits & bytes):- $$ K(\text{a thousand zeros}) \approx \log_2(1000) \text{bits} $$ $$ K(\text{Shakespeare's...
I am considering multivariate polynomials with integer coefficients that can be expressed as sums of products of terms of the form $y_i-z_j$ for positive integers $i$ and $j$. I am trying to find an algorithm to determine if there is a way to express them in terms of these linear factors in such a way that the terms ha...
In Wikipedia I found out that the formal grammar of $\lambda$-calculus is the following: <λexp> ::= <var> | λ<var> . <λexp> | ( <λexp> <λexp> ) Then, a few lines later they say that this is a valid $\lambda$-expression: $$\lambda x.x^{2}+2$$ How does one matches with the other? Where is the "+" operator in the for...
We have a graph where we want to get from node u to v in the shortest path possible. I understand how Bellman-Ford works when we have exactly i edges to go from u to v or at most i edges to get from u to v. But how does this work when you have to go from u to v with at least k number of edges? Is this a simple variatio...
In the Church-Turing thesis Wiki page, there are a set of descriptions of the "behavior of a computor—`a human computing agent who proceeds mechanically'". I am content with all of them, except: (L.2) (Locality) A computor can shift attention from one symbolic configuration to another one, but the new observed configu...
Suppose we have an undirected graph $G=(V,E)$ and and it's Maximal spanning tree $T=(V,F)$ such that the edges in $F$ is the heaviest subset of edges $E$ from which you can create a spanning tree. We're required to prove that for all $(u,v)\in V$, the bottleneck in the path $P(u,v)$ in $T$ is the heaviest bottleneck am...
Is it true that there is no known succinct data structure that has integer array (vector) functionality? Desirable operations would be: append O(1) access(i) - returns i-th item O(1) iterate(i..j) - i.e. iterate from i to j efficiently O(j-i) The emphasis is on integer arrays and O(1). A structure that divides the ar...
################### # create_slider() # ################### def create_slider(self, t0, t1): # adjust the main plot to make room for the sliders plt.subplots_adjust(bottom=0.25) slider = Slider( # left botm w h ax = plt.axes([0.25, 0.1, 0.65, 0.03]), ...
I'm trying to recreate the RSA key generator, from what I understood you must create two prime numbers of 256 bytes long, p and q. Since there really isn't a method able to generate prime numbers, you must generate random numbers so then you can test their primality using an algorithm. Here is where the Rabin-Miller's ...
I came a across a question where there were some statements made on Finite Automata, DFA and their states. One such statements in the question was that a "Every DFA accepting a finite language must contain a dead state" And the answer stated the statement to be true, and showed some DFA where there was a dead state fol...
Turing Machines can be used to compute functions. For example f(x)=x-1. 0011 is on the tape. Turing Machine computes for some time and finishes in accept state. On the tape, we see: _00_10_. Where _ is a blank symbol. Is it correct? Meaning 0011 == _00_10_. For exaple in Python: [] + [1] + [] + [2] + [] == [1,2] is Tru...
There are various meta-learning algorithms in RL that are proposed for settings when we have a (deep) neural network and the policy (or the value function) are parameterized as such. Can these methods be applied to tabular cases? For instance by following the steps of algorithm 3 in the MAML paper (https://arxiv.org/pd...
It is known that $QSAT$ is $PSPACE$ complete, and it is known that $QSAT_i$ is $\Sigma_i$ complete for any constant $i$. However, what if we had $QSAT_{\log n}$? That is, $QSAT$ where the quantifiers can alternate $\omega(1)$ times, but still $o(n)$. Would this be enough to make the problem $PSPACE$ complete, or are al...
I am currently learning about how the compilation and linking works in C++. I think I kinda get how the compiler works, and that for a file to fully compile you don't need to have function implementations, but only declarations. It is the linker's job to link the function declaration to its implementation. But now I ha...
I know that Busy Beaver problem can be used to illustrate the Halting Problem and it's probably the canonical problem used when talking about the Halting Problme . But long time ago I came across some a computation of a sequence from a starting value, that was used to illustrate the problem (I thought the source was Un...
Suppose we have some trees of the following forms: We want to place these trees in a linear fashion in a way such that the last node has the minimum distance to the first node. For instance, if we have the following trees: Then an optimal placement will be like the following: The minimum distance between the first n...
I am working on the following problem, given input list of length n to two sublists of length n2 , which are recursively sorted and then merged into a sorted list of length n. The merge sort has the recurrence for its time complexity as T (n) = 2T (n/2) + O(n). We can assume that the algorithm is modified such that the...
I need to convert a Max Heap to a "Partially Sorted Max Heap" such that all keys at depth i are smaller than all keys at depth i-1. What is the most efficient way of doing this? Can this be done in O(n)?
Recently I began learning a couple array based programming languages: Dyalog APL and BQN. And I cam across this peculiar manner in which division by zero is handled in Dyalog APL. Using the in-built method ⎕DIV a user can change the behaviour of $0÷0$. For instance if ⎕DIV=0 then $0÷0$ will return $1$ and if ⎕DIV=1 the...
I have a formula which cannot be expressed in terms of y. fv = (p (1 + r) (-1 + (1 + r)^m) ((1 + r)^(m y) - (1 + x)^y))/ (r (-1 + (1 + r)^m - x)) + c (1 + r)^(m y) I'd like to solve it numerically with some kind of matrix operation. For example with r = 0.05/12 m = 12 p = 1000 x = 0.03 c = 2000 fv = 92988.93 Ca...
I'm trying to say this in my paper: "$M$ is a key-value store, where 1) all keys are unique, 2) $k \in M$ means that the $k$ key exists in the store, 3) $M + (k, v)$ is a new store equal to $M$ but the key $k$ is assigned to $v$, 4) $M - k$ is a new store equal to $M$ but without the $k$ key. Is it possible to omit all...
Is there a way to make implication graph of expression of form : $$ ((x_1 \lor x_2)\lor(x_3 \lor x_2))\land(x_3 \lor x_4)$$ I haven't been able to find any sort of text on this and the usual way to make implication graph like of 2-SAT doesn't really make sense because of the extra OR in between.
I want to know if checking whether a 3-SAT is satsifiable if and only if every clause has at least 2 or all three literal set to true NP-complete? It seems similar to Exact-3SAT but it differs from it as the version of this problem which we'll call Exact2or3-3SAT ,where all literals are positive is trivial as its alway...
Here's a question about semaphore. (True/False) The signal operation can be implemented with spinlocks The answer is false, but I don't know why. I thought the signal operation can be implemented like signal(mutex): C.S. Entry section (including busy-waiting) mutex++ C.S. Exit section So the C.S. Entry se...
Is it possible for an online algorithm to perform better than the optimal solution for the offline version of a problem, and if so, in what circumstances? Doesn't competitive ratio rely on the fact that online algorithm can only reach at most the same performance as the optimal offline solution ?
I'm currently reading Design Patterns: Elements of Reusable Object-Oriented Software by GoF and having trouble understanding the following sentence (page 19, Section 1.6): Composition requires objects to respect each others' interfaces, which in turn requires carefully designed interfaces that don't stop you from usin...
ERROR: type should be string, got "https://complexityzoo.net/Complexity_Zoo:R\n\nRL: Randomized Logarithmic-Space Has the same relation to L as RP does\nto P. The randomized machine must halt with probability 1 on any\ninput. It must also run in polynomial time (since otherwise we would\njust get NL).\nContains RHL.\n\nWhile requiring runtime in polynomial time avoids trivial RL=NL, it also allows running time stored. If an algorithm would on average take $f(n)$ steps, then trying to run $100f(n)$ steps would only have 1% chance of not halting, and rejecting in this case doesn't harm.\nSo why only \"Contains RHL\" shown?\n\nAnswering D.W.\n\nWhat does \"allows running time stored\" mean?\n\nLogarithmic-Space allows storing polynomial-size integer\n\nWhat do you mean by \"rejecting doesn't harm\"?\n\nIf X is in RL, then there's an algorithm that accept for 51% chance for input in X, and we can construct one that accept for 50% chance and never fall into infinite loop\n\nWhy do you think the two classes should be equal? Their definitions are different.\n\n\nRHL: Randomized Halting Logarithmic-Space\nHas the same relation to L as RP does to P. The randomized machine must halt for every input and every setting of the random tape.\n\n"
In "Modelling Computing Systems: Mathematics for Computer Science", I came across a logic exercise to inductively define a merge sort function 'mergeSort', with a hint to first define auxillary functions 'split' and 'merge'. The style of the logic so far looks like this for inductively defined sets Odd and Even, and so...
While I was learning the Constraint Satisfaction Problems, I analyzed the Knapsack problem(https://www.csplib.org/Problems/prob133/) and I saw the approach with the neural network was not the best approach in solving this problem since it has not shown the best results. Knowing that the neural network approach has show...
Would it be correct to say that on a operation with a Non-regular language (L) with a Regular language will always return the language L? I'm came across a property that when we intersect a non-regular language (say L) with Regular Language the resultant result will always remain in Language L. $L \cap Reg = L$ Does th...
I am looking for all possible ways to find and eliminate ambiguity in CF grammar. Please share your knowledge or opinion (preferably you will indicate the literature so that I can familiarize myself).I know that it is impossible to check whether the grammar is ambiguous and there is no 100% solution, but I need to cons...
This question:Complexity of deciding the satisfiability of a quasi-monotone CNF formula asked whether quasi-monotone SAT is NP-complete or not ? I want to know if the restricted version of this SAT that is quasi-monotone 3-SAT is NP-complete or not, in this restricted quasi-monotone 3-SAT each clause has exactly 3 lite...
A question in a textbook says, suppose the regular Clique problem, which takes as input a graph G and a natural number k, and returns whether or not G has a clique of size >= k, can be decided in time T(n) (for some function T: N → N) where n is the size of the input. Then, prove that the problem of finding the size of...
I'm trying to know what is the exact function in medium term scheduler in operating systems. As far my understanding, a process may be needed to be removed from the running queue when it is faced with an I/O request. So it is usually sent to blocked list which is also situated in the main memory. Medium term scheduler ...
I'm studying the algebraic view of automata theory. One of the basic results is that the syntactic monoid of a language $L$ is the transition monoid $M(A)$ of the minimal automaton $A(L)$ accepting $L$. It is also very easy, from a monoid $M$ and a morphism $\mu:\Sigma^*\to M$, to build an equivalent deterministic auto...
Studying for the exam in "Advanced Algorithms" course. I'm trying to solve the following question: This question discusses a search operation for a vertex x in a splay tree. Determine how the depth of the vertices changes along the route from the root of the tree to x when, during the splay to the root, zig-zag and zi...
To be more precise, Is ~(a+b) = ~a + ~b? Here, "~" bitwise NOT operator. I ran into this question while thinking about the 2's complement, which adds 1 to ~x (i.e., -x = ~x + 1). Suppose we are given -x (in binary), and we need to find x (in binary). We can do this by computing x = ~(-x-1), but computing -x-1 (by hand)...
f(n) = log n^2; g(n) = log n + 5 => f(n) = Θ (g(n)) I think we can prove this for omega but how can we prove it for Big oh ? because if we simplify it to logn + logn <= logn +5 => logn<=5 is not true !
All the sources I find on the internet say the time complexity of quick sort is worse if: input array is sorted and we choose the leftmost element as the pivot input array is sorted reversely and we choose the rightmost element as the pivot I am wondering if time complexity is still $O(n^2)$ if we do the following ...
As we all know, 3-SAT is NP-hard. Two of the less known results are that Planar 3-SAT is NP-hard and also a 'restricted' 3-SAT, where any literal appears in at most two clauses turns out to be NP-hard. My question is if there is any known result on what happens if we combine these two conditions? That is, suppose we ar...
I'd like to implement pagination for an API. The elements are ordered by time but there can be multiple elements with the same timestamp. So there can be some duplication between the last elements of the previous page and the first elements of the next pages. So far the de-duplication is handled on the client side by k...
As the title says, I'm trying to solve the question where: Input: A directed tree $T = (V, E)$. Output: The maximal subset $A \subseteq V$ of vertices such that there doesn't exist any two vertices $u, v \in A$ that have a directed path between of distance $2$ or less. I thought of starting to append all of the leaves ...
I found a grammar for this language. $S->caZac |cccc $. $Z->aZa | cc$ But if I try to use pumping lemma for context-free languages on $L$ with the word: $ca^ncca^nc$ I obtain it's not context-free. How is it possible?
I am reading about algorithms to find the shortest path on a graph with one source, and I have a doubt about Dijkstra's algorithm about the negative weights on edges. In this case is Bellman-Ford algorithm a better solution for this part?
This might be a a simple and for some a silly question as well. If I buy two hard drives and have windows in one and Ubuntu in the other, can I work with both two systems(one at a time). Example, I wanna edit a photo and I quickly need to go to Adobe Photoshop, so I plug in the Windows harddrive and start editing, then...
If an array is stored from lower region of memory to higher region, we've this indexing formula. $$ Address (A[i]) = M+(i-L)*w$$ Where: M = memory location where first element is to be stored. L= Lower bound for index i = index w = word length But for the case in question, we have: $$L<i<U$$ $$A_i > A_{i+1}$$
We have an array of n measurements: (m_0, m_1, ..., m_n-1). The measurements are voltages, but that's not important, so let's say they are just numbers. The measurements can be positive, negative or zero. There are no NaNs or infinites, only "regular" numbers. We are given a certain non-negative threshold. We want to f...
We were given a question in class as follows: You have a "magic oracle" that can decide if a Turing Machine halts. You have three TMs $T_1, T_2, T_3$. Device an algorithm that decides which of the TMs halt and which do not by asking the oracle at most twice. The sketch of the solution given was Construct a new TM $T_A$...
A question is asked in the below link, which asks for the number of cases we can partition a multiset, where each part/segment in the partition has distinct elements. https://math.stackexchange.com/questions/4622246/how-many-ways-we-can-partition-a-multiset-where-each-part-segment-in-the-partit?noredirect=1#comment9752...
Here's a question in the OS textbook about calculating the cpu utilization. I've tried to write down the (A) by myself as below. (35+303)/((3+0.05)5 + (30+0.05)3) = 99.6xx% But I'm not sure if it is right.
In a sorting algorithm, While computing the complexity of an algorithm why do we only account for the number of comparisons done but not the number of swappings done? And what's the formal definition of complexity?
We know that the P language class is a polynomial-time solvable language class, and the NP language class can be determined in exponential time. And there exist some languages that can be decided only in exponential time and no polynomial time solution has been found yet, such as SAT language. My question is whether th...
(15 marks) Suppose a ray comes from a point (2, 8) and hits at mirror point (6, 6). Assume that perpendicular vector a point (6, 6) is ̅= (0, 3). Find the reflection emitting point from (6, 6). [Assume 2-D coordinate system, you must draw the appropriate diagram of your solution] I'm pretty sure I can figure out the di...
I have a directed graph $G(V,A)$ with arc costs $c_{ij} = \alpha_{ij}1_{x_{ij}>0} +\beta_{ij}x_{ij}$, where $\alpha_{ij}$ and $\beta_{ij}$ are, respectively, a fixed cost and a cost per unit of flow pushed along arc $(i,j)$. I'd like to solve the minimum-cost flow (MCF) problem in this graph, i.e., given a supply/deman...
I'm trying to learn the implementation of the Monte Carlo method in R language. I am following a course with an example of predicting results for a board game. What I'm not understanding is the usage of a function that was implemented on the top of the code, and that is: set.seed(5678) Do you know what this function i...
Can you verify this like please bro please tell me the answer to my question
$P$ is the language class that is decidable in polynomial time by a deterministic Turing machine. $NP$ is a language class that is decidable in polynomial time by non-deterministic Turing machines and can be decidable in exponential time by deterministic Turing machines. So are there any other language classes of time ...
I need to implement my own red-black tree and I am stuck with deletion. I have found this book (Introduction to Algorithms) (p.222) and in the following code I can't understand this marked line. Firstly, why do I need to do that if x.p is already pointed at y, because it is in particular y.right.p (== y). Secondly, wh...
Is there a $O(nlogn)$ time algorithm for computing $p(x)=\sum\limits_{i=0}^na_ix^i$ ? I think with the method below I get O(n), but I need O(nlogn) Hint: there's a way to calculate $x^i$ more efficiently. This is exactly what I'm doing right ? x = v total = 0 for coef in coefs: total += coef * x x *= x retu...
Problem In the problem, I was given the grammar for a non-deterministic finite state automata (NDFSA). There was no other useful context given. The problem asks you to use this grammar to draw the NDFSA and then asks you to convert the NDFSA into a deterministic finite state automata (DFSA). The grammar is written as s...
In graph G: a cycle $A$ is a subcycle of cycle $B$ if there exists vertices $c$ and $d$ such that: $cd$ is an edge of $A$. $F$ is the resulting path of $A$ after removing the edge $cd$. $E$ is a path from $c$ to $d$ of length at least $2$, and the cycle $B$ consists of the edges in $E$ and $F$ For example: In the gra...
I want to know if checking whether a a set of 3-literal clause is satisfiable such that every literal in each clause is either all true or all false NP-complete? By 3-literal clause, I mean it can have a clause can have at most 3 literals. I think this problem is NP-complete or co-np complete as it seems like a complem...
The permuted kernel problem is NP-complete problem by simple reduction from partition problem. In fact, it is strongly NP-complete by reduction from 3-partition. The literature points to Garey and Johnson for the reduction from 3-partition. I checked G&J but did not find the reduction. Do you have a reference that cont...
The problem that I'm trying to solve is: Given an array of length N, I want to find the length of the longest palindrome in the given array. With palindrome, we refer to a word, phrase, or sequence that reads the same backwards as forwards. For example, if we give as input "1234321789" the algorithm should return 7. I ...
I'm trying to find the time complexity of T(n) = 1600T(n/4) + n! . So far I have thought of changing n! to something usable by the master theorem. Stirling's approximation gives us the equation $$\sqrt{2\pi n}\left(\frac{n}e\right)^n$$ I am confused on whether the value for d in the master theorem would become n or if ...
I have a math problem I need to solve so I can complete an optimisation in a computer program. My initial approach was just to brute force all the possible permutations but it got out of hand quite quickly for larger sets. Here's the problem Let's say you want to take n bets each with odds k. We want to optimize the am...
I'm currently investigating the computational complexity of a modified one-dimensional Suguru puzzle. The general Suguru puzzles were recently proven to be NP-complete (see here). My investigation considers a modified one-dimensional Suguru puzzle played in a $1 \times N$ grid of cells. These cells are grouped into one...
This questions is about the work A novel similarity-search method for mathematical content in LaTeX markup and its implementation. The parser used by Wei Zhong is LALR. Now, supose I have to parse a function $func(foo)=bar$. How is the parser able to understand the "$func$" as a whole string representing the name of a ...
This questions is about the work A novel similarity-search method for mathematical content in LaTeX markup and its implementation. Mr. Wei Zhong uses flex lexer generator. Now, supose I find an expression like $\pi(x)$, the Prime-counting function. How to represent the prime-counting function correctly and not interpre...
I was given an assignment in which I had multiple recurrence relations and I had to find their Big-oh time complexities. Nearly all of the recurrence relations were of the form as under: $$T(n)=aT(n/\alpha)+bT(\beta n/\alpha)+f(n)$$ So I tried to find the general Big-oh complexity, so that I could solve each one just...
Given an arbitrary (potentially ambiguous) context free grammar $G: \mathbb{G}$, and string $\alpha: \Sigma^\ast$, is there a decision procedure that returns whether appending and/or prepending symbols can alter the parse forest of $\alpha$? In other words, we want a function $F: (\mathbb{G} \times \Sigma^\ast) \righta...
So I have an undirected graph G(V, E). We may assume there is always at least one path between any two vertices. I want to efficiently check if there are at least 2 different paths between x and y that have no vertices in common. (I'm pretty sure that) Equivalent problem would be to find if all paths between x and y go...
What is the smallest NFA that could be design for a^n where n!=1003? I have been racking my brain at this for a while but still can't reduce the number of states required from 1004. Here state(1003) will be a rejecting state and all the other previous state will be accepting state. A transition from state(1003) to stat...
While working on a math problem the following tree structure came up: o \ o / o / \ o o / \ / It is a binary tree with the following constraints: all nodes except the root have a left child all left-child nodes have a right child none of the right-child nodes have a right-child It als...
I am looking for an efficient CNF encoding of the following situation: I have sets of boolean literals $A = \{ a_1, \ldots, a_m \}$, $B = \{ b_1,\ldots, b_n \}$ and subsets $B_1, \ldots, B_m$, where for all $i$ we have $B_i \subseteq B$ and $|B_i|\le 10$. I would like to encode the constraints $$ a_i \to \bigwedge_{b \...
If $L$ is a decidable language, $M$ is a Turing machine that determines $L$. For $\forall s \in L$, M accepts, and for $\forall s \in \overline{L}$, M rejects However, my question is that If $L$ is a recognizable undecidable language and $M$ is a Turing machine that recognizes $L$, for $\forall s \in L$, M accepts and ...
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$. While giving a reduction from $L$ to $\Sigma_3$-SAT o...
Consider array $A=(a_1,a_2,...,a_n)$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=(5,7,4,2)$ and we decrease $(1,0,0,1)$ from it, it will become $(4,7,4,1)$. We cann...
When using the Baum-Welch algorithm to train a hidden markov model you normally repeat it on some observed sequence iteratively until your values converge. If you have multiple observed sequences, Wikipedia tells you to run the update on all sequences in parallel and then combine them into a new model and then apply th...
Hi i am practising standard theta notation: How could i find the standard theta notation of the following : 2n + 3n^2(log n)^3 + 2 and ((2n^2 + 7n+5)(7n+1))/7 So far i have used the "drop constants and find dominating term" strategy where we remove the constants from the expressions and then we find the biggest and d...
I understand range updates in segment trees using lazy propagation where each node is an integer. Merge Sort Tree (source GFG): https://media.geeksforgeeks.org/wp-content/uploads/20220722205737/MergeSortTutorial.png But when it comes to merge sort trees (segment tree of sorted arrays as nodes), how does one perform ran...
I want to study the reduction from the Diophantine Equation Problem (Hilbert's tenth problem) to the Halting problem. Can you either explain it to me or give me a credible source from which I can study it?
I was watching some lectures by Prof. Pfenning on Proof Theory. Between 5:30 and 15:00, he gave a list for some different kinds of judgments along with their calculus and computation phenomena that they can represent or model. I am looking for a more comprehensive list. I would like to compare and know the advantages a...
I am writing an N-body simulation in C++ that has to be able to deal with large N ($N \le 10^6$). Everything has been going well so far, but now that I have started to code in collisions between bodies (which can result in mergers - which means that one body is added to the system and two are removed) I cannot help but...
The definition of P is given by the union of all DTIME($n^k$) languages for $k >= 0$, where DTIME($n^k$) is the set of languages for which there exist a TM time-bounded by $T(n) = O(n^k)$. However, this is where my confusion lies - if $T(n) = O(n^k)$, then $T(n) <= c.n^k$ for $n >= N$; but does this mean the TM can run...
My idea was that it is because we can construct a TM M' that simulates a TM M that is to find a solution for a PCP instance. M' accepts if M accepts, rejects if M rejects, and doesn't halt if M does not. But I'm confused about the fact that in such a way we can also construct a TM M'' that simulates M. It rejects if M...
I was studying the Barrington Theorem in https://homes.cs.washington.edu/~anuprao/pubs/CSE531Sp2020/lecture2.pdf when I found a doubt regarding permutations. Particularly, with conjugations. It is said, in the 2nd page, 4th point, that two cyclic permutations $\pi$ and $\sigma$, always have a permutation $\tau$ s.t. $\...
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: $\triangledown$ puts an apple in the bag and $\triangle$ takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the rob...
Given a group of cities and a starting city, we have to find a path that covers all the cities. The path doesn't need to end at the starting city. Is this a TSP problem? What is the solution for it? This is not a homework problem or an interview question. I asked ChatGPT to find the shortest paths covering 5 random cit...
I'm studying for the Algorithms and Computability course. I have encountered a problem that I cannot solve and cannot find any materials to help me solve it. It's the following PCP problem: We have two sets: A = (b, a, ca, bac) B = (ca, ab, a, c). The task is to find a solution to the given PCP problem or prove that th...
Given a number n, the task is to find the XOR of every number from 1 to n. Why does the following algorithm work? Find the remainder of n by moduling it with 4. If rem = 0, then XOR will be same as n. If rem = 1, then XOR will be 1. If rem = 2, then XOR will be n+1. If rem = 3, then XOR will be 0.
I was wondering if the combination of Horn-SAT and XOR-SAT is solvable in polynomial time or not. It seems they can be solved in polynomial time as both are in class P and also that Horn-SAT is P-complete thus XOR-SAT must be reducible to HORN-SAT . Just want to clarify if that's the case. By,HORN-sat with XOR relation...
In this paper they prove that the number of rotations after doing $n$ insertions or deletions to a weight-balanced tree is $O(n)$ (when starting from an empty tree). What isn't clear to me though is how many times each node becomes the new root of a sub-tree after a single or double rotation takes place. Intuitively, I...
Use equation (3.14) or other means to show that $(n+o(n))^{k}=\Theta\left(n^{k}\right)$ for any real constant $k$. Conclude that $\lceil n\rceil^{k}=\Theta\left(n^{k}\right)$ and $\lfloor n\rfloor^{k}=\Theta\left(n^{k}\right)$. Where equation (3.14) is: $1+x \leq e^{x}$
In this post,Monotone$(+, 2^-)$-SAT problem is defined as follows: Given a monotone CNF formula $F^+$, where each variable appears exactly once (as a positive literal), and a monotone 2-CNF formula $F_2^-$ defined on the same variables as $F^+$, where all variables are negated. Is $F^+ \land F_2^-$ satisfiable ?), let ...
Prove that: $\lg (\Theta(n))=\Theta(\lg n)$
Say for example I'd like to state that there exists a pair of vertices such that they form an edge in one graph but not some other graph. I'd go about it as follows: $$ \exists u, v \in V, (u,v) \in G, (u,v) \not\in H $$ My main question here is: Is my use of commas fine (it seems odd, since there's commas between $u$ ...
The Question I define the language$$\mathsf{2-SIMPLE-PATH}=\left\{ \left\langle G,s,t\right\rangle \left|\begin{array}{c} \mathsf{there\;are\;two\;different}\\ \mathsf{simple\;paths\;from}\;s\;\mathsf{to}\;t\;\mathsf{in}\;G \end{array}\right.\right\} $$ where $G$ is a directed graph. it's easy to show using a reductio...