instruction stringlengths 0 29.8k ⌀ |
|---|
Supposed someone came up with a compression algorithm that doesn't iterate through bytes or anything to compress data, does that proves P=NP?
That is, an algorithm that doesn't rely on patterns/redundancy occurrence in data to work, but instead on some clever mathematical operations.
Such algorithm will be able t... |
Does a constant time compression algorithm proves that P=NP? |
|complexity-theory|time-complexity|np-complete|polynomial-time|data-compression| |
Nathaniels simple and elegant proof is the best way to formally convince yourself your conjectures are true. I want to add a more informal and visual explanation.
The postorder traversal of a binary tree can be found following an Euler traversal of the tree. That is, we follow the path along the tree starting at the... |
Just to be clear question at hand is the following:
> Let $c$ be a constant. Does the existence of an algorithm that takes a string $x \in \{0,1\}^*$ as input and outputs a string $f(x) \in \cup_{i=0}^c \{0,1\}^c$ such that $f$ is invertible (i.e., there exists some function $f^{-1}$ such that $f^{-1}(f(x)) = x$ for... |
Just to be clear question at hand is the following:
> Let $c$ be a constant. Does the existence of an algorithm that takes a string $x \in \{0,1\}^*$ as input and outputs a string $f(x) \in \cup_{i=0}^c \{0,1\}^c$ such that $f$ is invertible (i.e., there exists some function $f^{-1}$ such that $f^{-1}(f(x)) = x$ for... |
null |
null |
A hash table takes a key, calculates a hash value for the key, and maps the hash value to a sequence of indexes into the table. The mapping key -> hash value is fixed at least while the hash table exists.
Usually the number of possible hash values is huge; it might be $2^{64}$ which means you won't have the same ha... |
In Formal Grammars course we have a task to implement an **extended NPDA** (a pushdown automata where taking any amount of symbols from the stack is allowed (including ε) and it can be in several configurations at the same time) in any programming language. It can be one that accepts with a state or an empty stack.
... |
|automata|pushdown-automata| |
The [$y$-fast trie](https://en.wikipedia.org/wiki/Y-fast_trie) is a data structure for storing a sorted collection of $n$ integers from the range $[0, M)$. It builds on the [$x$-fast trie](https://en.wikipedia.org/wiki/X-fast_trie), which also stores elements in this range.
The space usage of an $x$-fast trie is $O(... |
$y$-Fast Tries: Why not partition into groups of $\Theta(\log^2 M)$ elements? |
|data-structures|integers|succinct-data-structures| |
Splay Tree: Repeatedly searching for the same key that's not in the Tree |
In a splay tree, doing $m$ sequential search operations for the same key that is in the tree has a time complexity in $O(n+m)$ where n is the number of nodes in the tree. Since the first search has a worst-case complexity of $O(n)$ and afterwards the node we're looking for is the new root, so further search operations ... |
The question want us to design a **Deterministic Finite Automaton (DFA)** that **accepts** Binary Representation of Integers that is divisible by 3.
>$\mathcal{L}=\{x\in\{0,1\}^∗:x$ is the binary representation of an integer that is divisible by three$\}$
>A word $w=a_{1}a_{2}...a_{n}\in \Sigma ^{*}$ is an accep... |
null |
null |
null |
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p... |
null |
I have received the below question for presentation. It was random assignments, its not my field, What is this specifically in Computer Architecture?
how CPU and GPU architecture, memory bandwidth/interfaces, and storage interfaces, all combine to contribute to overall computing performance
How and where I c... |
What can be the topic of the question |
|computer-architecture|cpu|performance|high-performance-computing| |
I have received the below question for presentation. It was random assignment, its not my field. What is this specifically in Computer Architecture?
> how CPU and GPU architecture, memory bandwidth/interfaces, and storage interfaces, all combine to contribute to overall computing performance?
How and where can I... |
What can be the topic of my assignment for presentation about overall computing performance? |
null |
I want to know the time complexity of specifically calculating ${n \choose k}$ where it is defined as
$$
{n \choose k} = \frac{n!}{k!(n-k)!}.
$$
If the factorial function is recursive $O(n)$:
```py
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
```
then ... |
Time Complexity of ${n \choose k}$ |
|time-complexity| |
I'll assume $k<n/2$, for simplicity (otherwise replace $k$ by $n-k$).
One way to calculate it is via
$${n \choose k} = {n (n-1)(n-2) \cdots (n-k+1) \over k!}.$$
This can be calculated using $2k$ multiplications. So, if we counted each multiplication/division/addition as $O(1)$ time, this would be $O(k)$ time.... |
null |
No. The output needs to be of length at least $k$, so you obviously need at least $k$ time steps even just to print the output.
To give yourself some intuition: imagine the case where $n=100$, $m=100$, and $k=$ a gazillion. Are you really expecting an efficient algorithm that takes only a few hundred steps for tha... |
Problem statement- Given a sorted array, print out the pair of elements of the array that have a sum of K, where K is a whole number.
The solution to the above problem goes like this:
> With using the Two Pointers pattern, and Pointer 1 pointing to the beginning of the array and Pointer 2 pointing to the end of th... |
Why do the pointers in Two-pointer algorithm move only towards each other? |
|algorithms|arrays| |
Consider a situation where Pointer 1 is equal to $i$ and Pointer 2 is equal to $j$, and $A[i] + A[j] > K$.
The last time Pointer 1 was incremented, Pointer 2 was in a position $j' \geqslant j$. Since it was Pointer 1 which was modified, that means that $A[i-1] + A[j'] < K$. Since the array is sorted, $A[j] \leqslant... |
In their [paper][1] Impagliazzo and Paturi in Theorem 1 claim that ETH is equivalent to $\mathsf{SNP \not \subseteq SUBEXP}$.
Since complexity classes are defined on the input size and a formula on $o(n)$ variables is solvable in subexponential time, it follows that the number of variables has to be linear in the nu... |
Let me make the following suggestion: *get rid of asymptotic notation*.
Here is how to do that. Your recurrence relation is really the following:
$$
T(n) = \begin{cases}
1 & \text{if } n = 1, \\
T(n-1) + f(n) & \text{otherwise},
\end{cases}
$$
where $f(n) = \Theta(n)$. Since $f(n) = \Theta(n)$, there are $c,C... |
Let $G = (V, E)$ be an undirected, connected and weighted graph.\
Let also $(e_{1},\ldots , e_{|E|})$ be some sort of the edges of $G$.\
let $w, w'\ :E\rightarrow \mathbb{R}$ such that:
----------
$w(e_{1})<w(e_{2})< \ldots < w(e_{|E|})$\
\
$w'(e_{1})<w'(e_{2})< \ldots < w'(e_{|E|})$
----------
Prove that... |
Prove there is only one MST in a graph |
|graphs|minimum-spanning-tree| |
>Let $G = (V, E)$ be an undirected, connected and weighted graph.
>
>Let also $(e_{1},\ldots , e_{|E|})$ be some sort of the edges of $G$.
>
> Let $w, w' \colon E\rightarrow \mathbb{R}$ such that:
> $$w(e_{1})<w(e_{2})< \dots < w(e_{|E|})$$
> $$w'(e_{1})<w'(e_{2})< \dots < w'(e_{|E|})$$
>
> Prove that the two M... |
Kruskal's algorithm goes over all edges in increasing order of weight. For each such edge, it adds it to the tree being build if it doesn't close a cycle.
As you can see, the outcome of the algorithm depends only on the relative order of the weights, not on their values.
Formally speaking (if the above informal a... |
Prove there is only one MST in a graph with distinct weights |
Formaly, for all $n>N$,
$$T(n-1)+c_0n\le T(n)\le T(n-1)+c_1n$$
If we expand the right inequality,
$$T(n)\le T(n-1)+c_1n\le T(n-2)+c_1n+c_1(n-1)\le\cdots \le T(N)+c_1\sum_{i={N+1}}^ni\\
=T(N)+c_1\frac{n^2+n-N^2-N}2.$$
We can repeat the reasoning with the left inequality. In the end, $T(n)=\Theta(n^2-n-N^2-N)=... |
Suppose given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ i... |
The average time complexity of linear search with weighted probability |
|algorithms| |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
We must assume $n$ even. As the average of an arithmetic progression is the average of the extreme members, the number of comparisons for the first half is $\dfrac{n+2}4$, and that for the second half is $\dfrac{3n}4$, noting that there is no comparison required for the last element.
Then taking the weighted sum,
... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
We must assume $n$ even. As the average of an arithmetic progression is the average of the extreme members, the number of comparisons for the first half is $\dfrac{n+2}4$, and that for the second half is $\dfrac{3n+2}4$.
Then taking the weighted sum,
$$\dfrac{5n+4}8.$$
Anyway, we can spare the very last compar... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$... |
The [$y$-fast trie](https://en.wikipedia.org/wiki/Y-fast_trie) is a data structure for storing a sorted collection of $n$ integers from the range $[0, M)$. It builds on the [$x$-fast trie](https://en.wikipedia.org/wiki/X-fast_trie), which also stores elements in this range.
The space usage of an $x$-fast trie is $O(... |
null |
I am trying to build an algorithm to compute the partition of a set into singletons or pairs for a set of cardinality 16. I am doing it in MATLAB and came up with codes that either run forever or require more memory than available. Do you know any time and space efficient algorithm? |
Set partitions into singletons or pairs |
|partitions| |
I've been given the question in the title:
Create a data structure that can insert a string S in O(|S|), string may belong to group A or B (or both). The structure should be able to return a string in it that the amount of lexicographic smaller string from A in the structure equals the amount of lexicographic larger... |
Find a string between two groups A,B that have an amount of smaller strings in A as it has larger strings in B |
|trees|strings| |
null |
I am trying to build an algorithm to compute the partition of a set into singletons or pairs for a set of cardinality 16. I am doing it in MATLAB and came up with codes that either run forever or require more memory than available. Do you know any time and space efficient algorithm?
I have added my function below.
... |
null |
I have a list of 256-bit binary data to store. Any algorithm for doing lossless compression on it in a way I can retrieve an entry by its index without decompressing the whole data (if possible). The decompressed data will also be stored as binary. I will also need to code this algorithm ground-up in a domain-specific ... |
I have a list of 256-bit binary data to store. Any algorithm for doing lossless compression on it in a way I can retrieve an entry by its index without decompressing the whole data (if possible). The decompressed data will also be stored as binary. I will also need to code this algorithm ground-up in a domain-specific ... |
Binary compression algorithm with decompress by index |
Here is one way to generate all partitions of an input array $A$ into singletons and pairs:
1. Let $x$ be the first element of $A$.
2. Recursively generate all partitions of $A \setminus \{x\}$, and add $\{x\}$ to all of them.
3. Go over all elements $y \in A \setminus \{x\}$ (if any); for each one, recursively ge... |
I have received the below question for presentation. It was random assignment, its not my field. What is this specifically in Computer Architecture?
> how CPU and GPU architecture, memory bandwidth/interfaces, and storage interfaces, all combine to contribute to overall computing performance?
How and where can I... |
Given the following family of hash functions:
$$
\mathbb{H} = \{h_c(x) = (12*x + c) \mod
| c \in \mathbb{N} \}
$$
where $m$ is the key size.
Prove that $$\mathbb{H}$$ is not a universal family of hash functions.
So I got the following idea:
If $$m = 12 $$ H is not an universal family of hash f... |
Universal family of hash functions - dependent on table size m? |
|hash|hash-tables|hashing| |
> Given the following family of hash functions:
>
>$$
\mathbb{H} = \{h_c(x) = (12x + c) \bmod
m \mid c \in \mathbb{N} \},
$$
> where $m$ is the key size.
>
>Prove that $\mathbb{H}$ is not a universal family of hash functions.
So I got the following idea:
If $m = 12 $ then $H$ is not an universal fa... |
Universal family of hash functions — dependent on table size? |
We have a cake of length $n$ and we have two arrays $A$ and $B$ of size $n$. The two arrays have order like below. $A[0]<A[1]<\dots <A[n]$, $B[0]>B[1]>\dots >B[n]$. We define a envyless location as a cut in the cake where it satisfies $A[i]=B[i]$. For example, $A=[1,2,3,4,5,6,7]$ and $B=[7,6,5,4,3,2,1]$, $A[3]=B[3]=4$,... |
Envyless location using divide and conquer |
|algorithms|divide-and-conquer| |
If $A[\text{mid}] > B[\text{mid}]$ then you can recurse on $A[\text{mid}+1, \dots, n]$ and $B[\text{mid}+1, \dots,n]$ since, if an envyless cut exists, it must be after location $mid$.
The situation $A[\text{mid}] < B[\text{mid}]$ is symmetric and you can recurse on $A[0, \dots, \text{mid}-1]$ and $B[0, \dots, \text... |
We have a cake of length $n$ and we have two arrays $A$ and $B$ of size $n$. The two arrays have order like below. $A[0]<A[1]<\dots <A[n]$, $B[0]>B[1]>\dots >B[n]$. We define a envyless location as a cut in the cake where it satisfies $A[i]=B[i]$. For example, $A=[1,2,3,4,5,6,7]$ and $B=[7,6,5,4,3,2,1]$, $A[3]=B[3]=4$,... |
I am really confused about this. I am trying to prove that the worst case of heap sort is Ω(nlogn) but i don't even know how to start. |
Heap sort worst case |
|heap-sort| |
Supose we have $n$ customers with interval that represent their range. For example, $[1,8], [2,5], [4,6], [1,9]$ for each customer. For a customer to have range coverage, a tower must be present within their range. For example, for customer $[1,8]$ to have coverage, a tower must be within range $[1,8]$. I need to make ... |
Optimal greedy algorithm solution for cell tower placement |
|algorithms|greedy-algorithms| |
null |
null |
Lexicography sort the list; i.e. Priority is based on the first and then second elements. For example $S_1=(1,8), (1,9), (2,5), S_4=(4,6)$.
Then, produce $\cap_{k=1}^iS_k$ where $\cap_{k=1}^{i+1}S_k=\emptyset$. Select from $\cap_{k=1}^iS_k$, delete $S_1,...,S_i$ and continue with the rest of the list. |
> Suppose given array of numbers with length $n=3^k$, we try to find an
> element that occurs more than $\frac{n}{3}$. So work as follow:
>
> we divide our arrays into $\frac{n}{3}$ partitions. we find
> recursively a candidate $x$ in each partition and we do a scan on
> array to find number of occurrence of each... |
Modification on Boyer Moore Algorithm |
|algorithms| |
Suppose given array of numbers with length $n=3^k$, we try to find an
element that occurs more than $\frac{n}{3}$. So work as follow:
>
> we divide our arrays into $\frac{n}{3}$ partitions. we find
> recursively a candidate $x$ in each partition and we do a scan on
> array to find number of occurrence of each c... |
null |
Suppose given two arrays $A$ and $B$ with length $n$. Array $A$ is sorted and $B$ is unsorted. Is there any lower bound for computing $A\cup B$? |
Lower bound union of a sorted array and unsorted array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.