instruction
stringlengths
0
29.8k
⌀
Dynamic table $T$ that grows at a factor of $ T.size + \sqrt{T.size} $
|algorithms|algorithm-analysis|amortized-analysis|
null
Prove it **by induction**. It is true for trees with |V|<=3. Suppose that it is true for trees with |V|=n-1 and we want to prove it for a tree T with |V|=n. **If** there exist a leaf v which is unmatched then by removing v, we have a tree T' and a proper matching M' where L(T')=L(T)-1, U(M')=U(M)-1 and L(T')>=U(M...
null
null
**Note:** the following problem is based on the section about *dynamic table* as part of the discussion about *amortized analysis* in CLRS **Problem:** We are given a dynamic table $T$ that supports INSERT operation , implemeneted as an array and allows a constant amortized time per operation. Change the data stru...
null
***The time-complexity of dynamic-programming with memoization*** Here is the simple principle. Suppose an algorithm - applies dynamic programming to solve a problem, - with the majority of running time spent on computing $O(s)$ subproblems for some expression $s$, - where each subproblem is computed/solved only...
0 I am trying to understand the concept of synchronised DFAs. I have a question where all the states in the DFA after reading that particular word from the alphabet will reach a particular state with the alphabet (A to Z). And I should prove that a language which accepts any random number of alphabet combinations ...
Synchronised DFAs
|automata|finite-automata|
null
A synchronizing word $w$ has the property that there is a single state $q$ of the DFA, such that for every state $s$ it holds that $\delta(s,w)=q$. That is, after reading $w$ you end up in $q$, regardless of where you started. Now, suppose you read a bunch of letters. You know nothing about them. But you know that a...
<!-- Coarsely, this problem is very easy. Just before an INSERT that triggers an expansion when $T.size=n$ (which implies this INSERT is $(n{+}1)$-th operation), most of the operations have a cost of 1, so the amortized time per operation is $O(1)$. Just after that operation, the total amount of operation is about $n(...
Set theory depends on a set membership function $\epsilon$ which is a class of ordered pairs. Is it possible to construct *the ordered pair* from an undirected graph of *unordered pairs*? Alternatively, is there a way to construct a undirected graph that represents a directed graph? The graph may be traversed from...
Using an undirected graph to represent an ordered pair?
|graphs|
I am not looking for the complexity of following algorithm but rather _how to think about the problem and calculate complexity of a given solution?_ One way is to perhaps use The Master Method for recursive functions, but that hides the "how?" part. I am trying to get much better at calculating complexities of algo...
Find worst-time complexity for a problem on matching a simple regular expression?
|algorithms|dynamic-programming|regular-expressions|memoization|
|graphs|trees|graph-traversal|
The following problem is based on the section about *dynamic table* as part of the discussion about *amortized analysis* in CLRS **Problem:** We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that ...
Amortized analysis on a dynamic table that grows at a factor of $ size + \sqrt{size} $
|algorithms|algorithm-analysis|amortized-analysis|dynamic-array|
null
In class we were talking about the decidability and acceptability of languages by Turing Machines but a doubt arose in my mind, "is any language containing a finite number of strings decidable by Turing Machines?" My first answer could be no, since there are finite languages that are undecidable.
Turing Machine recognizable
|turing-machines|turing-recognizable|
{"OriginalQuestionIds":[83752],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
A finite language of chains is TM decidable?
Now, **$\color{red}{\text{Exponentiation}}$** is defined as >Exponentiation is a mathematical operation, written as $b^n$, involving two numbers, the base $b$ and the exponent or power $n$, and pronounced as "$b$ raised to the power of $n$". > $$b^n = \underbrace{b\times b\times\cdot \cdots \times b}_{n\text{ tim...
Time Complexity of Exponentiation Operation as per RAM Model of Computation
|complexity-theory|time-complexity|algorithm-analysis|runtime-analysis|computation-models|
<!-- Coarsely, this problem is very easy. Just before an INSERT that triggers an expansion when $T.size=n$ (which implies this INSERT is $(n{+}1)$-th operation), most of the operations have a cost of 1, so the amortized time per operation is $O(1)$. Just after that operation, the total amount of operation is about $n(...
i recently have been practicing constructing Turing Machines for languages. But i can't seem to figure this one out. I've seen a few videos on constructing 3 equal length strings (a^nb^nc^n) But i can't figure out this one. Can anyone help out how i can do this. Please don't give the answer outright, i want to actually...
Construction of a Turing Machine that accepts the language of (a^nb^nc^md^m for) m,n >= 1
|turing-machines|context-free|
Consider a variant of the TSP problem where the cost function $c$ is not only symmetric but also satisfies $c(u, v) ≤ 2c(u, w) + c(w, v)$ for arbitrary vertices $u, v, w ∈ V$ . Give a polynomial time algorithm that achieves a constant factor approximation ratio for this problem. I think the algorithm itself is th...
approximation ratio of TSP problem where the weights are bounded by an inequality
|approximation|traveling-salesman|
The following problem is based on the section about *dynamic table* as part of the discussion about *amortized analysis* in CLRS **Problem:** We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that ...
null
Really, you have two identical tasks concatenated. Read the $a$'s and $b$'s and see if they're in the right form. Then, more or less reset and do the same things for the $c$'s and $d$'s. BTW, Welcome to the site!
Consider the following problem: > - Input: A Turing Machine M and a DFA D. > - Question: Is $L(D) \subseteq L(M)$? Of course, this problem is not decidable. Because it is known that judging whether a word belong to a Turing Machine is not decidable. If this problem is decidable, then we can write the word as reg...
Does the following "DFA-TM-INCLUSION" problem recursive enumerable?
|turing-machines|computability|finite-automata|reductions|proof-techniques|
null
How can the result of the execution of $ \rightarrow RL$ differ from that of $\rightarrow LR$? In turing machines
Left and right derivation of Turing Machine
|turing-machines|derivation|
Are there other advantages to linked lists over arrays other than constant time removals of the first element?
Advantages of linked lists over arrays?
|linked-lists|
For one dimensional, continuous binary search most effective algorithm would remember boundaries. For example if boundaries are 0.7 and 0.9, point to check would be 0.8. And if result is 'too small', then boundaries become 0.8 and 0.9, and point to check is 0.85. This algorithm is fast and simple. But it doesnt do we...
Unusual version of a binary search algorithm
|dynamic-programming|search-algorithms|binary-search|search|
Linked lists can work well even if memory is fragmented. Array usually requires continious piece of memory. For large piece of data finding this large continious piece of memory might be hard. Most of the benefits of linked lists requires to remember more links than just the head. For example. If you are doing some se...
This isn't really about "advantages", but appropriateness. Sometimes it's more appropriate to use an array, and sometimes to use a linked list. If it helps, take a look at [this large table][1] of the complexity of various operations of a bunch of data structures from the C++ standard library so you can compare them...
I don't have an exhaustive list (pun intended), but off the top of my head: * You can also perform constant time operation at the tail (*for a circular doubly linked list*). * You can implement the [move-to-front heuristic (MTF) ](https://en.m.wikipedia.org/wiki/Self-organizing_list#Move_to_front_method_(MTF)) e...
null
Linked lists can work well even if memory is fragmented. Array usually requires continious piece of memory. For large piece of data finding this large continious piece of memory might be hard. Most of benefits of linked lists requires to remember more links than just the head. For example. If you are doing some sequen...
Linked lists can work well even if memory is fragmented. Array usually requires continious piece of memory. For large piece of data finding this large continious piece of memory might be hard. Most of benefits of linked lists requires to remember more links than just the head. For example. If you are doing some sequen...
I've implemented this data structure, or something very similar to it, various times, without using hash tables (or associative mappings) at all. As far as I know, it's a folklore algorithm, although I suppose it must exist somewhere in the literature, and hash tables weren't the first choice in languages which don't h...
I've implemented this data structure, or something very similar to it, various times, without using hash tables (or associative mappings) at all. As far as I know, it's a folklore algorithm, although I suppose it must exist somewhere in the literature, and hash tables weren't the first choice in languages which don't h...
I've implemented this data structure, or something very similar to it, various times, without using hash tables (or associative mappings) at all. As far as I know, it's a folklore algorithm, although I suppose it must exist somewhere in the literature, and hash tables weren't the first choice in languages which don't h...
I am trying to understand the concept of synchronised DFAs. I have a question where all the states in the DFA after reading that particular word from the alphabet will reach a particular state with the alphabet (A to Z). And I should prove that a language which accepts any random number of alphabet combinations followe...
A language that is either fully accepted by synchronised DFAs or not at all
Let us be given a function $f(x_1,\dots,x_{10})$ of multiple variables $x_1,\dots,x_{10}$ given that $\sum_{i=1}^{10} x_i \leq 7$. How do we solve the following problem? $$ \begin{equation} \begin{aligned} \max_{\{x_i\}, i=1,\dots,10} \quad & f(x_1,\dots,x_{10})\\ \textrm{s.t.} \quad & \sum_{i=1}^{10} x_i \leq 7...
I am not looking for the complexity of following algorithm but rather _how to think about the problem and calculate complexity of a given solution?_ One way is to perhaps use The Master Method for recursive functions, but that hides the "how?" part. I am trying to get much better at calculating complexities of algo...
null
null
Assume $n\ge2022$. Consider a sequence of $n$ INSERTs. ***Lower bound of time for $n$ INSERTs*** Each expansion that has been done expands the capacity by no more than $\sqrt n$. So at least $n/\sqrt n=\sqrt n$ expansions has happened. Consider the last $\frac{\sqrt n}2$ expansions. The earliest one of them ha...
Optimizing an arbitrary function of 10 variables
There are only 19448 combinations of $x$'s that meet the constraints. If $f$ is arbitrary, the best you can do is enumerate all 19448 combinations and see which leads to the largest value of $f$. There is no faster algorithm. Dynamic programming does not seem relevant. If you know something about the structure of...
> Suppose that we're given a **connected**, **undirected** graph $G = (V, E)$ with > edge weights $w_e$ and a subset of vertices $U \subset V$. We want to find > the lightest spanning tree in which the nodes of $U$ are leaves (they > may be other leaves as well). We want to do so in $O(|E|\log(|V|))$ time. I was ...
Wrong Solution for `Spanning tree with chosen leaves` problem
|algorithms|graphs|minimum-spanning-tree|spanning-trees|
null
The following problem is based on the section about *dynamic table* as part of the discussion about *amortized analysis* in CLRS **Problem:** We are given a dynamic table $T$ that supports INSERT operation, implemented as an array and allows a constant amortized time per operation. Change the data structure so that ...
Amortized analysis on a dynamic table that grows its size by $\sqrt{size} $
I'm working on the following problem: > Suppose that we're given a connected, undirected graph $G = (V, E)$ with > edge weights $w_e$ and a subset of vertices $U \subset V$. We want to find > the lightest spanning tree in which the nodes of $U$ are leaves (there > may be other leaves as well). We want to do so in...
Does the following "DFA-TM-INCLUSION" problem recursively enumerable?
null
I am creating a tool for validating, parsing and interpreting flowchart diagrams on [diagrams.net][1], and it is neccessary to give users an opportunity to define a set of rules for the diagram. I was looking into applying context-free grammars for this task, but the problem is that CFGs and all the theory and tool...
Is there an alternative for the formal language theory that could be used for flowchart diagrams?
|formal-languages|context-free|formal-grammars|
null
A thread is the unit of execution of a process. The latter can have one or more threads. Each thread, shares the common process info (global variables, files, address space), but it has its own computation and therefore stores independently PC, stack pointer, IP, and other registers. All this information is stored in t...
Given an array of characters, I need to delete all the characters that got repeated 3 or more times (consecutively) and add '0' end at of the array for every deleted character, The restrictions: O(n) time O(1) memory Can't overwrite a cell in the array more than once Examples: "aacccbbddde" --> "aabbe000000" ...
Delete consecutive characters and add zeros at the end with a restriction
|algorithms|time-complexity|space-complexity|strings|
Let $G=(U, V, E)$ be a biparite graph, with $U$ and $V$ being the two sets of nodes. I am trying to find the smallest set of nodes $\hat{V} \subseteq V$ such that, for every node $u \in U$, $\hat{V}_u$ contains at least one element and is different from $\hat{V}_{u'}$, $\forall u' \neq u \in U$, where $V_u \subseteq...
Name and complexity of this problem on bipartite graphs
|graphs|np-hard|bipartite-graph|
Recently I studied a [MIT open course][1]. In [lecture2][2], it is stated that Rectangle Packing is NP-hard. I can understand this because the problem can be reduced to [3-partition problem][3] **But I don't know why it's an open problem whether if it's in NP.** In lecture2 it is stated that: > it i...
null
Recently I studied a [MIT open course][1]. In [lecture2][2], it is stated that Rectangle Packing is NP-hard. I can understand this because the problem can be reduced to [3-partition problem][3] **But I don't know why it's an open problem whether it's in NP.** In lecture2 it is stated that: > it is c...
In parameterized complexity, the class XP contains all problems that can be solved in time $O(n^k)$ where $k$ is the size of the parameter. Note that ${n \choose k} = O(n^k)$, so any algorithm that tries to find a solution of size $k$ in a set of $n$ elements have a similar running time. For example brute force algo...
null