instruction stringlengths 0 29.8k ⌀ |
|---|
|machine-learning|image-processing|research| |
I got the following question from my academic instructor and since I am new to graph algorithms I would be happy if someone could review my solution.
>Given undirected graph $G = (V,E)$, suggest an algorithm that determines whether or not it is possible to assign directions to edges in a way that the indegree of each ... |
Assigning directions to edges in an undirected graph in a way which satifies some condition |
|algorithms|graphs|depth-first-search| |
null |
There are integer tuples which index cells of a sparse multi-dimensional array (points inside n-parallelepiped), $n \le 32$.
The array itself is a BST with keys formed as $key = (...((a_0 * S_1 + a_1) * S_2 + a_3 ) * ... + a_{n-2}) * S_{n-1} + a_{n-1}$,
such keys preserve the order of tuples and can be compared ... |
Let's say we have a graph $G$ with $|V|$ nodes. We wish to select the smallest set of nodes $S$ that:
$dis(i, j) \le k, \forall i \in S, j\in V-S$,
where $k$ denotes a certain distance threshold.
Smallest means the least number of nodes. |
Selecting the smallest node set in a graph so that all nodes outside the set can connect to this set within certrain distance |
|graphs| |
Consider an ambiguous context-free grammar $G$. Define $A(G)$ the set of ambiguous words, meaning:
$$A(G) = \{u\in L(G) \mid u \text{ has at least two derivation trees for }G\}$$
Can we say something about $A(G)$ in the general case? In particular, is $A(G)$ a context-free language? |
Language of ambiguous words |
|formal-languages|context-free|ambiguity| |
As you say, you can split the points in two sets $A$ and $B$ of roughly the same size, depending on whether their $x$ coordinate smaller than or at least some threshold $x_0$. Solve the problem recursively on $A$ and $B$ and let $\delta$ be the minimum distance between any two points in the same set.
Now, instead of... |
The number of inversions in an array does not depend on any algorithm. It ranges from $0$ (sorted sequence) to $\dfrac{(n-1)n}2$ (reverse sorted sequence), so is $O(n^2)$ and but not $\Theta(n^2)$.
It turns out that bubble sort performs exactly that number of swaps.
The "blind" version that you evaluated perform... |
Reduce from dominating set, let $k=1$. |
Godd afternoon,
We have set C of k coins; For example C = (2, 3) \
We have positive integer n.
In how many ways we can represent n using those coins?
**Example:**
> If n = 12; C = (2, 3) we can represent 12 as 3+3+3+3, 3+3+2+2+2 or 2+2+2+2+2+2, so in three ways.
**Introduction:**
For any predefined... |
Number of ways to make change in o(k), where k is number of coins |
|algorithms|discrete-mathematics|generating-functions| |
null |
Could you use a different ordering, specifically [Morton Ordering (Z-order curve)][1]?
I could offer one of my own projects, the [PH-tree index][2].
It is an ordered map that uses multidimensional keys (e.g. a vector of integer).
In your case, you would use the "coordinate" of your matrix as "key".
This would sa... |
My Problem is having to work with real-time server in a DES model. I have the following situation:
I want to build a discrete event simulation model (*Using event scheduling world view*). However, this model needs to be connected to another **real-time** program.<br/><br/>
Within this model, the event routines cre... |
Could you use a different ordering, specifically [Morton Ordering (Z-order curve)][1]?
I could offer one of my own projects, the [PH-tree index][2].
It is an ordered map that uses multidimensional keys (e.g. a vector of integer).
In your case, you would use the "coordinate" of your matrix as "key".
This would sa... |
There are integer tuples which index cells of a sparse multi-dimensional array (points inside n-parallelepiped), $n \le 32$.
The array itself is a BST with keys formed as $key = (...((a_0 * S_1 + a_1) * S_2 + a_3 ) * ... + a_{n-2}) * S_{n-1} + a_{n-1}$,
such keys preserve the order of tuples and can be compared ... |
Another way to think about this, which maybe helpful is, to pick a concrete value of $\alpha$ and the size of the original array, $n$. Lets say that $\alpha = 0.2$ and $n = 100$. Then, $\alpha n = 20$. Lets also denote the size of the smaller subarray by $|S|$.
If the pivot chosen is at index $21$, then the size o... |
null |
Dynamic programming provides an $O(nv)$ solution where $n$ is the number of coins and $v$ is the target value. A slight variation to the classic coin change dynamic programming solution can be used to count number of solutions.
https://www.geeksforgeeks.org/coin-change-dp-7/amp/
|
null |
The standard example that context-free languages are not closed under intersection can also be used as a counter-example for the language of ambiguous words.
Construct unambiguous grammars for $\{ a^n b^n c^m \mid m,n\ge 1\}$ and $\{ a^m b^n c^n \mid m,n\ge 1\}$. Take the union of these grammars in the common way. ... |
null |
null |
null |
I got the following question from my academic instructor and since I am new to graph algorithms I would be happy if someone could review my solution.
>Given undirected graph $G = (V,E)$, suggest an algorithm that determines whether or not it is possible to assign directions to edges in a way that the indegree of each ... |
Count how many pairs are 1; there are 10^12.
Count the 2 <= w <= 1000000 that are exactly a 1st, 2nd, up to 19th power. Then for each n, m from 1 to 19 count how many equal pairs of nth and mth powers raised to other powers you have. For example if n = 3, m = 7, then a 3rd power raised to the power 7, 14, 21 etc ma... |
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the sequence (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$.
My idea: I tought about c... |
maximum length of the sequence (a[i],b[i]) such that if $b[i]='<'$ then $a[i+1]<a[i]$ and if $b[i]='>'$ then $a[i+1]>a[i]$ |
|algorithms|dynamic-programming|balanced-search-trees|search| |
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i... |
Count how many pairs are 1; there are 10^12.
Count the 2 <= w <= 1000000 that are exactly a 1st, 2nd, up to 19th power. Then for each n, m from 1 to 19 count how many equal pairs of nth and mth powers raised to other powers you have. For example if n = 3, m = 7, then x^3 raised to the power 7, 14, 21 etc matches x^... |
Andras is correct here. In the interest of full disclosure, I'm the original author of lambdabot and the free theorem plugin, and so I'm in a unique position to tell you exactly what's going on.
The way the plugin works is that it assumes that a type constructor with a single argument is a functor, and generates a f... |
Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 s... |
Determine whether we can pack $(r_1, \dots, r_k)$ copies of the variables $(A_1, \dots, A_k)$ into a string $s$, in time polynomial in $|s|$? |
|algorithms|graphs|time-complexity|polynomial-time|open-problem| |
Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 s... |
Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 s... |
null |
null |
null |
In the real world, different objects are concurrently doing stuff. In simulation, you just need to simulate that.
When an event happens that affects object O, your simulate should calculate what will O will do in response, and what is the next action (if any) that object O will take, and at what time O will take it... |
I found a very systemmatic approach to solve the problem but it depends on my instinct and it has no direct proof yet (or I am not sure if it is "correct"). Maybe someone else can prove/disprove my approach.
First, I will not try to put 100 ships into a square as the question asks but I will try to find the maximum ... |
For those who are struggling to understand the problem in terms of mathematical equations, here's an elaboration!
Example:
1 2 3
4 5 6
7 8 9
Indices of corresponding diagonals (if we are going from right to left):
```
[0][2]
[0][1], [1][2]
[0][0], [1][1], [2][2]
[1][0], [2][1]
[2][0]
```
... |
null |
null |
Count how many pairs have a product of 1; there are 10^12. It’s all the cases 1^x = 1^z. Then ignore w, y = 1.
Count the cases with identical left and right side w^x = w^x. There are (n-1) * n cases.
Divide the numbers from 2 to n into (here) about 999,000 non-powers, about 1000 squares, 100 cubes etc. Each numb... |
In state diagram of DFA is it mandatory to keep a final state. I mean whether DFA is possible without final state or not?!
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/fuxr3.jpg |
I am trying to solve this question and ended up with the answer O(√n.log√n). But when I checked online the answer was supposed to be O(√n.logn) or √n.logn base 4. I am not sure how to remove the square root from n. |
T(n) = 2T(n/4) + sqrt(2) |
|time-complexity|recurrence-relation| |
I am bit confused on these terminologies.
While studying Paging of Operating System we study about Page and Frame.
> Size of one Frame of Main Memory = Size of one Page of a Process
While studying Cache Memory Mapping in Computer Organization we study about Memory Block.
> Size of one Block of Main Memory ... |
Page/Frame VS Block |
|computer-architecture|operating-systems|memory-management|cpu-cache|virtual-memory| |
Count how many pairs have a product of 1; there are n^2 = 10^12. It’s all the cases 1^x = 1^z. Then ignore w, y = 1.
Count the cases with identical left and right side w^x = w^x. There are (n-1) * n cases.
Divide the numbers from 2 to n into (here) about 999,000 non-powers, about 1000 squares, 100 cubes etc. Eac... |
Count how many pairs have a product of 1; there are $n^2$ = $10^{12}$. It’s all the cases $1^x = 1^z$. Then ignore w, y = 1.
Count the cases with identical left and right side $w^x = w^x$. There are $(n-1) \cdot n$ cases.
Divide the numbers from 2 to n into (here) about 999,000 non-powers, about 1000 squares, 10... |
You just have a sequence of boolean values, either true or false. How you calculate which ones are true or false is both trivial and irrelevant. So you need to find the longest possible subsequence of all true values.
May I suggest that your solution to this is bizarrely complex. There is no need for a search tree ... |
You just have a sequence of boolean values, either true or false. How you calculate which ones are true or false is both trivial and irrelevant. So you need to find the longest possible subsequence of all true values.
May I suggest that your solution to this is bizarrely complex. There is no need for a search tree ... |
This looks quite NP-complete to me (just guessing). Obviously if S is not connected then you split it into connected sub-graphs and solve each one individually. Call two nodes a, b connected if their distance is at most k.
Since this is NP-complete, just a heuristic: Put the nodes in some order. If a comes before b... |
Given: T(n) = 2T(n/4) + sqrt(2)
Complexity should be sqrt(n) => n^(1/2).
Please let me know whether the following derivation makes any sense.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/I3XO5.png |
The problem is a case of [list-labeling problem](https://en.wikipedia.org/wiki/List-labeling_problem).
It seems impossible to fullfill `Addition of a new tuple doesn't change any already existing mappings as they are in use elsewhere` requirement, as even unacceptably large $N$-bit mappings (labels of size $m = 2^{\... |
With $T(n)=\sqrt n\log n$, $$T(n)-2T\left(\dfrac n4\right)=\sqrt n\log n-2\sqrt{\frac n4}\log\frac n4
\\=\sqrt n\log 4.$$
|
The problem is a case of [list-labeling problem](https://en.wikipedia.org/wiki/List-labeling_problem).
It seems impossible to fullfill `Addition of a new tuple doesn't change any already existing mappings as they are in use elsewhere` requirement, as even unacceptably large $N$-bit mappings (labels of size $m = 2^{\... |
T(n) = 2T(n/4) + sqrt(n)
I am trying to solve this question and ended up with the answer O(√n.log√n). But when I checked online the answer was supposed to be O(√n.logn) or √n.logn base 4. I am not sure how to remove the square root from n. |
T(n) = 2T(n/4) + sqrt(n) |
null |
When you decide on a cryptographic scheme you want to know that cracking it is an NP complete problem --- that is, you want the encoding/decoding scheme you want to be as hard as possible to crack.
For example, RSA encryption relies on the NP-complete problem of factoring (very large) numbers into their prime factors. |
Paging is a non-contiguous, fixed size partitioning method to allocate memory to a process. The process(virtual address space/virtual memory) is divided into fixed size partitions(pages) and then loaded into main memory. [This post][1] explains why page size is the same as frame size.
<hr>
A cache block/cache li... |
Paging is a non-contiguous, fixed size partitioning method to allocate memory to a process. The process(virtual address space/virtual memory) is divided into fixed size partitions(pages) and then loaded into main memory. [This post][1] explains why page size is the same as frame size. A page is not the same as a frame,... |
null |
As we know, Quickselect chooses a 'random' element in order to sort the array around that element in every iteration.
Assume the random element is at most the $\frac{1}{k}\cdot n$ largest element, and at least the $\frac{k-1}{k}\cdot n$ largest element, for some constant $k>1$.
I'm asked to prove that under tho... |
Modified Quickselect - Proving linear time |
|recurrence-relation| |
As we know, Quickselect chooses a 'random' element in order to sort the array around that element in every iteration.
Assume the random element is at most the $\frac{1}{k}\cdot n$ largest element, and at least the $\frac{k-1}{k}\cdot n$ largest element, for some constant $k>1$.
I'm asked to prove that under tho... |
You can do it by proving by induction that there exists a constant $A$ such that for all $n\geqslant 0$, $T(n) \leqslant Akn$.
Note that the constant $A$ can be chosen depending on $T(1)$ and such that the $\mathcal{O}(n)$ in your relation is $\leqslant An$. |
null |
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i... |
I am reading the paper HyperEnclave. I have a few questions about the OS in general.
1) Is is safe to assume that attackers cannot mount physical attacks during boot process of the OS?
2) Can we assume that the OS is benign during boot process?
3) Is it possible to remove some parts of the OS and disable DMA ... |
Is booting only a part of OS possible? |
|operating-systems|security| |
This problem does not admit even a constant-factor polynomial time approximation algorithm, unless P = NP.
Proof:
Assume there exists a polynomial time $\alpha$-approximation algorithm $A$ for this problem. Consider the following reduction from Hamiltonian path:
Given an unweighted undirected graph $G$ as inpu... |
I know that regular languages are closed under closure properties. But, for example, we know if $L$ is regular, then its complement $L^\complement$ is also regular. If we have $L_1$ and $L_2$ as regular then $L_1 \cap L_2 = L_3$ makes $L_3$ regular. Now for the case of when $L$ is not regular, then its complement $L^\c... |
Regular language under intersection and complement confusion |
|formal-languages|regular-languages|automata|finite-automata| |
Intersection of 2 non regular languages means the languages [could be anything other than regular][1], and each class of languages have their own set of [closure properties][2]. The problem of finding which class a language belongs to is undecidable.
[1]: https://en.wikipedia.org/wiki/Chomsky_hierarchy
[2]: h... |
Lets say I have n lists from different sources, each contains m possible location of the user. I need to choose the most probable prediction of the user location. My idea was to pick one location from each source that so that those n locations are closest to each other. The average of those n locations will be my estim... |
Compare and find the best match from multiple lists |
|algorithms| |
Non-regular languages are not closed under intersection.
Let $L_1 = \{aa^nb^n \mid n \ge 0\}$ and $L_2 = \{ba^nb^n \mid n \ge 0\}$. Then $L_1 \cap L_2 = \emptyset$ is regular, but neither $L_1$ nor $L_2$ are regular. |
If we accept some restrictions regarding the size of the inputs, I think so.
There is a mapping betweeen types of grammar and the type of automaton that can recognise them:
Type Grammar Accepted Automaton
Type 0 Unrestricted grammar Turing Machine
Type 1 Context-sensitive grammar Linear-bou... |
If we accept some restrictions regarding the size of the inputs, I think so.
There is a mapping betweeen types of grammar and the type of automaton that can recognise them:
Type Grammar Accepted Automaton
Type 0 Unrestricted grammar Turing Machine
Type 1 Context-sensitive grammar Linear-bou... |
This is problem 88 from Miscellaneous exercises of Kozen's "Automata and Computability".
> The shuffle $A||B$ of two languages $A$ and $B$ is defined as $\{w \mid w = a_1b_1\ldots a_kb_k,$ where $a_1\ldots a_k ∈ A$ and $b_1\ldots b_k ∈ B,$ each $a_i,b_i ∈ Σ^∗\}$.
> 1. Show that if $L$ is context-free and $R$ is reg... |
Shuffle of a DCFL and a regular language |
|regular-languages|automata|context-free|pushdown-automata| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.