instruction stringlengths 0 29.8k ⌀ |
|---|
null |
I've wondered this for some years now. As near as I can figure, if individual files were tagged with each of the components in a typical path (e.g. each of `['C:', 'Program Files', 'Mathematica']`, or `['var', 'log']`, etc.), you would be able to uniquely refer to files if desired, while gaining a lot of flexibility in... |
Is there any advantage to a hierarchical directory system vs. tagging files? |
|filesystems| |
For amortized analysis (aggregate method), dynamic table insertion cost can be divided into:
if no expansion, then cost = 1
if we expand the table, then cost = i (if i-1 is an exact power of 2)
then the total cost is
[![total cost][1]][1]
I don't understand how to get 2n from the part that I circle below
... |
Aggregate method for dynamic table (amortized analysis) |
|algorithms|amortized-analysis|dynamic-array| |
Upfront, I'm not a computer science or mathematics graduate. I am a dabbler/recreational programmer and I find some problem/solution scenarios intellectually stimulating to attempt. Sometimes (frequently, actually), this lack of formal training limits my ability to formulate a good solution to a problem. I can pretty... |
Suppose you have a dependency graph of "packages" registered in the ecosystem of a given programming language. We can model each package as a tuple `(name, version)` where `name` is the package name (like `Plots`) and `version` is a semantic version number (like `1.2.3`).
Each package has a set of dependencies, whi... |
Finding a minimal set of package versions in a dependency graph with constraints |
|graphs|optimization|satisfiability|constraint-satisfaction| |
null |
It should be an inequality, using the formula for the sum of a geometric series:
$$
\sum_{j=0}^m 2^j = 2^{m+1} - 1.
$$
Substituting $m = \lg n$ gives
$$
\sum_{j=0}^{\lg n} 2^j = 2^{\lg n+1} - 1 = 2n-1.
$$ |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
Show problem is NP-hard |
|np-complete|reductions|np-hard|np|polynomial-time-reductions| |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
It’s a nice problem.
If all numbers were given factored into products of prime powers, say 2^2*3^2 instead of 36, or 2^3835857109 instead of a billion digit number then the problem would be NP complete - restricting all numbers to be powers of two would produce the subset sum problem if we just look at the exponent... |
Recently I came across with a question about Von Newman architecture (which is usually used) and whether the following statement is true or not?
In Von Neumann architecture data are stored in disk and instructions are stored in state registers. Answer to this is false. Why?
Now my questions is: -> What are state ... |
Von Neumann Architeture |
|computer-architecture|compilers| |
The last times i was searching a lot to understanding Big O notation or in general asymptotic notations concepts because i didnt hear about it or them before starting studying in computer science.
- In math thoes notations can be used for n approaching to some real number a `[n-->a]` (not only to infinity), but in ... |
Confusion about asymptotic notations in math and computer science |
|complexity-theory|time-complexity|asymptotics|big-o-notation| |
The last times i was searching a lot to understanding Big O notation or in general asymptotic notations concepts because i didnt hear about it or them before starting studying in computer science.
- (In computer science) Since to get asymptotic notation of a function we must get firstly the function itself. And bec... |
Note that $\mathcal{O}(g)$ is a set of function, not a function itself, though we often write $f(n) = \mathcal{O}(g(n))$ instead of $f\in \mathcal{O}(g)$ for convenience. In computer science, this asymptotic notation is indeed mainly used for $n$ being an integer, and $n\longrightarrow +\infty$.
Also, $f(n) = \mathc... |
null |
I'm preparing for my exam and I got stuck on the following problem:
The gardening problem:
> We have access to a set of different types of seeds and a number of plant pots.For each plant pot, there is a limit to how many seeds can be planted in that particular pot.
>
>In addition, there are seeds that cannot be... |
I want to write a regular grammar that follows C language. I almost wrote the grammar but was not able to resolve how to define a variable.
Def: Variable can be any combination of characters but it should not be an existing keyword.
I tried writing something like this but not sure how to write it/
<Var> -> {... |
Regular grammer such that it reject keywords |
|regular-languages|programming-languages|regular-expressions| |
Asymptotics is indeed a way to compare the performance of algorithms, and to attest whether they are usable in practice. However, asymptotics are not everything: in the big-o notation, the value of the constant matters in many cases. For example:
- Fibonacci heaps are one of the best way to implement heaps in terms... |
null |
Consider any computational problem in which the inputs are integers.
As far as I understand, if the problem has a strongly-polynomial time algorithm, it means that the algorithm uses a polynomial number of arithmetic operations in integers, and polynomial space.
Now, suppose we want to solve the same problem but ... |
Does "strongly-polynomial time" implies "polynomial time in the unit-cost model"? |
|polynomial-time|real-numbers| |
I know that the optimization version of NP-complete problems belong in NPO. What about co-NP-complete problems? Is there a co-NPO class, or is it just NPO?
I've also never seen the name for the complexity class of optimization problems whose decision version is NExpTime-complete. Is it called NExpTimeO? Is there a c... |
What is the name of the complexity class for the optimization version of co-NP-complete and coNexpTime-complete problems? |
|complexity-theory|optimization|complexity-classes| |
The proof seems ok to me. The fact that you didn't use multiple capacities does not mean something went wrong: some problems are inherently more complex than others, and a reduction from a simpler problem to a more complex problem is generally easier.
For example, doing a reduction from the $\texttt{Clique}$ problem... |
There is no difference between $\mathsf{NPO}$ and what you would call $\text{co}\mathsf{NPO}$.
To explain why, I will try to use a problem as an example:
- the problem $\texttt{Clique}$ is defined as follow:
> Input: an undirected graph $G$ and an integer $k$.
>
> Question: does $G$ have a $k$-cli... |
null |
There is no difference between $\mathsf{NPO}$ and what you would call $\text{co}\mathsf{NPO}$.
To explain why, I will try to use a problem as an example:
- the problem $\texttt{Clique}$ is defined as follow:
> Input: an undirected graph $G$ and an integer $k$.
>
> Question: does $G$ have a $k$-cli... |
There is no difference between $\mathsf{NPO}$ and what you would call $\text{co}\mathsf{NPO}$.
To explain why, I will try to use a problem as an example:
- the problem $\texttt{Clique}$ is defined as follow:
> Input: an undirected graph $G$ and an integer $k$.
>
> Question: does $G$ have a $k$-cli... |
Given an integer $n$ and a tree set $S$, I would like to find the *approximate* median $x$ of the integer set $T := \{i \in \mathbb N : i < n \wedge i \notin S\}$. There are no constraints to the distribution of $S$, so it is not possible to assume that $S$ is uniformly distributed over $(0,n)$.
I would define "appr... |
Approximating the median of the complement of a set |
|algorithms|data-structures|search-trees|balanced-search-trees| |
Given an integer $n$ and a tree set $S$, I would like to find the *approximate* median $x$ of the integer set $T := \{i \in \mathbb N : i < n \wedge i \notin S\}$. There are no constraints to the distribution of $S$, so it is not possible to assume that $S$ is uniformly distributed over $(0,n)$. This problem can be fou... |
null |
Given an integer $n$ and a tree set $S$, I would like to find the *approximate* median $x$ of the integer set $T := \{i \in \mathbb N : i < n \wedge i \notin S\}$. There are no constraints to the distribution of $S$, so it is not possible to assume that $S$ is uniformly distributed over $(0,n)$. This problem can be fou... |
null |
null |
null |
_Summary: the memoization technique is a routine trick applied in dynamic programming (DP). In contrast, DP is mostly about finding the optimal substructure in overlapping subproblems and establishing recurrence relations._
_Warning: a little dose of personal experience is included in this answer._
_Reading sugge... |
null |
_Summary: the memoization technique is a routine trick applied in dynamic programming (DP). In contrast, DP is mostly about finding the optimal substructure in overlapping subproblems and establishing recurrence relations._
_Warning: a little dose of personal experience is included in this answer._
_Reading sugge... |
Prove the following problem is NP-Complete:<br>
The problem gave a directed graph G, and several subsets of vertices of such graph are being specified as T1,T2,....Tn, and the subsects could intersect, does there exist a path in G where it doesn't contain any cycle and for every subsect Ti, the path consist of exactl... |
NP-Complete Reduction |
|np-complete|np|decision-problem| |
I think a reduction from $\texttt{Directed Hamiltonian Path}$ (not cycle) would work quite well.
Given a digraph $G = (V, E)$ where $V = \{v_1, …, v_n\}$, consider the digraph $G' = (V', E')$ where:
- for all $i \in \{1, …, n\}$, $T_i = \{v_{i,1}, v_{i,2}, v_{i,3}\}$;
- $V'$ consist of three copies of each ... |
Currently I'm using the well-known ratio-2 algorithm which is nice and fast, but I'm looking for an intuitive way to improve my results.
All the articles I read so far were way too complicated for me, I'm looking for simple ideas to improve the results.
What I got so far:
```python
def approx_vc(g):
... |
null |
I would add that kernel registers are the ones extraneous to a user process, but help the OS and CPU enforce privilege levels. The registers that contain the upper and lower bounds of memory accessible by a user process in x86 are examples. |
No. For instance, consider the following algorithm to compute the square root of the input $x$: use binary search on $t$ (computing $t^2$ in each iteration) to find the largest $t$ such that $t^2\le x$. This is a strongly polynomial time algorithm, but converting it to infinite-precision arithmetic does not give an a... |
I expect that a brute-force solution will suffice. Enumerate all possibilities for the first word; for each such, enumerate all possibilities for the second word that respect constraint 3 and don't re-use any letter found in the first word; for each such, enumerate all possibilities for the third word; etc. You can t... |
One standard approach for package managers these days seems to be to use a SAT solver (or ILP solver). That seems like a plausible solution. All of your requirements can be expressed in SAT (or ILP). |
null |
null |
null |
Starting from the leftmost position, maintain a histogram of the symbol frequencies. All entries initially zero. Every time you process a symbol, check if it is a new one (frequency still zero), and increment a count of "lacunary" symbols in the string; also increment the frequency for this symbol and if it reaches exa... |
Actual compilers cheat here, instead of doing a full per character grammar they instead do a per token grammar.
This means that there is a tokenizer which will preparse the character stream with a regular language parser and emit a stream of tokens. These tokens are then the whitespace, operators, keywords, identifi... |
The problem is to count number of unique binary search trees with keys $a_1,a_2,...,a_n$, given that some of the keys are not unique. For example, $a$ could be 2, 1, 1, 4, 3, 4.
We could try an approach that is similar to the case when keys are unique - choose some root node from $a$ and then solve two subproblems -... |
BSTs with repeating keys |
|trees|combinatorics|binary-trees|search-trees|counting| |
Starting from the leftmost position, maintain a histogram of the symbol frequencies. All entries initially zero. Every time you process a symbol, check if it is a new one (frequency still zero), and increment a count of "lacunary" symbols in the string; also increment the frequency for this symbol and if it reaches exa... |
I found following statements in [6.4.16. Arbitrary-rank polymorphism](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/rank_polymorphism.html) of ghc document.
> GHC uses an algorithm proposed by Odersky and Laufer (“Putting type annotations to work”, POPL‘96) to get a decidable algorithm by requiring some he... |
Is type inference for arbitrary-rank types decidable when supplied type signatures? |
|type-theory|type-checking|type-inference|haskell| |
### $T$ as the union of subintervals ###
Let $U = [1,n-1]$. In your problem, you can think of $S$ as elements removed from $U$. Removing an element splits $U$ into several smaller subintervals. The union of all these subintervals generates $T$.
Let $S'$ be $S \cup \{n\}$. Working with $S'$ instead of $S$ will make ... |
### $T$ as the union of subintervals ###
Let $U = [1,n-1]$. In your problem, you can think of $S$ as elements removed from $U$. Removing an element splits $U$ into several smaller subintervals. The union of all these subintervals generates $T$.
Let $S'$ be $S \cup \{n\}$. Working with $S'$ instead of $S$ will make ... |
### $T$ as the union of subintervals ###
Let $U = [1,n-1]$. In your problem, you can think of $S$ as elements removed from $U$. Removing an element splits $U$ into several smaller subintervals. The union of all these subintervals generates $T$.
Let $S'$ be $S \cup \{n\}$. Working with $S'$ instead of $S$ will make ... |
Any tree structure can be labeled with keys to make a BST. This property does not need for the keys to be different.
That means that there are as many BST over $n$ keys (some not unique) as there are binary trees over $n$ nodes: the $n$-th Catalan number, $C_n = \frac{1}{n+1}\binom{2n}{n}$. |
### $T$ as the union of subintervals ###
Let $U = [1,n-1]$. In your problem, you can think of $S$ as elements removed from $U$. Removing an element splits $U$ into several smaller subintervals. The union of all these subintervals generates $T$.
Let $S' = $S \cup \{n\}$. Working with $S'$ instead of $S$ will make so... |
### $T$ as the union of subintervals ###
Let $U = [1,n-1]$. In your problem, you can think of $S$ as elements removed from $U$. Removing an element splits $U$ into several smaller subintervals. The union of all these subintervals generates $T$.
Let $S' = S \cup \{n\}$. Working with $S'$ instead of $S$ will make som... |
The following comes from section _Dynamic Tables_, _Introduction to Algorithms_ by Cormen. et. al.
---
In the following pseudocode, we assume that $T$ is an object representing the table. The field $table[T]$ contains a pointer to the block of storage representing the table. The field $num[T]$ contains the number... |
null |
The following comes from section _Dynamic Tables_, _Introduction to Algorithms_ by Cormen. et. al.
---
In the following pseudocode, we assume that $T$ is an object representing the table. The field $table[T]$ contains a pointer to the block of storage representing the table. The field $num[T]$ contains the number... |
Let $P$ be a set of finite points in $\mathbb{R}^n$ and $S$ be a set of $n$-spheres that follows these two properties:
- Each $n$-sphere in $S$ overlaps with at least one of the other $n$-spheres in $S$,
- For all $p \in P$, there exists $s \in S$ with center point $c_s$ and radius $r_s$ such that $\text{distanc... |
Algorithm for finding the set of minimum, bounding $n$-spheres that covers a finite set of points in $\mathbb{R}^n$ |
|algorithms|computational-geometry| |
With the decision problem Clique, I mean:
Given a graph $G$, does $G$ admit a clique of size at least $k$?
From [Wikipedia][1], one finds that the brute force algorithm of testing all possible subsets of size $k$ results in a complexity of $O(n^kk^2)$. On the other hand, Wikipedia also states that a maximum size... |
Is it correct to state the decision problem Clique can be solved in time $O(\min(n^kk^2, 2^{n/4}))$? |
|time-complexity|clique| |
In Introduction to Algorithms by Thomas H. Cormen, when talking about prefix code for Huffman encoding, it says that:
"Although we won’t prove it here, a prefix code can always achieve the optimal data compression among any character code..."
How can we prove such a claim? My first thought was in the direction o... |
Optimal Encoding for charectar codes |
|algorithms|greedy-algorithms|cryptography|algorithm-design|huffman-coding| |
There have been processors doing it differently, but it is most most likely that your processor has one set of registers per virtual core. Having a second set of registers that are just needed when switching between user mode and kernel mode would be extremely wasteful. Registers are expensive.
What happens: Your u... |
Yes, I think the most famous example is the $\pi$-calculus, which Milner showed to be complete by such a reduction in [Functions as Processes](http://hal.archives-ouvertes.fr/docs/00/07/54/05/PDF/RR-1154.pdf). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.