instruction
stringlengths
35
29.1k
I am trying to compute the Follow set of the following Grammar: E -> E' E A A -> + | * E -> num E' -> num I start by adding the end of string symbol, via. some non-terminal S such that: S -> E$ E -> E' E A A -> + | * E -> num E' -> num Becomes the Grammar. With this I get the following set constraints for the product...
I'm stuck with the following problem by Skiena (The Algorithm Design Manual, p. 106): Problem: Give an efficient algorithm to determine whether two sets (of size $m$ and $n$, respectively) are disjoint. Analyze the worst-case complexity in terms of $m$ and $n$, considering the case where $m$ is substantially sm...
Let's say I've finished my compiler for my new language. Next step is write a custom editor with syntax highlighting (type checking and semantic can wait), is there a cookbook or any kind of guidance to accomplish this project?
Suppose there exists an algorithm that takes as input an unsatisfiable SAT formula, and never fails to verify it in polynomial time. However, when the input is a satisfiable formula, it doesn't work (let's say time and memory problems, the algorithm gets lost in the reasoning). Then Co-NP = P because we can verify uns...
i think the above is incorrect; specifically, i think H isn't bijective. say our alphabet is the lowercase letters [a-z] and that char(a) = 0. then, e.g., H("abc") = H("bc"). am i missing something?
I'm taking a class. In this class every week we have a partner. There are an even number of people in the class. We'd like avoid having repeat partners if possible so that everyone gets to work with as many people as possible. I'd like to know how many weeks we could accomplish this before we're forced to partner someo...
Given a undirected graph which only has two different edge weights $x$ and $y$ is it possible to make a faster algorithm than Prim's algorithm or Kruskal's algorithm? I saw on Kruskal's algorithm that it already assumes that the edges can be sorted in linear time with count sort, so then can we gain any benefit by know...
I have a hashtable with length $m$. Initially it's empty. Next, $n/2$ unique random numbers $\in [0, n]$ are added to it. What would be variance of chain length when such $n/2$ numbers are being added $x$ times? I tested it using code with $n=2^{16}$, $m=2^{15}$ (part of md5 was used as index) and got the following res...
Suddenly a thought came to my mind and I thought of resolving it as follows. We know that: String is a finite sequence of symbols from an alphabet $\Sigma$ i.e. we cannot have an infinite sequence representing a string, which means there is no definition such as $w = "abcabe...........$ which is unending Now when we co...
Exercise 3 from https://massimolauria.net/courses/2015.ProofComplexity/lecture6.pdf Consider the set of inequalities $x_i+x_j\leq1$ for $1\leq i<j\leq n$. Find a derivation of $\sum_{i=1}^n x_i\leq 1$ in $O(n^2)$ length. If it were just algebra I could just show by contradiction that at most one $x_i$ could be 1 and ...
I have been asked this question, but don't know how to go about answering it. Three process, which are implementing Lamport's clocks, are running and a lot of events are taking, place including some messages being sent between the processes. The arrows and circles represent in-processor events and messages being sent ...
I'm trying to figure out the running time for a Dijkstra algorithm. All the sources I have read say that the running time is O(E * log (E)) for a lazy implementation. But when we do the math we get O(E * (Log(E)+E*Log(E))). Since E isn't a constant, I don't see how someone could reduce this to O(E * log (E). Are we a...
Say I have a deterministic turing machine which solves decision problem S with oracle access to both problems B, C that are in $NP$. Can S be solved with oracle access to only one problem in $NP$? That is, can B and C somehow be combined into one problem in $NP$ (thus showing S is in $P^{NP}$)?
Given a square matrix of size N X N (1 <= N <= 1000) containing positive and negative integers with absolute value not larger than 1000, we need to compute the greatest sum achievable by walking a path, starting at any cell of the matrix and always moving downwards or rightwards. Additionally we also have to find the n...
I would like to determine if the following language is decidable or not. L = { w $\in$ $\Sigma^*$ | $T(M_w)$ is recognized by a Turing machine with at most 42 states}. I know that every finite language is decidable, but I am not sure if this has anything to do with this particular problem. Every help is appreciated, I...
I need to get feeling for the feasible size of a LPP, that can be solved on a PC. Say, its a good one (8 cores @ 3+GHz, 64GB RAM). We also assume that number of variables is close to the number of additional conditions. I know it depends on the solver, but what size is feasible for solution in several hours/few days? ...
Our local ninja Naruto is learning to make shadow-clones of himself and is facing a dilemma. He only has a limited amount of energy (e) to spare that he must entirely distribute among all of his clones. Moreover, each clone requires at least a certain amount of energy to function (m) . Your job is to count the number o...
I have the following alphat {0,1}. I'm told to draw a DFA which fulfills the following: {w|w starts with 1 and ends in 0} This is the DFA I came up with.
I am learning Computer Architecture from Introduction to Computing Systems (2nd Edition) and am stuck on this question. What operations can be used to convert the binary representation of 3 into ASCII representation for 3? What about binary 4 to ASCII or any other digit? The concepts I have learnt until now are Basic...
we have the alphabet {0,1}. {w|w contains at least two 0s and at most one 1} It tried this: (However I'm not sure if it's correct. If it's incorrect why?)
I am well-aware of the result showing that one can convert an epsilon-NFA (that is, an NFA with epsilon transitions) $A$ to an NFA without epsilon transitions $A'$, where $L(A) = L(A')$. Is there a similar result comparing the state complexities of $A$ and $A'$? That is, if one has an epsilon-NFA $A$ with $n$ states, i...
Here is the question: Link. In a gist, we need to count the total count of numbers that would divide every number in an array. The approach that I took was that any number that has to divide all the numbers must be less than or equal to the smallest number in the array. For e.g., if the array is [6 90 12 18 30 18] - an...
My understanding is that symbolic execution only deals with specific paths and bad patterns, while SAT solvers, or satisfiability modulo theories in general, provide a much more robust analysis of the program. Could someone validate the statement above and (briefly) explain the differences between these two formal veri...
i have seen in the "logic to cs" class i take - a theorem that states: "every recursive (computable) function $f$ can be expressed using the arithmetic dictionary {$C_0, C_1, f_+(,), f_x(,), R_\le(,)$} with the structure {$D=\mathbb{N} ,C_0=0,C_1=1, f_+(a,b) =a+b, f_x(a,b)=ab, R_\le(a,b) = a\le b $}" But we didnt prove...
I am currently studying Algorithms, Fourth Edition by Sedgewick et al. On page 226, there is an analysis of the quick-union algorithm's find() method's worst case. This is the algorithm: private int find(int p) { // Find component name. while (p != id[p]) p = id[p]; return p; } Suppose we have origi...
I am trying to calculate the Time Complexity of the Recursive Function, suppose this, function T(int n){ if(n == 1) return 1; return T(n-1) + T(n-1); } the time complexity equation is: T(n) = 2T(n-1) + C, taking C = 1 and T(1) = 1. Now, since I am working on this, I am confused whether I am doing the right process u...
Say we have a place-transition digraph system. A transition can fire if all input places have marks. A transition fires by consuming items from input places and placing one into each output place. A number near the transition is a transition price. So, for example, we can get an image like this: We want to find the ch...
I have a big problem with converting GNF example. This is my CFG $ S \to AS\mid BS\mid \lambda\\ A \to aC\mid BCA\mid c\\ B \to AB\mid b\mid \lambda\\ C \to S\mid d $ I simplified the CFG by removing redundant, $\lambda$-production, unit production. $ S \to AS\mid BS\mid BA\mid CA\mid AB\mid BCA\mid aC\mid a\mid b\mid ...
Background: I have a .yaml file which holds around >3000 elements. The elements are related to each other through a recursive relationship. I want to create a tree view containing those items. A good algorithm is needed, since I also have other .yaml files with more items. Question: How can I convert a tree with recurs...
what is the time complexity of the following code. please help me. // a is mxn matrix for i = 1 to m: l = {} for j = 1 to n: if(a[i,j] != 0): add j to l if(len(l) > 1): for k=1 to len(l) for j=k+1 to len(l): some other code
I want to know why $\text{DSPACE}(O(1))=\text{REG}$, especially in the direction of why all languages in $\text{DSPACE}(O(1))$ can be recognized by a finite automaton. I've thought for some time and know that the idea is to encode the finite possibilities of memory as finite states, and also have read https://cs.stacke...
Consider two index sets $S = \{0, 1, 2, 3, 4, ..., N - 1\}$ and $Q = \{0, 1, 2, ..., \frac{N(N + 1)}{2} - 1\}$. Let $R = \{(a, b)\space |\space a, b \in S, a \ge b\} = \{(0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (2, 2), \dots\}$. There will be $\frac{N(N + 1)}{2}$ elements in $R$. Is there a one-to-one function $f : Q \t...
Stoer-Wagner algorithm can be used to find global minimum cut in a graph. I'm wondering if it could be adapted to find a minimum s-t cut, given s and t. We can start a single phase with {s} but there's no guarantee that vertex t will end up in the other subset. Is there any way to do it?
I am building an app where a user controls inputs via multiple sliders each with discrete steps. The app then uses the combination of slider values to run some calculations and returns back an output value. The sliders are meant to be highly responsive, so the user can immediately see the impact of their input combinat...
im looking for a formal proof to demonstrate that all regular language is in L (logarithmic space). I deduced that all regular languages has a DFA that accept them, so if i find a way to transform all DFA to a L-Space Turing Machine, i would be able to prove this. Thanks for helping.
Let us start this question out, by defining for a Turing machine, the set of words it doesn't halt on. Define: $P(M)=\{w\in\Sigma^*|M$ doesn't halt on $w \}$ We know that the $HALT$ problem is $RE\setminus R$ - thus every TM $M$ that computes $HALT$ has a word it doesn't halt on, i.e $P(M)\ne\emptyset$. From this, aris...
First question: How would one prove that by removing free (unbound) variables from lambda calculus, and allowing only bound variables, its power is not reduced (it is still Turing-complete) ? Second question: Is the proposition given above really true? Is lambda calculus sans free variables really Turing-complete?
Is something like this possible: You have state A,B,C all pointing towards accepting state D. Is this allowed? Where online can I find a list of rules that define how an automata must be drawn or conceived?
I'm asked to draw a DFA of this {$\epsilon$, 0} but have no clue what it means. Can someone help me understand what the automata is supposed to do? I know that $\epsilon$ is the symbol for empty word. As an example having to make an automata for this {w| w contains at least two 0s and at most one 1} is pretty understa...
Can you enumerate a class of languages in such a way that the description of every language/ machine enumerated encodes where it was in the enumeration? Ex:if you are given the description of the bth machine/language enumerated you could quickly check, by some tag or marker in the description of the bth machine / langu...
I have a language $$ L = \{ww^R, w \in \{ab\}^5\}$$ I know this is a regular language because it is finite (since w can only be of length 5). I want to prove it's a regular language, so I'd create a regular expression for it. Theoretically, my regular expression could be the union of all strings in the language, but is...
I have a function whose time complexity is given by the following recurrence: \begin{equation*} T(n) = \begin{cases} \mathcal{O}(1) & \text{for } n=0\\ T(k)+T(k-1)+\mathcal{O}(1) & \text{for } n=2k\\ T(k)+\mathcal{O}(1) & \text{for } n=2k+1\\ \end{cases} \end...
I have a point's array of some 2d shape(polygon). The polygon could be either crossed or convex, I don't know it. And I want to join those points in the correct order. My first thought was to take some point as an origin and start looking for the closest one and so on. But this approach doesn't work for some crossed p...
Came across this in a book, and I'm wondering why the following language is regular? $$ L = \{a^nww^R: n \geqslant 0, w \in \{a,b\}^3\}$$ Is it correct to say that $$ \{a^n : n \geqslant 0\} $$ is a regular language because it can be expressed by a regular expression $$a*$$, and $$ \{ww^R: w \in \{a,b\}^3\} $$ is a reg...
Do any one give me some hints to solve this problem. Explain is steps by steps.Thanks
So as the title says i m trying to find this NFA. So far i thought to make an NFA that "guesses" what comes after the first 0 and i got this: After some time trying to get rid of all the extra (7 !) states i put in i got to this beauty: But now i cant figure out how to get rid of the one extra state. Also if you hav...
I developed an algorithm that transforms any simple connected graph, cyclic or not, into a tree. The resulting tree is syntax-preserving, in a sense that it allows to reconstruct the original input graph and only the original input graph. In other words, the constructed tree preserves adjacency information, while resol...
Let’s say I have a JavaScript loop iterating over input of size N. Let’s say all elements in N are unique, so the includes method traverses the entire output array on each loop iteration: let out = [] for (x in N) } if (!out.includes(x)) { out.push(x) } } The worst case runtime of the code inside the loop seem...
$L=a^*b^*c^* \setminus \{a^n b^n c^n \mid n \geq 0\}$ can be proved as context-free by partitioning it as $L = \{a^nb^mc^* \mid n \neq m\} \cup \{a^*b^nc^m \mid n \neq m\}$ and further dividing each $\neq$ into smaller and larger. You will have four sets. You can give CFG's for each. Then since CFGs are closed under un...
I was given a question and don't really know to solve it. Given a regular language $L$, is the following language also regular? $$L_1 = \{ w \mid \text{each prefix of } w \text{ of odd length is in $L$} \}.$$ I think that $L_1$ should be regular, but I don't have a clue how to prove it. Thank you for any input.
An enumerator is defined as a 7-tuple: https://en.wikipedia.org/wiki/Enumerator_(computer_science) A Deterministic Turing machine is defined as a 7-tuple: https://en.wikipedia.org/wiki/Turing_machine How are these definitions different? Can a DTM M simulate an enumerator E, for part of its computation can it call an en...
In all the examples I have seen, the pumping length $p$ is not specified. The string is a pattern that somehow has the $p$. E.g. when proving $L=\{a^n b^n c^n | n \geq 0\}$ is not context free, we assume the string $s \in L$ has the form $a^pb^pc^p$, and continue. Do we have to select such a general pattern? E.g. Can I...
Here is the full problem. You need to calculate Euler's totient function of a binomial coefficient $C_n^k$. Input The first line contains two integers: $n$ and $k$ $(0 \le k \le n \le 500000)$. Output Print one number $\varphi (C_n^k)$ modulo $10^9+7$. My thoughts: It is known that $$\varphi(a)=a \prod_{p|a}(1-\frac{...
In this book ‘Theory of computation’ By Dexter Kozen on page 313,exercise 127 he says "A set of total recursive functions is recursively enumerable (r.e.) if there exists an r.e. set of indices representing all and only functions in the set. For example, the complexity class P is r.e., because we can represent it by an...
I have found that X + Y sorting is an open computer science problem but that book was too old and then I have google it but didn't find any strong evidence that it is still open or there is an algorithm that can solve it in O(n2) comparison without using Fast Fourier Transform. Is there any algorithm proposed that can ...
I can't seem to find a solution to the following question. Given the following grammar for palindromes: $$G_{pal}=\{\{a,\dots,z\},\{P\},P,R\},$$ with $R$ consisting of the rules $$P \to \epsilon \mid a \mid aPa\text{ for every }a \in \Sigma.$$ Prove that every palindrome $w$ is in $L(G_{pal})$: $$w = w^r \longrightarr...
I'm wondering if PDAs with more than one initial states are also accepting context free languages. If found that question on this site about NFAs and would like to know if this answer is also valid for PDAs if one defines a new single initial state and connects this with the former initial states using $\epsilon : \e...
Decision Problem: Given a set $S$, is there at least a given $N$ $>$ $1$ amount of solutions, for an $Exact~Cover~by~3-sets$ for $C%$? $s$ = $1,2,3,4,5,6$ $c$ = $[[1,2,3],[4,3,2],[4,5,6],[5,1,6],[5,6,3]]$ Solutions $[1,2,3],[4,5,6]$ $[4,3,2],[5,1,6]$ $N$ = $2$ Yes, there are $N$ solutions. Algorithm Remove sets that ...
Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 3 (The data link layer), Page 213: When the polynomial code method is employed, the sender and receiver must agree upon a generator polynomial, $G(x)$, in advance. Both the high- and low-order bits of the generator must be 1. To compu...
Given two regular languages $A,B$ on the same alphabet $\Sigma$, I want to show that the following language is regular: $$ \{a_1b_1 \ldots a_kb_k \in \Sigma^* \mid a_1,\ldots,a_k,b_1,\ldots,b_k \in \Sigma,a_1\ldots a_k \in A, b_1\ldots b_k \in B\}. $$ However I simply do not understand how I'm supposed to do this. Simp...
I have two 4-bit 2's complement numbers a,b, and their sum in s (Also a 4-bit 2's complement number). Using only the basic logical operations, I need to write a procedure to find if an overflow occurs. If there is an overflow, the output needs to be 1000 otherwise it is 0000. The inputs in this procedure are a, b, s, ...
A computer has a cache memory and a main memory with the following features: - Memory cache access time: 4 ns - Main memory access time: 80 ns - The time needed to load a line in cache is 120 ns. - Write-through policy. If the hit ratio in this computer is 95 % and the 90% of the memory accesses are read opera...
I am having trouble finding the PDA with 1 state for this one. So far my solution is this but i cant figure out how to get to 1 state. Alphabet: {a, b}, Stack alphabet (the first symbol is the initial one): $ S (this can be changed,i just wrote these 2), Acceptance condition: empty stack, Deterministic (DPDA): false T...
What is the difference between the Magnitude and the Phase Spectrum of the Fourier Transform?
The problem I have two sets of numbers and need to find a mapping between those two sets, so that the total distance between two mapped numbers is as small as possible. Two numbers must not be mapped if they are farther apart then 0.18. As many numbers should get mapped as possible. Also, the sets are not necessarily t...
i encountered the following problem: Exact2IS ={G has exactly 2 independent sets} Assuming that given a graph G i can find an independent set how can i check if G has exactly 2 independent sets. (i can check if a graph contains independent set in O(1) and also find some independent set in O(1)) I was thinking on find s...
Problem Given data consisting of $n$ coordinates $\left((x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n)\right)$ sorted by their $x$-values, and $m$ sorted query points $(q_1, q_2, \ldots, q_m)$, find the linearly interpolated values of the query points according to the data. We assume $q_i \in (\min_j x_j, \max_j x_j)$ I he...
Is there a simple linear algorithm for finding in an array A two such elements that $A[i] > A[j]$ and $i - j$ is as large as possible? If one wants to actually return the indices, then linear memory usage seems impossible to avoid. If the only result needed is the value $i - j$, i.e. the distance, can we get away with ...
I want to ask about the definition of regular languages. My book says there has to exist a deterministic finite automaton that recognizes it. Does this mean the finite automaton recognizes exactly this language and nothing else or it can recognize possibly some other words not in the language?
I have two DFAs one for language A and one for language B. I'm asked to make an FDA that is the zig-zag concatenation of letters of A and letters of B. This is described by the following: {w: w = $a_1 b_1$...$a_k b_k$ and $a_1...a_k \in A$ and $b_1 ... b_k \in B$}. With $1 \leq i \leq k$ and $a_i \in \Sigma$ and $b_i \...
I have simple graph G on 10 vertices the degree of each vertex is 8. I need to determine the chromatic number of G. I tried drawing and all but it seems there is a trick needs to be used.
While trying to analyse the runtime of an algorithm, I arrive to a recurrence of the following type : $$\begin{cases} T(n) = \Theta(1), & \text{for small enough $n$;}\\ T(n) \leq T(a_n n + h(n)) + T((1-a_n)n+h(n)) + f(n), & \text{for larger $n$.} \end{cases}$$ Where: $a_n$ is unknown and can depend on $n$ but is b...
Let us consider the following Context-Free Grammar G = ({S,A,B,C,D},{a, b}, S, P) with production rules P: S → SSA | Bb A → BSA B → A | Cb C → AD | Cb | ɛ D → a | b | ɛ Let L be the language produced by G. Design a single state Pushdown Automaton that accepts L. Indicate the relevant functions of transitions and draw t...
Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 3 (The data link layer), Page 213: When the polynomial code method is employed, the sender and receiver must agree upon a generator polynomial, $G(x)$, in advance. Both the high- and low-order bits of the generator must be $1$. To com...
I need to implement a system that can schedule and dispatch periodic jobs and needs to support a very high load (millions of jobs per second). Each job in the system has a period that is some multiple of 15 seconds, with the maximum allowed period being 1 day. The system needs to support adding new jobs and removing /...
I have a problem that I need to solve, and I'm looking for which area of computer science (algorithms. etc) would be appropriate to solve this problem. In the system we have a list of actions that a user has previously taken. The possible actions are: User creates item of type A. User creates item of type B. User crea...
I'm trying to understand arithmetic using stacks. Specifically converting infix notation to postfix notation. My question is how you convert an expression like: 1 + (2 + 3) + (4 + 5) that computes in the exact order that the order of operations says. Meaning: 1 + (2 + 3) + (4 + 5) becomes 1 + 5 + (4 + 5) then 1 + 5 + 9...
The question is inspired by the following UVa problem: https://onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=18&page=show_problem&problem=1628. A network of autonomous, battery-powered, data acquisition stations has been installed to monitor the climate in the region of Amazon. An order-dispatc...
I am trying to understand the difference of assignment, binding, and substitution. I know the three things are related, but to me it's not exactly clear what word refers to what. Example, illustration, and citations from computer science wiki/articles/textbooks are welcome.
Assume we have a number of transducers with limited information processing capabilities. Are there theoretical results (proofs) on how these transducers can be combined by some sort of communication into one joint transducer to reach a maximum of information processing capabilities? Does this work for universal transdu...
I would like to try some different proofs, specifically in proving equivalence of the implementation of some feature in two different programming languages (C and JS in this question). This is about proving that replacing one character in a string is equivalent in C and JS. In JS, for example, strings are immutable, wh...
I need to determine all the trees on 25 vertices for which there exists an integer m ≥ 2, such that the degree of each vertex gives the same remainder when divided by m. Can somebody help ?
For a given graph $G=(V,E)$ and a given weight function $W$ lets say we define the new weight for path p to be the regular weight minus the heaviest edge in that path, i.e: $w^*(p)=\varSigma(w(v_i,v_{i+1}) -max\{w(v_i,v_{i+1})) | 1\leq i \leq k$} The complexity needs to be $O(V+E\log V)$. Obviously i thought about dijk...
A Bloom filter is a probabilistic data structure that allows encoding sets with false positives. Parameterized by the number of bits $m$ in the array $A$ (initialized to zeros), and number of hash functions $k$, an insertion of an item $x$ corresponds to setting $A[h_i(x)]=1$ for $i=1,\ldots,k$. Similarly, for testing...
I have an image with gray-scale anti-aliased text produced by Chromium and need to convert this into pure binary black and white text. Applying a simple binary threshold pass over the image causes artifacts, either missing edges or weird protrusions and text being too bold depending on the chosen threshold. Below an e...
I just started reading a book on theoretical computer science and here are a couple of beginner questions about graphs, which I am struggling to answer: Given the graph with the matrix representation \begin{bmatrix}0&0&1&1\\0&0&1&1\\0&1&0&1\\0&0&0&0\\\end{bmatrix} what is its shortest possible unambiguous represe...
I was going through "Discrete Mathematics and its Application" by Kenneth Rosen where I came across the following algorithm of the Insertion Sort and also its analysis. The algorithm is quite different from the one dealt with in the CLRS so I have shared the entire algorithm below. Note that they have considered a mach...
I have a large set of half-planes $a_ix+b_iy + c_i \geq 0$. What I need is is the fastest way to determine if they have at least one common point. Currently I build a convex polygon by adding half-planes sequentially, there are $O(n^2)$ checks if a point belongs to a half-plane. I need an algorithm that does $O(n \log ...
It's sort of similar to bin packing, but instead of the minimum amount of bins,I was interested in just one infinite bin and finding out what's the smallest height you could get when you start packing items there. I was thinking about this because of RCPSP, in case anyone's interested. I already have an algorithm to so...
In Dexter C. Kozen - Theory of Computation (2006, Springer) page 319 exercise 127 he says : "A set of total recursive functions is recursively enumerable (r.e.) if there exists an r.e. set of indices representing all and only functions in the set. For example, the complexity class P is r.e., because we can represent it...
I have the following question: Let $G = (V,E)$ be a directed graph with a weight function $w:E\rightarrow \mathbb{R}^+$, and let $s \in V$ be a vertex such that there is a path from $v$ to every other vertex, i.e $0\leq dist(s,v) < \infty$. Let $f\colon V \to \mathbb R$ a given function. Describe an algorithm that run...
Disclaimer: I'm not a compiler expert, but some of my best friends are! :) I do a lot of embedded systems programming where stack (and other memory) is limited. Most of my code is written in gcc, so I thought nested functions could be useful for reducing stack usage. Here's an example of what I had in mind: (Though ...
Classical DFS: A set of tasks with precedence constraints (saying “u must be done before v”) are given. This problem can be represented by a directed graph. We assume that the graph is acyclic. A DFS is usually used to find an ordering of the tasks that satisfies all of the precedence constraints, classical DFS algorit...
Show by induction that any solution to a recurrence of the form $ T(n) \le 2T(n/3) + c\log_3 n $ is $O(n\log_3 n)$. Hoping someone can help me with the correct solution. I attempted two ways to get the solution (but I think that they're both incorrect): SOLUTION A \begin{align} T(n) &\le 2T(n/3) + c \log_3 n \\ &\...
I'm studying about UFLP using the book The Design of Approximation Algorithms Ch 9 starting page 233 (there is an electronic free edition), I ran into some unclear steps in the book and need some help with it. In few words the UFLF deals with finding a subset of facilities from a given set of potential facility locatio...
I have this assignement that asks to say if the following statement is true or false, and possibly justifying the answer: "Let L₁, L₂ be decidable languages. For every language L s.t. L₁ ⊆ L ⊆ L₂, L is decidable too My first idea was to use the Halting Problem Language as L and show that is not decidable to prove the ...
This is not a technical question, I hope this community has a room for such questions, but I will delete it in case this is inappropriate. It has been experimentally observed (e.g. here) that when choosing a $3$-SAT formula by the following process: On input $(n, \alpha n)$: choose $\alpha n$ clauses uniformly at rand...
E.g. when proving $L = \{w \in \{a,b\}^*:$ the first, the middle, and the last characters of w are identical$\}$, can i just prove $ab^{p}ab^{p}a$ is not regular? Where $p$ is the pumping length?
I have a task to determine the upper bound of states in the Minimal Deterministic Finite Automata that recognizes the language: $ L(A_1) \backslash L(A_2) $, where $ A_1 $ is a Deterministic Finite Automata (DFA) with $n$ states and $A_2$ is Non-deterministic Finite Automata (NFA) with $m$ states. The way I am trying t...
Fix some finite graph $G = (V, E)$, and some vertex $x$. Suppose I generate a random sub-tree of $G$ of size $N$, containing $x$, as follows: Let $T_0 = \{ x \}$. For $0 < n \leqslant N$ i. Let $B_n$ be the set of neighbors of $T_{n-1}$ outside of $T_{n-1}$. ii. Form $T_n$ by Sample a pair $(x_n, y_n) \in E(G) \cap...