instruction stringlengths 0 29.8k ⌀ |
|---|
This was one of my exam questions and the answer is apparently no.
Can someone explain why because I don't understand. |
If $L_1 \cup L_2 \in RE$ does it implicate that at least one of them is also in RE? |
|regular-languages|automata| |
I have a number of agents and tasks. In my case, the agents and the tasks have time constraints: so agent1 loves doing task1, but task1 must be done at 10am or 11am, and agent1 is only available after 1130am.
Is there a way to introduce duplicate rows/cols or some such to account for this while still applying a nai... |
Assignment problem with time constraints on both axes |
|algorithms| |
I have a number of agents and tasks. In my case, the agents and the tasks have time constraints: so agent1 loves doing task1, but task1 must be done at 10am or 11am, and agent1 is only available after 1130am, also, task1 and task2 can happen at the same time, but the cost increases if so.
Is there a way to introduc... |
I want to compare two trees:
I will consider the trees equal if they are:<br/>
Isomeric-i.e have the same structure. <br/>
Nodes in both trees have the same values but the order of the children nodes are not necessarily the same.<br/>
A picture is worth a thousand words:
eg:
```
A) B) ... |
Comparing two rooted n-ary trees irrespective of the order of children nodes? |
|trees| |
It's much simpler than isomorphism.
For each vertex, check that the parent is the same in both trees. |
null |
I am reading Michael Sipser's "Theory of Computation" 2nd edition, chapter 1 , Topic "Non determinism" ( Section 1.2 )
Let's use this E-NFA as an example
[![enter image description here][1]][1]
My question is, do we transition along "epsilon transition" before reading any input or after reading any input?
a... |
If all tasks take one hour and are required to start "on the hour", then you can make a bunch of copies of each agent and each task, one per hour of the day.
For more complicated situations, I don't know of any way to represent this as an assignment problem. You might do better to solve it using integer linear prog... |
I have a waypoint graph and a function that finds all polygons in this waypoint graph by finding closed loops.
Currently if i add / remove a new vertex or edge i basically clear all the polygons i found and search the entire graph to find all the polygons again.
I was wondering what is a way to optimise this so I... |
Optimising updates to a way point graph |
|algorithms|graphs|graph-traversal| |
There exist languages which are **Non-RE** and their complement is also **Non-RE**, let $L$ be such a language we can say that
$L \cup L^{c} = \Sigma^{*}$
Here both languages are **Non-RE** but their union is $\Sigma^{*}$ which is regular as well as **RE** also. |
I am trying to learn about approximation algorithms. In some research papers, it is mentioned about the absolute approximation ratio. what does the absolute approximation ratio mean? is it different from the asymptotic approximation ratio?
if there is any resource that might help to understand more about this, pleas... |
asymptotic approximation ratio vs absolute approximation ratio? |
|asymptotics|approximation| |
null |
null |
[This](https://cs.stackexchange.com/questions/86813) question deals with how to find the maximum matching in a tree. I understood the answers, but for one part.
>Choose a root arbitrarily. For each subtree, calculate the maximum matching within the subtree, as well the maximum matching within the subtree that doesn't ... |
You can prove this by a case analysis. Consider any optimal solution. Either the root is matched to another vertex, or it is unmatched. If it is matched to some other vertex, consider all possible cases for what the root might be matched to. Make sure that your dynamic programming algorithm handles all of those cas... |
*Given $m$ sorted arrays $A_1,A_2,\dots,A_m$, also $\mid A_i\mid=n$ for each $i=1,2,\dots,m$. How we can compute $k^{th}$ smallest number in union of $A_i$s (i.e. $\cup_{i=1}^nA_i$) in at most $O(m\log mn)$?*
$I.$ If I use Minheap to find $k^{th}$ element, th running time will be $O(m+k\log mn)$, so that $k$ can be ... |
null |
I am trying to understand the difference b/w functional and decisional problems. The core as I understand is this:
**Functional Problems:** Given an input $x$ we calculate some function $f(x)=y$ over it.
**Decisional Problems:** Given inputs we output *YES* or *NO* depending on some logic or algorithm.
As far ... |
Difference b/w Functional and Decisional Problem's computational complexity |
|complexity-theory|time-complexity| |
I am trying to understand the difference b/w functional and decisional problems. The core as I understand is this:
**Functional Problems:** Given an input $x$ we calculate some function $f(x)=y$ over it.
**Decisional Problems:** Given inputs we output *YES* or *NO* depending on some logic or algorithm.
As far ... |
What you're missing:
First, given $x,y$, there might be an easier way to test whether $f(x)=y$, without having to compute $f$ on input $x$. For instance, when $x$ is an integer, suppose that $f(x)$ outputs the factorization of $x$. This is believed to be hard to compute (there is no known polynomial-time algorithm... |
I have an algorithm that recursively connects together pairs of nodes into new nodes. It looks like the Huffman code algorithm, except that a node can be re-used after it has been part of a merge. The result is a graph where each node has two parents, but can have any amount of children.
Is there a term for such a g... |
Visualising pseudo-tree with two parents per node |
|graphs|trees|graph-drawing| |
This is a paragraph from the book *CLRS*:
> What we need is known as an optimal binary search tree. Formally, we are
given a sequence $K = (k_1, k_2, ..., k_n)$ of $n$ distinct keys in sorted order (so that
$k_1 < k_2 < ... < k_n$), and we wish to build a binary search tree from these keys.
For each key $k_i$, we... |
Two statements about optimal binary search trees |
|binary-search-trees| |
As a side-project, I had the idea to write some kind of an algorithm that would evaluate all participations in our weekly Pub quiz, to then calculate the average strength of the participants.
### This is the information that I have available:
- The final score of the group
- All members of the group for a part... |
An algorithm to evaluate the strength of Quiz Participants |
|linear-programming|algorithm-design| |
In a directed graph $G=(V,E)$ we denote a vertex $s\in V$ to be a 'source' if there exists in $G$ a path from $s$ to all other vertices $u \in V$.
The problem asks for an efficient algorithm to return the 'source', in case there isnt any, return false.
I've been able to come up with a naive approach to his proble... |
Lets take an example of the range of N=32 bits
2^32 = 4294967296
00000000000000000000000000000000
00000000000000000000000000000001
00000000000000000000000000000010
00000000000000000000000000000011
...
11111111111111111111111111111100
11111111111111111111111111111101
1111... |
Binary subsets for a given set |
|sets|binary|computer-algebra| |
How can I update values in Binary Search Tree without affecting its properties (all the nodes in the left subtree have values that are less than the value of the root node and all the nodes of the right subtree have values that are greater than the value of the root node).
I tried deleting and inserting the new Valu... |
Binary Search Tree Updating |
|binary-search-trees| |
|optimization|binary-search-trees| |
This is a paragraph from the book *CLRS*:
> What we need is known as an optimal binary search tree. Formally, we are
given a sequence $K = (k_1, k_2, ..., k_n)$ of $n$ distinct keys in sorted order (so that
$k_1 < k_2 < ... < k_n$), and we wish to build a binary search tree from these keys.
For each key $k_i$, we... |
I want to compare two trees:
I will consider the trees equal if they are:<br/>
Isomeric-i.e have the same structure. <br/>
Nodes in both trees have the same values but the order of the children nodes are not necessarily the same.<br/>
A picture is worth a thousand words:
eg:
```
A) B) ... |
I want to prove this language $a^nb^{n^2+n}$ to be not regular by the pumping lemma. This is my attempt, is this a correct way of doing it?
Let's suppose $L$ is regular. Let $s = a^kb^{k^2+k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$.
Then, by the pumping lemma, $\exists s... |
prove $a^nb^{n^2+n}; n \geq 0$ is regular or not regular |
|regular-languages|automata| |
Your proof is not correct when you "let $k=1$". You cannot choose the pumping length $k$ when you are using the pumping lemma to prove a language is not regular. For example, your proof does not exclude the possibility that $L$ could be regular with pumping length $2$.
Using the pumping lemma method to prove a langu... |
I want to prove this language $a^nb^{n^2+n}$ to be not regular by the pumping lemma. This is my attempt, is this a correct way of doing it?
Let's suppose $L$ is regular. Let $s = a^kb^{k^2+k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$.
Then, by the pumping lemma, $\exists s... |
Prove $a^nb^{n^2+n}; n \geq 0$ is regular by the pumping lemma |
|regular-languages|pumping-lemma| |
null |
*Given $m$ sorted arrays $A_1,A_2,\dots,A_m$, also $\mid A_i\mid=n$ for each $i=1,2,\dots,m$. How we can compute $k^{th}$ smallest number in union of $A_i$s (i.e. $\cup_{i=1}^nA_i$) in at most $O(m\log mn)$?*
$I.$ If I use Minheap to find $k^t{th}$ element, th running time will be $O(m+k\log mn)$, so that $k$ can be... |
*Given $m$ sorted arrays $A_1,A_2,\dots,A_m$, also $\mid A_i\mid=n$ for each $i=1,2,\dots,m$. How we can compute $k^{th}$ smallest number in union of $A_i$s (i.e. $\cup_{i=1}^nA_i$) in at most $O(m\log mn)$?*
$I.$ If I use Minheap to find $k^{th}$ element, th running time will be $O(m+k\log mn)$, so that $k$ can be ... |
Your proof is not correct when you "let $k=1$". You cannot choose the pumping length $k$ when you are using the pumping lemma to prove a language is not regular. For example, your proof does not exclude the possibility that $L$ could be regular with pumping length $2$.
Using the pumping lemma method to prove a langu... |
I want to prove this language $L=\{a^nb^{n^2+n}:n\in\Bbb N\}$ to be nonregular by the pumping lemma. This is my attempt, is this a correct way of doing it?
Let's suppose $L$ is regular. Let $s = a^kb^{k^2+k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$.
Then, by the pumping le... |
Prove $a^nb^{n^2+n}$ is not regular by the pumping lemma |
Deleting the value and inserting a new one is a valid way to update a value in a binary search tree. Its asymptotic running time is as good as any other solution. |
I have an optimization problem and I am wondering if there is a better way to solve it than using a naïve brute force method. I have a number of tasks T that must be completed, and a number of agents A to do work in parallel to one another. For this, T > A.
What I would like to do is write a program to figure out th... |
Optimize Multiple Agents Completing Multiple Tasks in Parallel |
|optimization|assignment-problem| |
How can I update values in Binary Search Tree without affecting its properties (all the nodes in the left subtree have values that are less than the value of the root node and all the nodes of the right subtree have values that are greater than the value of the root node).
I tried deleting and inserting the new Valu... |
How can I update values in Binary Search Tree without affecting its properties (all the nodes in the left subtree have values that are less than the value of the root node and all the nodes of the right subtree have values that are greater than the value of the root node).
I tried deleting and inserting the new Valu... |
I believe your problem is equivalent to a [bin packing problem](https://en.wikipedia.org/wiki/Bin_packing_problem). To determine whether there exists a schedule that finishes in M minutes, set the bin capacity to M. Each task is a item, whose size is equal to the time it takes to complete that that task, so we have T... |
Let $A(n,k)$ denote the number of valid strings of length $n$ ending with a string of $k$ zeroes. Then:
- $A(0,0) = 1$
- $A(0,1) = A(0,2) = A(0,3) = 0$
- $A(n+1,0) = A(n,0) + A(n,1) + A(n,2) + A(n,3)$
- $A(n+1,k+1) = A(n,k)$
You are interested in $A(n,0) + A(n,1) + A(n,2) + A(n,3)$ for various values of $n$.
... |
This problem is known as Makespan Scheduling and is $\mathsf{NP}$-complete. Hence, computing an optimal assignment cannot be done in polynomial time unless $\mathsf{P} = \mathsf{NP}$; i.e., under common complexity-theoretic assumptions, there is no algorithm which is guaranteed to find optimal assignments quickly.
... |
I suspect this is primarily a statistics and data modelling question, rather than a question about computer science.
If you have a model $f$ for predicting the score of a team from the strengths of the participants (i.e., the predicted score is $f(x_1,\dots,x_k)$, where $x_1,\dots,x_k$ represent the strengths of eac... |
Let $A(n,k)$ denote the number of valid strings of length $n$ ending with a string of $k$ zeroes. Then:
- $A(0,0) = 1$
- $A(0,1) = A(0,2) = A(0,3) = 0$
- $A(n+1,0) = A(n,0) + A(n,1) + A(n,2) + A(n,3)$
- $A(n+1,k+1) = A(n,k)$
You are interested in $A(n,0) + A(n,1) + A(n,2) + A(n,3)$ for various values of $n$.
... |
|optimization|scheduling| |
Your proof is not correct when you "let $k=1$". You cannot choose the pumping length $k$ when you are using the pumping lemma to prove a language is not regular. For example, your proof does not exclude the possibility that $L$ could be regular with pumping length $2$.
Using the pumping lemma method to prove a langu... |
I want to prove (or disprove) that for any finite alphabet $\Sigma$ and string set $L \in \Sigma^*$, then $L$ is finite if:
- Every word in $L$ is finite; and
- There are no $v, w \in L$ such that $v$ is a substring of $w$.
I have the intuition that this is true, haven't been able to find a counter example, but am... |
Can we prove that any set of finite strings without substrings if finite? |
|formal-languages|strings|finite-sets| |
Assuming that by *substring* you mean *consecutive substring*, take
$$ L= \{10^n1 : n \ge 0\}. $$ |
I need a data structure/algorithm to efficiently retrieve borders and update changes.
There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time.
In this case, a pixel borders another if it is directly above, below, or to the left or right of it ([Von Neumann neig... |
Determining all pixels of a specific color directly bordering on another color |
|algorithms|graph-traversal|image-processing| |
null |
I need a data structure/algorithm to efficiently retrieve borders and update changes.
There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time and pixels may be randomly inserted - although most changes happen along the borders.
In this case, a pixel borders ano... |
I need a data structure/algorithm to efficiently retrieve borders and update changes.
There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time and pixels may be randomly inserted - although most changes happen along the borders.
In this case, a pixel borders ano... |
I need a data structure/algorithm to efficiently retrieve borders and update changes.
There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time and pixels may be randomly inserted - although most changes happen along the borders.
In this case, a pixel borders ano... |
I need a data structure/algorithm to efficiently retrieve borders and update changes.
There may be many (unconnected) regions of the same color. The shape of regions changes frequently over time and pixels may be randomly inserted - although most changes happen along the borders.
In this case, a pixel borders ano... |
|algorithms|euclidean-distance| |
|optimization|computer-vision| |
|optimization|permutations| |
|algorithms|data-structures|adjacency-matrix| |
I don't think that rotation and swapping of node value can fix the problem caused by an update. Consider the situation where the value of node $x$ decreases to $x'$. Let $y$ be the ancestor of $x$ closest to the root such that $y < x$. Assume that $x' < y < x$. Then before update, $x$ is in the *right subtree* of $y$ a... |
I don't think that rotation and swapping of node value can fix the problem caused by an update. Consider the situation where the value of node $x$ decreases to $x'$. Let $y$ be the ancestor of $x$ closest to the root such that $y < x$. Assume that $x' < y < x$. Then before update, $x$ is in the *right subtree* of $y$ a... |
I don't think that rotation and swapping of node value can fix the problem caused by an update. Consider the situation where the value of node $x$ decreases to $x'$. Let $y$ be the ancestor of $x$ closest to the root such that $y < x$. Assume that $x' < y < x$. Then before update, $x$ is in the *right subtree* of $y$ a... |
Assuming that by *substring* you mean *consecutive substring*, take
$$ L= \{10^n1 : n \ge 0\}. $$
On the other hand, if you refer to nonconsecutive substrings, or *subsequence* ordering, then [Higman's Lemma][1] states that any set of incomparable strings is indeed finite.
[1]: https://en.wikipedia.org/wiki/... |
null |
### The ideas
For simplicity, I will be ignoring off-by-one errors and treating some fractions as if they were integers from time to time. A rigorous and working implementation will be provided later.
Imagine the algorithm will run some logic repeatedly, removing elements that are not possible to be the $k$-th sm... |
I want to prove this language $a^nb^m; n>m \geq 0$ to be not regular by the pumping lemma. This is my attempt, is this a correct way of doing it?
Let's suppose $L$ is regular. Let $s = a^{k+1}b^{k}$ such that $k \geq 0$ as a pumping length. So we have $s \in L$ and $|s| \geq k$.
Then, by the pumping lemma, $\exi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.