instruction stringlengths 0 29.8k ⌀ |
|---|
null |
This problem is called $s$-$t$ $\texttt{NODE CONNECTEDNESS}$ and was proved to be $\#\mathsf{P}$-complete by Valiant in 1979 in *The Complexity of Enumeration and Reliability Problems*.
As such, it is $\mathsf{NP}$-hard: if it could be solved in polynomial time, you could solve $\#\texttt{SAT}$ in polynomial time, a... |
Given any singly linked-list L storing n real keys, that is, each key in L belongs to
R, design an algorithm (either in words or in pseudocode) that computes the sum of the negative keys in L. What is
the running time of your algorithm, in the worst-case, using O notation? |
Data Structure And Algorithm |
|algorithms|time-complexity|data-structures|linked-lists| |
From what we've seen so far, we can confirm that there is no single answer.
The answer depends on the context in which you want to compare “operating system” to “hypervisor”, however for basic/conceptual understanding we could say:
- Both are specialized programs to support and run programs;
- Both orchestrate... |
null |
Great conversation so far..
i spend a fair bit of time with hypervisors in edge devices.. and the discussion about what is Type1 and Type2 has always fascinated me. Type1 is usually associated with 'bare metal' whereas Type2 is associated with 'operating system hypervisor'. Bare metal must be always better right?
... |
null |
About a [Universal Computer](https://conwaylife.com/wiki/Universal_computer), this wiki says:
> A universal computer in a cellular automaton is a system that can compute anything that a Turing machine can compute (another term for this is Turing-complete). A cellular automaton in which such a system exists is called... |
What is a "universal" cellular automaton exactly, what does it look like to compute "anything"? |
|computation-models|cellular-automata| |
My book explains loads and stores like this:
[![enter image description here][1]][1]
From what I understand this means that loads and stores are made on the physical adress? But when we turn of the computer we lose the contents in RAM(physical adress), so does the computer always update the content of the virtual... |
Does the computer change the content of the virtual adress |
|memory-management|virtual-memory|memory-allocation| |
My book(digital design and computer architecture ARM edition) explains loads and stores like this:
> To perform a load or store, the processor must first translate the
> virtual adress to a physical adress and then access the data at that
> physical adress. The processor extracts the virtual page number from
> t... |
The computer cannot predict that you are about to turn it off, so yes, it updates the content of the virtual address when requested to do so, and this implies a change in content at the corresponding physical address.
(In reality, the changes to physical memory can be postponed when there are caches, but this is yet... |
My book(digital design and computer architecture ARM edition) explains loads and stores like this:
> To perform a load or store, the processor must first translate the
> virtual adress to a physical adress and then access the data at that
> physical adress. The processor extracts the virtual page number from
> t... |
A naïve solution would be to first sort all sets, taking time $O(N n \log n)$. Then, for every possible pair of sets, check if one is included in the other, and remove the included one. This checking and removing can all be done in time $O(N^2 n)$. The total time complexity would thus be $O(N n \log n + N^2 n)$, which ... |
What is the time complexity of removing among $N$ sets of size at most $n$ the sets which are included in others? |
|algorithms|time-complexity|sets| |
A naïve solution would be to first sort all sets, taking time $O(N n \log n)$. Then, for every possible pair of sets, check if one is included in the other, and if applicable remove the included one. This checking and removing can all be done in time $O(N^2 n)$. The total time complexity would thus be $O(N n \log n + N... |
What is the time complexity of removing among $N$ sets of size at most $n$ the sets which are included in another set? |
A naïve solution would be to first sort all sets, taking time $O(N n \log n)$. Then, for every possible pair of sets, check if one is a subset of the other, and if applicable remove the subset. This checking and removing can all be done in time $O(N^2 n)$. The total time complexity would thus be $O(N n \log n + N^2 n)$... |
What is the time complexity of removing among $N$ sets of size at most $n$ the sets which are subsets of another set? |
null |
As part of a [hobby project](https://cutonbuminband.github.io/counting-analysis/network.html#cliques) I stubmled into the following question which has me stumped:
Given an undirected graph $G = (V, E)$ and an integer $k$, what is that smallest number of edges that need to be added to $E$ such that the new graph $G' ... |
Determining the minimum number of edges to add to a graph to obtain a clique of size $k$ |
|algorithms|graphs|reference-request|clique| |
Maybe the confusion resides between the difference between the MMU and the caches.
The MMU translates virtual to physical addresses, it uses some pagination tables stored somewhere in memory.
Actual data is stored in various memories. It can be DRAM, it can be caches, it can be even some disk (like when computers... |
The problem is called **Defective $k$-Clique**. The optimization problem is:
**Problem:** _Defective $k$-Clique_<br />
**Input:** A graph $G$ and $k \in \mathbb{N}$.<br />
**Output:** The minimum number, $\ell$, of edges to add to $G$ such that $G$ has a $k$-clique.
Clearly, $G$ has a $k$-clique if and only if... |
null |
I am working currently on Path-Packing problems and found this Book:
https://jeffe.cs.illinois.edu/teaching/algorithms/book/Algorithms-JeffE.pdf
My question is about exercise 23b on page 184.
Here is a description of the problem :
Assume $T$ is a tree (T is not necessarily a binary tree) with n nodes and... |
I am working currently on Path-Packing problems and found this Book:
https://jeffe.cs.illinois.edu/teaching/algorithms/book/Algorithms-JeffE.pdf
My question is about exercise 23b on page 184.
Here is a description of the problem :
Assume $T$ is a tree (T is not necessarily a binary tree) with $n$ nodes a... |
I am working currently on Path-Packing problems and found this Book:
https://jeffe.cs.illinois.edu/teaching/algorithms/book/Algorithms-JeffE.pdf
My question is about exercise 23b on page 184.
Here is a description of the problem :
Assume $T$ is a tree (T is not necessarily a binary tree) with $n$ nodes a... |
null |
null |
null |
null |
I think you essentially answered it yourself (and @Yves Daoust) with the point that there's an O(log(n)) trick.
**We could say that it's the set of problems for which you can modify a known O(log(n)) algorithm by adding O(log(n)) operations.**
You asked for "the conditions" under which an array can be searched in... |
null |
**Hint:**
You cannot analyze this code in terms of two nested loops as in simpler cases, because the number of iterations of the inner loop varies depending on the data.
But you can solve this with a simple remark: as `window_end` grows by units, from `0`, and will not exceed `n:= len(arr)`, the total number of i... |
What is the proof that STCON
(returns 1 if there is a path in the directed graph $G = (V,E)$ from $ s \in V$ to $t \in V$ and else, 0.
is indeed in NL? (Non-deterministic turing machines with logarithmic memory) |
Proof that STCON is in NL |
|complexity-theory|graphs| |
First of all, people tend to forget that $\omega$ is an infimum. Whenever we write $O(n^\omega)$, we actually mean for all $\gamma > \omega$, there is an algorithm running in time at most $C_\gamma n^\gamma$, where $C_\gamma$ is a constant depending on $\gamma$ (possibly $C_\gamma \to \infty$ as $\gamma \to \omega$).
... |
Here is an NL algorithm:
- Input: Graph, nodes $s,t$
- Count the number of nodes $n$
- Guess $\ell \in \{0,\ldots,n\}$
- Repeat $\ell$ times: Guess an out-neighbor $s'$ of $s$ and set $s \gets s'$
- Verify that $s = t$ |
I have the following problem to solve:
Given a non-empty array A consisting of N integers, the task is to find the first unique number in the array. A unique number is defined as a number that occurs exactly once in the array. The desired output is the unique number with the lowest position in the array.
For exam... |
Finding the first unique number in an array with lowest position: Algorithm and Time Complexity |
|algorithms|complexity-theory|arrays|first-order-logic|integers| |
The problem is called **Defective $k$-Clique** [[Yu et al.](https://doi.org/10.1093/bioinformatics/btl014), Bioinformatics (2006)]. The optimization problem is:
**Problem:** _Defective $k$-Clique_<br />
**Input:** A graph $G$ and $k \in \mathbb{N}$.<br />
**Output:** The minimum number, $\ell$, of edges to add to... |
**Hint:**
You cannot analyze this code in terms of two nested loops like in simpler cases, because the number of iterations of the inner loop varies depending on the data.
But you can solve this with a simple remark: as `window_end` grows by units, from `0`, and will not exceed `n:= len(arr)`, the total number of... |
Consider a clause $C_k = (x_1 \odot x_2 \odot x_3)$ in *X3SAT* (exactly-one *3SAT* or one-in-three *3SAT*). Then, $C_k$ is true iff exactly one of $\{x_1, x_2, x_3\}$ is true iff $\phi_k$ is satisfiable, $\phi_k = [x_1 \Rightarrow (\overline{x}_2 \wedge \overline{x}_3)] \wedge [x_2 \Rightarrow (\overline{x}_1 \wedge \o... |
Reducibility of 3SAT to 2SAT: 3SAT to X3SAT, and X3SAT to 2SAT |
|complexity-theory|np-complete|reductions| |
**Hint:**
You cannot analyze this code in terms of two nested loops like in simpler cases, because the number of iterations of the inner loop varies depending on the data.
But you can solve this with a simple remark: as `window_start` grows by units, from `0`, and will not exceed `n:= len(arr)`, the total number ... |
Consider a clause $C_k = (x_1 \odot x_2 \odot x_3)$ in *X3SAT* (exactly-one *3SAT* or one-in-three *3SAT*). Then, $C_k$ is true iff exactly one of $\{x_1, x_2, x_3\}$ is true iff $\phi_k$ is satisfiable, in which $\phi_k = [x_1 \Rightarrow (\overline{x}_2 \wedge \overline{x}_3)] \wedge [x_2 \Rightarrow (\overline{x}_1 ... |
Can you help me in finding an algorithm that finds the first unique number in an array with lowest position? |
I have an optimization problem in which I need to schedule events and each of the events needs to be scheduled exactly once. The "cost" of scheduling one event depends on all of the events that have been scheduled before. So given a list of events `[e_1, e_2, ... e_n]`, the goal is to find an optimal order.
I think ... |
Traveling salesman problem with dynamic edge costs |
|optimization| |
The Pumping Lemma says that if a language is regular then there is associated with that language a natural number, the pumping length. The point of that length is that for any string in the language at least as long as that length, that string has a decomposition into three substrings, which satisfy the conditions of ... |
I feel that choice should work great for proving non - regularity of the mentioned language.
If $L=\{ww|w \in \{0,1\}\}^*$ and we choose $s=0^p0^p$, meaning s is atleast as long as 'p'. Then we can decompose s as follows $x=empty \ string,\ y = 0^p, \ z = 0^p$
Then we can pump 'y' according to the rules of pumpi... |
Why does Michael Sipser state that $0^p0^p$ is a bad choice for proving $L=\{ww|w \in \{0,1\}\}^*$ is non-regular a bad choice? |
|pumping-lemma| |
Your proof doesn't work. First of all you can't chose your favorite decomposition of $s$: the pumping lemma just ensures that such a decomposition
**exists** so your argument needs to work for all possible decompositions.
Nevertheless, even with your decomposition it is false that the "pumped" word does not belong... |
First of all, you don't get to pick the decomposition. So one decomposition you'd need to handle is $x = \varepsilon$, $y = 00$, $z = 0^{2p-2}$. Now if we pump $y$ for $i$ times, we get $xy^iz = 0^{2p + 2i - 2}$, which belongs to $L$. |
{"Voters":[{"Id":150711,"DisplayName":"Latif Salum"}]} |
Here's one idea.
1. Pair up each element with its index.
[(4, 0), (10, 1), (5, 2), (4, 3), (2, 4), (10, 5)]
2. Sort.
[(2, 4), (4, 0), (4, 3), (5, 2), (10, 1), (10, 5)]
3. It is now easy to recognize unique elements, because if any duplicates exist they are right next to each other. Keep o... |
I feel that choice should work great for proving non - regularity of the mentioned language.
If $L=\{ww|w \in \{0,1\}^*\}$ and we choose $s=0^p0^p$, meaning s is atleast as long as 'p'. Then we can decompose s as follows $x=empty \ string,\ y = 0^p, \ z = 0^p$
Then we can pump 'y' according to the rules of pumpi... |
Why does Michael Sipser state that $0^p0^p$ is a bad choice for proving $L=\{ww|w \in \{0,1\}^*\}$ is non-regular a bad choice? |
I want to be an OS developer. I can say I am a bit comfortable after i read few tutorial on x86 assembly.
But I see a lot detailed in intel manual, does an OS developer really need to study whole manual for its architecture.
1) Is there any alternative ?
2) Will I miss something important if only reading short t... |
Do i really need to study monstrously long intel manual? |
|operating-systems|os-kernel| |
Suppose I have the following CFG that I would like to bring to CNF
```
S -> TA | bA | Ab | b
A -> Aa|a
T -> Ab
```
Then I have two options to get rid of the nonsolitary terminal a in Aa
1 - Make a new nonterminal K and introduce the rule
The grammar in this case becomes
```
K->a
S -> TA | bA | Ab |... |
Duplicate rules in CFG |
|context-free|formal-grammars| |
null |
I'm trying to figure out a more efficient solution to the following problem.
Given a set of arrays of pairs (which can have duplicates), I need, given an array of 8 pairs, to be able to find matches between the first element of each pair (the index), outputting pairs of the second element of each pair (the payload).... |
What data structure/s can I use for fastest lookup of a permutation between two associated arrays (preserving order)? |
|algorithms|data-structures|computational-geometry|trees| |
What data structure/s can I use for fastest lookup of a permutation between two arrays of pairs (preserving order)? |
null |
In this case, both are correct, but in general, you should use method 1.
For example, suppose that you had
$$A \to Aa|a|b.$$
You might be tempted to say that we have $A \to a$ already, so let's just use $A$ instead of creating a new non-terminal, and convert this to
$$A \to AA|a|b.$$
This would be an inc... |
Your proof doesn't work. First of all you can't choose your favorite decomposition of $s$: the pumping lemma just ensures that such a decomposition
**exists** so your argument needs to work for all possible decompositions.
Nevertheless, even with your decomposition it is false that the "pumped" word does not belon... |
null |
null |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**Input:** A fixed-length array of key-value pairs `(J,... |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**Input:** A fixed-length array of key-value pairs `(J,... |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**Input:** A fixed-length array of key-value pairs `(J,... |
|algorithms|complexity-theory|data-structures|optimization| |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths, and the keys are non-zero 16-bit unsigned integers.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**I... |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths, and the keys are non-zero 16-bit unsigned integers.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**I... |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths, and the keys are non-zero 16-bit unsigned integers.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**I... |
null |
I'm trying to figure out a more efficient solution to the following problem.
**Dataset:** A set of arrays of key-value pairs `(K, V)`. The arrays have varying lengths, and the keys are non-zero 16-bit unsigned integers.
Examples:
`[(3, 100)]`
`[(1, 200), (1, 100), (2, 300)]`
`[(2, 200), (2, 300)]`
**I... |
null |
If I understand correctly, we can reformulate your problem as following:
We have a database that contains a set of sets $S_1,\dots,S_n$. You are given an input set $I$. The goal is to determine whether there is any set in the database that is a subset of $I$: i.e., does there exist $i$ such that $A_i \subseteq I$?... |
I have the following regex that I'm trying to convert to a CFG: `e|a(,a)*` (`e` representing the empty state). Basically I want to match a comma-separated list (without a leading or trailing comma) or nothing at all. Here are some of my attempts:
```
S = A
A = e | a | a , A
```
This doesn't work, it matches `,a`... |
Trouble with regex to cfg |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.