instruction stringlengths 0 29.8k ⌀ |
|---|
If the hash is calculated as h(k, i) = (h1(k) + i*h2(k)) mod |T|
What would happen if h1(k) or h2(k) is constant? Would that produce primary or secondary clustering? I think both would produce secondary clustering and I don't see how it would cause primary clustering because I feel the i multiplying h2(k) prevents t... |
What type of clustering would occur if one of the functions in double hashing is constant? |
|hashing|clustering| |
null |
let consider a simple decimal system in which precession = 3, lower exponent = -3 & upper exponent = 3.
so in order to call it uniform, number line should have a equal gaps between consecutive numbers.
case 1: $x_1 = 1.31*10^2, x_2= 1.32*10^2 $ $\therefore \Delta x =0.01*10^2 $
case 2: $x_1 = 1.31*10^{-2}, x_2 ... |
Take a C++ compiler. Start with double x = 1.0 and double y = 1e100.
Now try out various values z, and find for which z you find that x+z != x or y+z != y. What is the smallest z where 1.0 + z != 1.0 and the smallest z where 1e100 + z != 1e100? |
When $h_2$ is constant we have [open adressing][1] with linear probing. Usually the step size equals $1$, but here it is another constant. It has both primary and secundary clustering. For the primary cluster, not all keys are next to one another, but rather a constant $h_2$ places apart.
When $h_1$ is constant, I w... |
Grammars are inherently recursive objects, so the answer seems obvious: by induction. That said, the specifics are often tricky to get right. In the sequel I will describe a technique that allows to reduce many a grammar-correctness proof to mechanical steps, provided some creative preprocessing is done.
$\newcommand{... |
null |
null |
I have a simple question which I cannot answer, and it relates to [this question](https://stackoverflow.com/questions/42794263/symmetric-bipartite-matching-of-elements-in-list).
What I cannot answer is this:
1. Why does a graph with bidirectional edges destroy the "bipartiteness" of the graph?
2. Depending on th... |
Why does Hopcroft-Karp only work on bipartite graphs? |
|algorithms|graphs|bipartite-matching| |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]} |
Is the following adaptation of the graph bandwidth problem NP hard? If so, which problem could a reduction use?
Given: Graph $G = (V , E ), L:E\to \mathbb N$.
Question: Is there a $f : V \to \mathbb Z$ where for each $e = \{u, v \} \in E$, $|f (u) - f (v )| = L(e)$? |
null |
Suppose there is an algorithm $\mathcal{A}$ for the problem $\Pi$ that halts on any instance $x\in\Pi$. Someone tells me that we can run $\mathcal{A}$ on Linear Bounded Automata, but I can't understand why.
My background in Theory of Computation says that the problem $\Pi$ could be a decidable language and maybe ca... |
Why we could run the algorithm on Linear Bounded Automata? |
|algorithms|formal-languages| |
Suppose there is an algorithm $\mathcal{A}$ for the problem $\Pi$ that halts on any instance $x\in\Pi$. Someone tells me that we can run $\mathcal{A}$ on Linear Bounded Automata, but I can't understand why.
My background in Theory of Computation says that the problem $\Pi$ could be a decidable language and maybe ca... |
null |
null |
I don't see why bi-directional edges are relevant here (or what problem your construction tries to solve), the question you reference is only about undirected graphs. But I can understand your confusion with that Q&A pair. My understanding is that:
1. The questioner wants to match the entries of an array $A$ to other... |
> I wonder if $\text{P}$ is the set of languages that can be decided by
> a non-deterministic Turing machine in polynomial time?
This is the same as asking whether $ \text{P} = \text{NP}$, where $\text{NP}$ is the set of languages that can be decided by nondeterminsitic Turing machines in polynomial time. The ques... |
> I wonder if $\text{P}$ is the set of languages that can be decided by
> a non-deterministic Turing machine in polynomial time?
This is the same as asking whether $ \text{P} = \text{NP}$, where $\text{NP}$ is the set of languages that can be decided by nondeterminsitic Turing machines in polynomial time. The ques... |
If given two sets of integers how can I find an integer in the first set furthest away from all members of the second set. The distance of two integers is the absolute value of difference of the two integers. Thanks! |
Given two sets of integers find an integer in the first set furthest away from all members of the second set |
|algorithms|sets| |
[Here][1], I read this:
> For all CFL, there is a one-state PDA that recognizes this language.
What is the proof/idea behind this claim?
CFL: Context Free Languages
PDA: Push Down Automaton
[1]: https://cs.stackexchange.com/a/165657/153411 |
Is there a one-state PDA that recognizes every context free language? |
|context-free|pushdown-automata| |
null |
We have to be precise.
Each context-free language can be accepted by *empty stack* using a push-down automaton with a single state, or by *final state* and two states. (In the latter case we obviously need one accepting and one non-accepting state.)
The proof uses the equivalence between context-free grammars and... |
If you mean that you want to find the two farthest elements between the two sets this is the solution. However, you question is not very clear, so I'm not 100% sure that I understood it.
Assume your sets are $A$ and $B$, with $|A|=n$ and $|B|=m$. We can assume without loss of generality that $n\geq m$. You can solve... |
|algorithms|algorithm-analysis|computational-geometry| |
On page 77 (section 6.1) of *Types and Programming Languages* by Benjamin C. Pierce (1st and only edition thus far), there is the following quote regarding naming contexts and de Bruijn indices:
> Γ = x ↦ 4, y ↦ 3, z ↦ 2, a ↦ 1, b ↦ 0
>
> Then x (y z) would be represented as 4 (3 2), while λw. y w would be... |
If given two sets of integers how can I find an integer in the first set furthest away from all members of the second set. The distance of two integers is the absolute value of difference of the two integers.
To clarify the question: if $a_i$ and $b_j$ are elements of the first and the second sets, I am trying to find... |
Assembly language is basically meant to be a 1:1 representation of the underlying CPU machine code. (Yes I'm aware there are a few exceptions, especially with modern assemblers) The difference is you are representing actual machine opcodes with short "mnemonic codes" that make it slightly easier to understand what is h... |
It seems you almost solved the problem in your question statement. Note that the $n\neq m$ condition makes pumping hard: one needs a trick using factorials to succeed, see [Prove if $L=\{0^m1^n∣m≠n\}$
is regular or not](https://cs.stackexchange.com/a/64074/4287). We use your idea, but start at the other side.
A... |
Edit:
Since you now clarified your request, I give a new answer:
Assume your sets are $A$ and $B$, with $|A|=n$ and $|B|=m$. Let $k=\max(n,m)$. This is the procedure:
1. Join the two sets $X=A\cup B$ in $\Theta(k)$ time.
2. Sort $X$ in $\Theta((n+m)\log(n+m))=\Theta(k\log k)$ time.
3. Scan the sorted set an... |
null |
Since you now clarified your request, I give a new answer:
Assume your sets are $A$ and $B$, with $|A|=n$ and $|B|=m$. Let $k=\max(n,m)$. This is the procedure:
1. Join the two sets $X=A\cup B$ in $\Theta(k)$ time.
2. Sort $X$ in $\Theta((n+m)\log(n+m))=\Theta(k\log k)$ time.
3. Scan the sorted set and, each... |
So considering this [answer][1] for unconstrained minimization:
> For any $n$, let $f$ be a $\sigma$ strongly convex function, write $$\epsilon = \left\|\nabla f(0) \right\|_2$$ then the ball of radius $\epsilon / \sigma$ around 0 includes the minimum.
I suppose one could use the [penalty method][2] or [barrier m... |
null |
> An Alternative view of I/O programs, popular in earlier **lazy** functional programming languages, was to see the input and output as Strings, that is as lists of characters. Under that model an I/O program is a function
>
> listIOprog :: Str->Str
>
> This obviously makes sense in a 'batch' program, where al,... |
Understanding how lazy functional languages achieve IO (...sometimes?) |
|functional-programming| |
The [paper](https://arxiv.org/pdf/2101.00027.pdf) mentions a line about GPT-3's training dataset -
`Motivated by the ability of GPT-3 (Brown et al., 2020) to generate plausible code completions despite its training data not containing any explicitly gathered code datasets`
My question - I need clarification on ... |
Is the fact true that GPT-3 wasn't trained on any explicitly gathered code dataset? |
|natural-language-processing| |
I am trying to learn Scikit_Learn and build an ML model. I am learning from "Hands-On Machine Learning with SciKit-Learn, Keras & TensorFlow".
In Chapter 2, there is a review of an entire ML project from the beginning until completion. One of the steps is to transform or prepare the data for the model. There are num... |
Python Scikit-Learn transformation |
|machine-learning|python| |
I am trying to learn Scikit_Learn and build an ML model. I am learning from "Hands-On Machine Learning with SciKit-Learn, Keras & TensorFlow".
In Chapter 2, there is a review of an entire ML project from the beginning until completion. One of the steps is to transform or prepare the data for the model. There are num... |
I am trying to learn Scikit_Learn and build an ML model. I am learning from "Hands-On Machine Learning with SciKit-Learn, Keras & TensorFlow".
In Chapter 2, there is a review of an entire ML project from the beginning until completion. One of the steps is to transform or prepare the data for the model. There are num... |
I am trying to learn Scikit_Learn and build an ML model. I am learning from "Hands-On Machine Learning with SciKit-Learn, Keras & TensorFlow".
In Chapter 2, there is a review of an entire ML project from the beginning until completion. One of the steps is to transform or prepare the data for the model. There are num... |
null |
null |
null |
null |
null |
You can build a model from either untransformed data or from transformed data. The only requirement is that, at test time, you must apply the model to the same sort of data.
Which will perform better? It depends on the algorithm, the data, and perhaps other factors. Some algorithms work better with data that has ... |
Presumably "explicitly gathered" means that they didn't go out of their way to collect datasets specifically focused on code.
Undoubtedly the datasets they did use contained some code in it. The GPT3 paper says it was trained on a filtered version of CommonCrawl. This includes data from many sources that likely co... |
Let $T$ be a finitely branching tree. I will call a subtree of $T$ a "tassel" if it is of width one, closed downward, and is maximal subject to this criterion. Equivalently, a tassel is a sequence of nodes $A_1,\dots, A_n$ such that $A_i$ is the parent of $A_{i+1}$, $A_n$ has no child, and $A_1$ either has no parent or... |
Big O of a parallel tree algorithm |
|trees| |
I am interested in the following algorithmic problem:
Given a strongly connected directed graph $G$, I want a "short" (see below what I mean by short) walk that starts with a arbitrary vertex $s$ and contains all vertices of $G$.
Deciding if such walk can be a path (i.e. no repeated vertices) is a well known NP com... |
How to find a "short" walk that visits all vertices of a strongly connected graph |
|algorithms|directed-graphs|path| |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}],"DeleteType":1} |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}]} |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}],"DeleteType":1} |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}]} |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}],"DeleteType":1} |
{"Voters":[{"Id":132305,"DisplayName":"Michal Dvořák"}]} |
I'm working on constructing deterministic finite automata (DFAs) with a specific learning complexity when using the L* algorithm developed by Dana Angluin. My goal is to create a DFA of size \( n \) that necessitates \( n-1 \) equivalence queries for the L* algorithm to correctly learn the automaton.
The L* algorith... |
Constructing worst case for L* by D.Angluin |
|algorithms|finite-automata|machine-learning| |
Let $T$ be a finitely branching tree. I will call a subtree of $T$ a "tassel" if it is of width one, closed downward, and is maximal subject to this criterion. Equivalently, a tassel is a sequence of nodes $A_1,\dots, A_n$ such that $A_i$ is the parent of $A_{i+1}$, $A_n$ has no child, and $A_1$ either has no parent or... |
null |
I know that NP is a subset of EXP, but I cannot find any resources talking about whether NP = EXP or not.
My intuition tells me that any problem that requires exponential time to be solved with a DTM can be solved in polynomial time with some NDTM. Is that not the case? If so could someone provide me a problem that de... |
How could it be the case that NP != EXP? Do we know of any problems in EXP that are not in NP? |
|complexity-theory|time-complexity|np| |
null |
The answer is **no**. For any $n\geq 3$ consider an oriented cycle $C_n$ and let $u\to v$ be adjacent in the $C_n$. Create $n$ vertices $x_1...x_n$ and add edges $u\to x_i$ and $x_i \to v$. Now any walk containing all vertices has length $\Omega(n^2)$. |
Say you have a double ended priority queue in the form of a minmax heap as described [here][1].
What is the most efficient algorithm to update the priority of an existing item?
Assume that
1. I explicitly want to avoid deleting and re-inserting the item
2. The index of the existing item (pre-update) in the hea... |
Update priority of existing item in a minmax heap |
|algorithms|data-structures|heaps| |
null |
Say you have a double ended priority queue in the form of a minmax heap as described [here][1].
What is the most efficient algorithm to update the priority of an existing item?
Assume that
1. I explicitly want to avoid deleting and re-inserting the item
2. The index of the existing item (pre-update) in the hea... |
null |
Recently AI (alphazero) was used to [improve](https://www.nature.com/articles/s41586-022-05172-4) practical matrix multiplications by around 10 to 20 percent. Alphageometry and ramanujan machines all came into existence in the recent years as well. Seems like it might time AI gets used to further improve algorithms for... |
Potential of Artificial Intelligence to improve algorithm for PI |
|algorithms|optimization|artificial-intelligence|mathematical-programming| |
All of the improved algorithms that Alphazero found are basically the same idea: there is a combinatorial search space of solutions which is hard to navigate through, but it's possible to prove that you've found a solution when you propose one.
There are definitely algorithms for computing $\pi$ that live in spaces ... |
Yes, it doesn't ensure bounded waiting. It might be the case that process p1 will set its flag to 1 after p0 sets its flag to 1, and it will be stuck in the loop and p0 will keep on executing the critical section without giving any change to p1 |
Yes, it ensures bounded waiting.
In the example you have given even if p0 enters twice in a row, p1 will be able to enter in it the after p0's second entry.
Normally you will see only 1 entry to the other process is allowed for binary critical solution problem. But here 2 entries are allowed. |
> You have $n$ events on your calendar, defined as intervals with a start time $s_i$ and a finish time $f_i$.
The events might overlap, and you want to attend all the events, so you are going to create $k$ clones
of yourself to achieve this. You want to minimize the number of clones you need, $k$. A clone can attend a ... |
Interval scheduling; sort by ending times |
|algorithms|greedy-algorithms|correctness-proof|scheduling|check-my-answer| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.