instruction
stringlengths
35
29.1k
Okay so we've been given an algorithm and asked to give an upper bound to its best and worst case weirdSort(A,r,p) if r < p q = (r+p)/2 BubbleSort(A,r,q) wierdSort(A,q+1,p) Merge(A,r,q,p) I'm not quiet sure how to do that.. this is my first time analysing time complexity and I'm quiet lost I know that an upper bound...
The problem: I have a list $\displaystyle S=\{s_{1} ,s_{2} ,\dotsc ,s_{n}\}$ places. Each unordered pair of places has cost and gain: $\displaystyle c\{s_{i} ,s_{j}\} \in \mathbb{N}$, $\displaystyle g\{s_{i} ,s_{j}\} \in \mathbb{N}$. Also the pairs are only for $\displaystyle i\neq j$. I have two numbers: $ $$\displays...
Given any regular language L, we define $$shrink(L) = \{ \sigma_{1}\sigma_{2}\sigma_{3}...\sigma_{n} : \sigma_{1}\sigma_{1}\sigma_{2}\sigma_{2}\sigma_{3}\sigma_{3}...\sigma_{n}\sigma_{n} \in L \} $$ The question is whether these languages are regular or not. The intuition says they are, and I was thinking about proving...
I was doing an assignment of Theory of automata but while doing this question I am stuck there is no such state that can be eliminated even from transition table. I am very confused and stuck please help me out
I'm studying the issue of FPT algorithms and came to the k-disjoint triangles problem as can be seen here on slide 60. The problem summary is given a graph G and variable k, are there k disjoint triangles in the graph. There are two methods, I want to focus on one of them. (Method 1) First I randomly color the graph in...
I am working on Problem 6-1 from MIT's Fall 2011 6.006 course. The problem reads as: Problem 6-1. [30 points] I Can Haz Moar Frendz? Alyssa P. Hacker is interning at RenBook (人书 / 人書 in Chinese), a burgeoning social network website. She needs to implement a new friend suggestion feature. For two friends u and v (fri...
The question is: Given a language $L$ (not necessarily regular), prove or disprove that $Eq(L) = Eq(\overline{L})$. Where $Eq(L)$ is the amount of equivalence classes the language L has, and $\overline{L}$ is the complement of $L$. My intuition says the statement is true, but I don't know how to prove it.
I managed to figure out how to double a unary format number however I have had no such success in tripling it. An input tape would be of the following format Λ111Λ and the output would be like Λ111Λ111111111Λ with the tripled number coming directly after the initial input tape. Any help would be greatly appreciated.
Is (A' + B') the same as (A + B)' ? Note: The apostrophe ( ' ) represents the complement
When I think about "compressing" outside computers I can think about a compressed car which has become a metal rectangle. It doesn't have less redundancy because it has everything it had before, just compressed and destroyed (data loss) It's not delivered more efficiently because it's destroyed and isn't restorable by...
Question: What is the difference between designing an algorithm that solves a problem and creating a Turing machine that decides a language? A turing machine "decides" the language if it "accepts" the language and enters a rejecting state for any input not in the language. Don't really know what the difference is
Change propagation in programming environments is an add-on at the framework level such as React. There was a lot of work on dataflow virtual machines in the wake of Backus's Turing Award Lecture on formal functional programming. This is because dataflow programming is one way of thinking about change propagation in f...
I have 10 data sets (lat and long) of the same path. I started from point A and stopped in point B and did this 10 times for a single route to get the data. While collecting the data, there were some fixed obstacles and some random obstacles. So, I avoided them. Doing this 10 times created a fixed curve in every datase...
What is the asymptotic rate of growth of the following recurrence? $$ T(n) = n + T(n - \sqrt{n}). $$ Since I cannot use the Master's Theorem here, I could not figure it out the answer. My initial guess is $n^{3/2}$, but I'm not sure. Can anyone help me? What are the big-O and big-Omega complexities here?
On an old worksheet I came across the question If L1 and L2 are two Turing decidable languages, then show that 1∪2 and 12 are Turing decidable languages (high-level description with stages is enough). How do I go about answering this without being given a language to work from?
I'm learning about the disparity calculations and want to calculate the distance for a known pixel. I have calibrated and rectified images already. Now I just want to calculate Z for some pixel x,y. the opencv tutorial says: "The depth of a point in a scene is inversely proportional to the difference in distance of co...
The SUBSET SUM decision problem consists of poitive integers a1,...,an; b. We wish to know if for some subset S of the indices, $\sum_{i \in S}a_i = b$ I want to prove that if b is given in unary(and the ai's are gives in binary), that this decision problem is in P
In a typical data structures class, we look at a variety of problems: finding an element in a list, sorting a list, balancing a binary search tree, finding the shortest paths in a graph, etc. Would these problems be decidable or undecidable? Wouldn't the answer to this question be both, because decidable means a clear ...
I'm specifically referring to this group of questions here: https://www.cs.rice.edu/~nakhleh/COMP481/final_review_sp06_sol.pdf So as I've learnt it, say we want to prove a new Language L is undecidable using a known undecidable language D, we use Oracle calls to L to solve an instance of D right? In none of these quest...
Assume that $L_1 \subseteq \Sigma^*$ is a CFL and that $y \in \Sigma^∗$ is a string. I need to prove that the language $L_2 = \{x \in L_1 \mid x \text{ does not contain $y$ as substring}\}$ is a CFL. I tried pumping lemma for CFLs, but it seems that is for disproving that languages are CFLs. I also tried to create a CF...
As far as I understand defragmentation: Removes spaces between objects by putting objects nearer one to the other reorganizes objects for better performance The first action feels to me as some kind of minification and the second action feels to me as some kind of compression.
Let $X_1, \cdots, X_n$ be $n$ independent geometric random variables with success probability parameter $p = 1/2$, where $X_i = j$ means it took $j$ trials to get the first success. Let $S_d = \sum_{i=1}^n X_i^d$ and $\mu_d = \mathbb{E}\left( S_d \right)$. Given $\delta > 0$, I am interested in finding an inequality of...
I'm having difficulty understanting how can i prove that L = { w | w0 is the representation of a turing machine M with input {0, 1} and M don't accept w } is not turing-recognizable The solution I have is by contradictio. Reduce w0 to w Suppose a TM M', L(M') = L Suppose that w' ∈ L w' is the representation of a turin...
I genuinely don't know if the following problem is NP-hard. I have never seen it mentioned online, but it's hard to even search for exact problems like this. I have been trying to find an efficient algorithm for a while and intuitively it feels very NP-complete to me, but I haven't been able to prove it. A solution wou...
Two numbers $x,y$ are 'connected' if $gcd(x,y)>g$. Here $gcd$ is the greatest common divisor. A path exists between two numbers $x,y$ if given $g$ and $n$ there is a sequence of numbers that connect $x$ to $y$ such that all numbers along the path are less than or equal to $n$. How do you find if there exists a path bet...
Parser-generators like nearleyjs can return a parse forest instead of a parse tree. Since not all input may result in a parse forest (eg, the input may exercise only a non-ambiguous subset of the grammar), how do you programmatically choose the 'correct' parse tree from the forest? One option is to always choose the fi...
So I'm trying to figure out why the worst case of Quicksort is $O(n^2)$. I know this a very well known problem, but the funny thing is where ever I look (even Wikipedia) gives the following explanation: "The worst case is the most unbalanced case where the problem splits to a problem of size $n-1$ and a problem of size...
I would appreciate some advise/mentoring on self-study of algorithms. Based on my several years of work as a software developer (non CS background), I have some good grip on standard data structures (linked lists, stacks etc.) and basic sorting and searching algorithm characteristics (time/space complexity). My goal of...
Suppose n students have preferences over n different notebooks. Their preferences can be represented with a square matrix of size n where each column is a different permutation of the vector [1:n], where the first entry in the column represents the most desirable notebook for student 1, and so on. We are interested in ...
I have this recursive formula $$T\left(n\right)=T\left(\frac{n}{2}\right)+O\left(n\right)+O\left(n\right)+2O\left(1\right) \ \ \ ➜ \ \ \ T\left(n\right)=T\left(\frac{n}{2}\right)+O\left(n\right)$$ $$T\left(n\right) =T\left(1\right)\ +\ c_{2}n\cdot\sum_{k=1}^{⌊\log n⌋}\frac{1}{2^{k}}=T\left(1\right)+c_{2}(n-1)$$ I've be...
I have a rather foolish question on an example explaining the idea behind Referential transparency Here is given an example i not understand: Consider a function that returns the input from some source. In pseudocode, a call to this function might be GetInput(Source) where Source might identify a particular disk file,...
I'm looking to model data inputs for an artificially intelligent system, which is affected by its internal parts and has feedback loops. I'd like to model it mathematically, using category theory or homotopy type theory. Is Agda or Idris the best choice for such modelling?
In Motwani and Raghavan's textbook, p38-39, they states: A sequence $C_1, C_2, C_3, \dots$ of circuits is a circuit family for function $f_n\colon {0,1}^n \rightarrow \{0,1\}$ if $C_n$ has $n$ inputs and computes $f_n(x_1, x_2, \dots, x_n)$ at its output for all n-bit inputs $(x_1, x_2, \dots, x_n)$. The family $C$ is...
Learning a policy from sparse reward information (a reward function where a positive reward is only generated at the goal state) is challenging due to the resulting sparse feedback. One solution is to shape the reward to enrich feedback during learning. Unfortunately, shaping the reward is challenging and often leads t...
The 0-1-INT-PROG problem is given an integer $m \times n$ matrix $A$ and an integer $m$-vector $b$, is there an integer $n$-vector $x$ with $A \cdot x \leq b$. I am trying to prove that 0-1-INT-PROG is NP-Hard by reducing SUBSET-SUM to it. My attempt: Given an instance of SUBSET-SUM $<\{a_1, a_2, \cdots, a_n\}, k>$ we ...
Consider a program P that enumerates possible proofs in some proof system and halts only if it finds a valid proof that P does not halt. Clearly no such proof exists, or the program would eventually find it, causing a contradiction. But that argument itself appears to constitute exactly such a proof. It seems like that...
For an array, I'm using a left pointer (pointing to 0) and a right pointer (pointing to end). For every iteration, if my search element is not found, I increment left and decrement right. This iteration continues until left <= right. Find the code snippet below left = 0 right = length - 1 while left <= right: // s...
Is a hash table a good data structure for storing data in an application that support partial search such as "select * from MyTable where name like 'John%'. If not, what is? I would have thought that hash table isnt ideal because there no way to make faster than O(n). Maybe a some kind of balanced binary tree best. Ho...
I've been working on an asymptotic proof and I want to start with saying that since $\log z=O(z)$ then $\log z\le\frac1 9z$ for $z\ge z_0$. In this example I'm picking $c=\frac1 9$ and hoping $z_0$ exists, but is $z_0$ guaranteed to exist if I pick $c$?
Consider a graph graph G with |V| vertices and more than |V|-1 edges, is it possible for an edge to be the 'heaviest' and also be unique, but still be part of the graph's MST? If so, in which cases is it applicable? From what I've been thinking so far, if the maximum edge is the only part that connects some vertex wit...
I am wondering if $\omega$-automata with the following acceptance condition are valid. An input string is accepted iff one of the final states occurs at least once. This differs from Buchi automata in that the final state only has to occur once, not infinitely often. Does this kind of automata have a name? Is it intere...
Consider the following problem: Given a weighted directed graph $G$, determine if $G$ has a cycle whose total weight is $k$. All edge weights are integer but might be negative. $k$ is not an inputted value. It's fixed and known beforehand to everyone. So $k$ is NOT an input to this algorithm. I want to show the problem...
I learned that Bottom up parsers use only synthesized attributes to evaluate semantics. Which makes sense considering that it would be very hard to evaluate an inherited attribute in bottom up parsing. So, can bottom up parser evaluate pretty much anything top down parsers do without using inherited attributes? Is tha...
The equation below is intuitively correct, but how do you show that this is actually the case? What is the working out needed? $$\sum_{i=1}^{n-1}O(\lg n)=O(n\lg n)$$
Consider an MDP where the transition model and the reward function are unknown. Consider an optimal policy $\pi^*$ generated from this MDP (say by some oracle who does know the transition model and reward function). How can one infer the reward function and transition model from an optimal policy? For such a question, ...
Let's say that we have computed a suffix tree in O(n) time, and wish to use this to create a suffix array. According to wikipedia: A suffix tree can be built in $O(n)$ and can be converted into a suffix array by traversing the tree depth-first also in $O(n)$, so there exist algorithms that can build a suffix array in ...
I am writing a hashing algorithm to be used in the key-value data store. That is for each key the location of the data is determined. The structure of the data store is given a key, a value needs to be retrieved OR given a key and value we determine a location to store the value. We want the keys to be designed/modifie...
Consider a variant of STCON, called 2STCON, which is defined like this: $$2STCON = \{\langle G,u,v \rangle \} \mid \text{$G$ is a graph with } \mathit{two} \text{ paths from $u$ to $v$} \} $$ This means the only difference to the "normal" STCON is that there are two paths instead of just one between $u$ and $v$. I need...
The k-disjoint triangles problem is as follows: Input: A graph $G=(V,E)$ and an integer $k\in \mathbb{N}$ Output: Are there $k$ vertex-disjoint triangles in $G$? An FPT algorithm is presented here (starting from slide 60). The algorithm uses color-coding and relies on dynamic programming to determine if a solution is...
I have an array of n elements. Smallest element that exists in the array is x and the largest element is x+n. None of the numbers between x to x + n is missing from the array. i need an algorithm to get the sum of all numbers in the array provided that x is already known. The time complexity of this algorithm should be...
I was wondering besides the typical matching of all bits in the presented address to the resulting page, is there another way of doing so? what are the benefits/ cons and how would one go about doing so?
While doing image filter, I was perplexed on a particular topic regarding it. I was wondering how to take the weighted average of the immediate neighboring elements of a 2D array. I am doing this by taking two matrices and multiplying the immediate neighbors of a first matrix with the elements of the second matrix, My ...
Stephen Cook presented his seminal paper "The complexity of theorem-proving procedures" at the 1971 STOC (Symposium on Theory of Computing) conference which was held May 3-5, 1971 at Case Western. How rapidly was this recognized as being revolutionary? The book "Computers and Intractability: A Guide to the Theory of NP...
I'm looking into computing the prime implicants of a Boolean function. I have found many different algorithms in the literature, many of them relying on SAT solvers. However, I have not been able to find a SAT solver that already provides this feature. Are there any? Similarly, are there any SAT solvers/SMT solvers/rel...
I am studying computational complexity using Papadimitrious's book: "Computational Complexity". I am trying to solve the final statement of Problem 8.4.9, but I am stuck and would like some hint on how to proceed. Problem 8.4.9: "Let $f(n)$ be a function from integers to integers. An $f(n)$-prover is an algorithm whic...
Does there exist a CFL L such that the language defined as $L' = \sqrt{L} = \{w | ww \in L\}$ is not CFL? I feel that there is no such $L$ but obviously, I am unable to prove it. I am sorry but I have not made any mentionable progress with my attempts on this problem. I would appreciate any hint to the proof or a langu...
As input, given two finite sets of integers $X = \{x_1,...,x_m\}$, $Y = \{y_1,...,y_n\} \subseteq Z$, and a non-negative integer $v ≥ 0$. The goal is to decide if there are non-empty subsets $S ⊆ [m]$ and $T ⊆ [n]$ such that $$ \left|\sum_{i\in S}x_i-\sum_{j\in T} y_j\right| \leq v$$ How to show this problem is NP-hard...
Alongside the OBJ files for each figurine, Nintendo has released the following information about each figurine f: • the filament cost (amount of filament necessary) to print f, denoted fc, in grams, as an integer • the amount that Nintendo will pay for each printed copy of f, denoted fp Find P(N), the maximum profit wh...
I'm having trouble understanding the logic behind Hoare Triples. The question asks for the missing value of the precondition {X} {X} if (b mod 2 <> 0) t = 1 else t = 0 {t = b – 2*(b div 2)} Any help would be amazing!
I am missing something obvious here. Does ACC0 reach a ceiling AC0[m] with m being constant? By another description, ACC0 can use any m, which can trivially test modulus gates from [n/2,n] over all inputs. Any modulus active in that range indicates MAJ returns true, implementable as an OR over the current range of gate...
I'm referring to questions like this one: Mapping reduction to show NeverHalt is undecidable I understand with Turing reductions, you have to use oracle calls of the unknown language you're trying to prove is undecidable to solve a known undecidable language. However, with mapping reductions, am I right in assuming the...
Let $0 \le \alpha \le 1$. The complexity classs $\mathsf{RP}_\alpha$ consists of all languages $L$ for which we can find a probabilistic polynomial time Turing machine which satisfies the following conditions: $w \in L \Rightarrow \Pr[\text{accept}] \geq \alpha$. $w \notin L \Rightarrow \Pr[\text{accept}] = 0$. We de...
I am confused about the purpose/statement of the Acceptance problem: $A_{TM} =\{\langle M\rangle\,s |$ Turing machine $M$ accepts $s\}$ It can be shown that $A_{TM}$ is uncomputable, so we know that, in general, one cannot compute whether an arbitrary Turing machine will accept some input. Common sense tells me that fo...
how to prove that the lower bound of the Huffman coding problem is $\Omega(n \log n)$? Here Huffman coding problem is Huffman encoding. For example, Input: A string with different characters, say “ACCEBFFFFAAXXBLKE” Output: Code for different characters: Data: K, Frequency: 1, Code: 0000 Data: L, Frequency: 1, Code: 00...
How does cache memory take advantage of both temporal locality and spatial locality principles?
Given $n$ elements $x_1,\dots, x_n$, and algorithm $A$ which outputs $(r_1,\dots, r_n)=A(x_1,\dots, x_n)$, we say $A$ is $\epsilon$-sorting the list if $rank(x_i) \in (r_i-n\epsilon, r_i+ n\epsilon) $ for all $i$, where $rank(x_i)$ is the exact rank of $x_i$: $rank(x_i):=\#\{j:x_j\le x_i\}$. Suppose we have a noisy com...
In Scala we can print list val nums = (1 to 10).toList with both nums.filter(_ < 4).foreach(println) and for {n <- nums if n< 4} println(n) Are there any advantages of first syntax except ability to omit variable name in foreach(println)? Can we express evrything with second syntax or there are some things expressin...
The way I think of reducing problem $A$ to problem $B$ in polynomial time, i.e. $A \leqslant_P B$, is that you assume an efficient solution to $B$ which is enough to solve $A$. Now, this is suspiciously similar to $A \in \mathsf{P}^B$. I'm confident that $A \leqslant_P B \implies A \in \mathsf{P}^B$ but is the reverse...
I recently started self-learning about GNNs, and I have trouble understanding the difference between the GNN models. As I understand it, all GNN models apply an aggregation step on each node, and the different models differ in the aggregation function. Is the aggregation for a single node done by aggregating the entir...
I am considering the asymptotic analysis required to convert a polynomial of the shape $$P(x) = \prod_{i = 1}^{n}(1 + x^{s_i})$$ to its "full" representation, for example $$P(x) = 1+x^3+x^5+x^8+x^9+x^{12}+x^{14}+x^{17}.$$ Now, it would appear to me that we perform $n$ repetitions of performing $2^i$ multiplications, as...
Halting problem is not decidable in general, but are there interesting/useful subsets where it IS decidable? Bonus points if that subset is actually helpful. Example: If we know BB(x), then the halting problem for TMs with x states is decidable. The problem is BB(x) is not a computable function, as it basically require...
In his networking textbook, the world-renowned computer science expert Tanenbaum says that e-mail communication is inherently peer-to-peer. Here is the paragraph from the book: Peer-to-peer communication is often used to share music and videos. It really hit the big time around 2000 with a music sharing service called...
The regular languages are known to be closed under the operation "left half": $$ \operatorname{left}(L) = \{ x \in \Sigma^* : xy \in L \text{ for some } y \in \Sigma^* \text{ s.t. } |x|=|y| \} $$ What about the context-free languages?
I have a partially ordered set of numbers, represented as a vector<set<int>> (e.g. if $2 \preceq 4$ in this order, then poset[2] contains 4). Given 2 elements $x$ and $y$, what is an efficient way to find all their minimal upper bounds (that is, those which aren't greater than any other upper bound, but there may be ot...
Book: Parameterized Algorithms by Marek Cygan (free to download legally) Chapter about Multivariate polynomials on Page 353 (In the book not the pdf) Question 10.19: Describe a Monte Carlo $2^{3k}n^{O(1)}$ - time polynomial-space algorithm for the Triangle Packing problem: given a graph $ G $ and a number $ k \in N $,...
I am trying to prove the following statement (from book, page 317): Let $G(A,B,E)$ be a bipartite graph, where $A$ and $B$ are the two disjoint sets of vertices s.t. $|A|=|B|=n$. Let the number of matchings of size $k\le n$, be $m_k$. If $|E|>k$ then there exists an edge $e$, such that $\frac{m_{ne}}{m_k} \ge \frac{1}...
Considering the following recursive algorithm: $ T(n)= T(\frac{n}{2})+c_1(\frac {n}{2})^2+c_2n$. I was able to prove that this algorithm is $O(n^2 logn)$ I was trying to understand whether it is a tight bound or not, yet I was unable to prove that $ T(n)\in \Omega(n^2logn)$ Is it possible or maybe the algorithm's lower...
I need help writing the regular expression over the alphabet (0,1) represent the even numbers in base ten. So basically the regular expression would show represent an even number in binary. (also if you know what the FSA would look for that it would help as well)
I know that filling partial latin square and solving sudoku are NP-hard. But what are the counting versions of these two problems?
All-SAT is the problem of enumerating all satisfying assignments of a boolean formula. All-SAT is different from #SAT, where it suffices to find the number of satisfying assignments without enumerating them. Is the computational complexity of All-SAT known, or is this an open problem? In this CS Theory question, some s...
I am trying to show that $\forall \beta \gt0, \log(n^\alpha) = O(n^\beta)$, however I cannot use the limit definition, as demonstrated in similar questions on the forum. First I show that $\log(n^\alpha) = O(n)$, using the following method: $\log(n^\alpha) = \alpha \cdot \log(n) \leq \alpha \cdot n$ Thus for $c=\alpha^...
I wonder why two phase locking is designed in a way that as long as you release a lock, you cannot acquire any lock anymore, even for a lock on a different database object. Can't the scheme be relaxed to as long as you release the lock for an object, you cannot acquire the same lock again? So you release the lock on an...
I have been trying to understand the solution to the following problem: "Show that if $L_2$ and $L_3$ are Turing recognisable, then so is $L_2L_3 = \{w_1w_2 : w_1 \in L_2,w_2\in L_3\}$: which essentially says to use non-determinism to guess a partition $w$ (say $w=xy$) and run the Turing machines $L_1$ and $L_2$ on $x$...
Is it possible to use regular expression identities to prove or disprove that the RE1=0*(0+1)*0* and RE2=(0+1)* represent the same language?
If a dual core processor have 4 threads, then what will happen if i run an application which uses more than 4 threads? And just to make sure i'm understanding what are threads in a cpu, when an application uses more than one "task" on its main process a single core will switch back and forth between the threads to give...
I want to extend $\alpha$-equivalence to cover substitution. That is, I will implement runSubst_Term : Subst -> Tm -> Tm and prove: Theorem runSubst_Term_main_property (sub : Subst) (tm : Tm) : AlphaSubst sub tm (runSubst_Term sub tm). where the definitions of Subst, Tm, AlphaSubst are below. But I don't sure that A...
I have a time-serie and I fit different HMMs on it, each with a different number of hidden states. Now after sampling from the models , I'd like to compare the results with the ground truth data and find the model that gets closer to the real world data in the original time-serie. For now I simply compared visually the...
I'm currently going through past paper questions and was wondering if I could get some help answering this one? 'Consider a classification model which is applied to a set of records, of which 100 records belong to class A (the positive class) and 900 records to class B. The model correctly predicts the class of 20 reco...
I'm reading proof on Wikipedia that the existence of pseudorandom generators implies the existence of one-way functions. My understanding is that pseudorandom generators are defined as A function $G_l:\{0,1\}^l\to\{0,1\}^m$ is a pseudorandom generator if all of the following hold: a. $l<m$ b. $G_l\in\mathbf P$ c. For ...
I have seen this similar question but I can't seem to apply the same technique for the equation $7j = 5i + 6k$
When we have a universal family of hash functions, it gives us a few useful mathematical guarantees. But, if we pick a specific function from the family and use it all the time it's effectively like the family doesn't exists and we only have this one function. Therefore, the only logical thing seems to be switching a h...
Please, how can I prove that x . y' . z' simplifies to y' . z'? I have tried without success. Below is the context of my question; I am taking a course on Coursera
Suppose a Turing Machine (TM_G) that generates natural numbers following < or, equivalently, it generates words in lexicographical order. Then, that language/set is decidable. Because it is trivial to devise a (halting) TM_R, using TM_G, that recognize/accepts the words/numbers of that language/set. It is also clear (r...
From what I understand, stack and heap grow in opposite directions: However, why is it then the case that the stack is sometimes statically allocated, and generally smaller than the heap? We hear about stack overflows a lot more than heap overflows. For instance, the Linux kernel stack is limited in size, and recommen...
The A* algorithm terminates when the f (distance + heuristic) is less than the f values for all of the nodes that haven't been visited. Dijkstra's algorithm produces the shortest path to every node from a starting point (not just the end node - the goal). Is it possible to modify Dijkstra's algorithm so that when the d...
Consider the graph $G$, which is comprised of 2 vertex disjoint odd cycles ($C_1$, $C_2$) where $|C_1|$ and $|C_2| \geq 5$. $G$ is sub-cubic and connected, with edges in between the cycles. Because $G$ is sub-cubic, each node's degree $\leq 3$ but $\geq 2$. I am interested to know whether the minimum vertex cover of $G...
This is just something I've been wondering just out of curiosity. I apologize if this doesn't fall under the category of this forum, and if so feel free to divert me :) Whenever a computer does anything, it always handles a sequence of bits. My question is: how does it actually measure what bit goes in what place? I'm ...
Consider the following algorithm sketch: Given an edge-weighted directed acyclic graph $G = (V, E, w : E \to \mathbb{N})$, adjoin a temporary source $s$ and sink $t$ to get $G' = (V', E', w')$. $G'$ should have edges pointing from $s$ to all nodes in $G$ that have an empty set of in-neighbors, and edges pointing from a...
Problem Definition: Given a universe set $U = \{1, 2, \dots, n\}$ and a collection of $m$ subsets $S_1, S_2, \dots S_m \subseteq U$, find the minimum collection of subsets that cover $U$. I am specifically trying to find a $k$ polynomial time approximation algorithm for set cover where $k$ is the largest size of the su...
If I have a Lower triangular matrix of order n and I want to store non-null elements of this matrix in 1D array from first row to last row and within a row from left to right. What could be the mapping function to map the index of Lower triangular matrix Aij in 1D.