instruction stringlengths 0 29.8k ⌀ |
|---|
null |
null |
null |
Let's say N students
S1, S2, ... SN
with their respective candies count
c1, c2,... cN
The ask is to distribute the candies (whole number only) as evenly as possible among the students, with last student can get the extra candy.
Hence, average cookie ```(c1 + c2 + ... + cn)/N```
E.g
student -... |
Algorithm to balance candies among students |
|algorithms|distributed-systems| |
null |
As written in other answers, the contributions of AlphaDev are:
- A branch-less implementation of sort for short vectors (from which most of the speedup over std::sort comes)
- A reduction in the number of instructions to be executed.
In the meantime, others have provided even shorter/faster instruction sequen... |
null |
The source does not seem to talk about pure in a functional programming sense. Note it says "pure method" and not "pure function".
Call-by-value is not really a type of method either. It is a way of passing arguments. A better name might be pass-by-value. In some programming languages, like C++, one function can hav... |
null |
Despite a huge amount of literature regarding table representation and indexing in secondary memory (also including database books), I found no information on how relational databases represent records generated from intermediate results in secondary memory. How are they representing this, thus considering that you mig... |
Secondary Memory Data Structures and allocation strategies for intermediate query results |
|data-structures|memory-management|database-theory|virtual-memory| |
null |
null |
null |
null |
null |
null |
([Context][1])
Given two byte arrays of length 16, say $L$ and $H$, one can define a mapping $M$ from the set of all bytes to itself in the following way.
If $0 \le b \lt 256$ is a byte, let $\text{lo}(b)$ denote the lower 4 bits of $b$ and let $\text{hi}(b)$ denote the higher 4 bits of $b$.
Let $L_i$ (resp. ... |
Specialized SAT solver (?) |
|algorithms|complexity-theory|satisfiability|sat-solvers| |
Given the following theorem and definitions from *Introduction to Algorithms* 3rd edition by CLRS:
**Theorem 22.5: (Correctness of breadth-first search**)
Let $G = (V, E)$ be a directed or undirected graph, and suppose that $BFS$ is run on $G$ from a given source vertex $s \in V$. Then, during its execution, $BF... |
|algorithms|graphs|algorithm-analysis|shortest-path|graph-traversal| |
null |
Consider A, B where for problems of size n they both take n log n and n steps respectively, except there is always exactly one problem of size n where A takes n/4 and B takes n/2 steps. Answer your question for these A, B. |
Lets talk of each case one by one:
(**FINDING FROM THE START**)
SINCE QUESTION HAS ASKED US TO FIND THE ELEMENT FROM THE START AND HAS TO REACH PARTICULARY TO A PLACE THAT IS 8 TH FROM THE START . ACTUALLY MANY OF US BECOMES THAT WE HAVE TO TRAVERSE THE LINK LIST A LONG BUT ACTUALLY WE DONT HAVE TO BECAUSE **SINCE IT... |
null |
null |
Consider signed integers with common addition and multiplication.
Reassociation of expression is another equivalent form.
Say expressions:
a * b + a * c + c * b
a * (b + c) + c * b
a * b + c * (a + b)
Are all reassociations of each other.
Lets call optimal reassociation with one with minima... |
Optimal reassociations is NP-hard? |
|np-complete|compilers| |
null |
You can use this [Automaton Simulator][1] which has a Debug/Trace feature to help you understand the PDA for non-palindromes. Testing the PDA with pen and paper is a bit more challenging. It is best to first understand the logic behind the PDA.
### Algorithm for non-palindromes
> We can use the PDA for the language... |
> Systems impose semantics to clarify functionality. For example, a system may disallow a mount over a directory that contains files; or it may make the mounted file system available at tha directory and obscure the directory's existing files until the file system is unmounted, terminating the use of the file system an... |
Why can't we mount multiple filesystem in same mountpoint? |
|operating-systems|filesystems| |
I'm trying to convert a x86 assembly language program to binary. I have read a 1979 Intel 8086 manual and so understand the basic architecture, however I am still unsure as to how to convert this. Here's the code:
```
MOV BX, 1300H ; Load the Base Address 1st input Matrix in BX
MOV BP, 1400H... |
How do you convert this x86 assembly program to binary |
|binary|assembly| |
null |
Perhaps your confusion comes from the fact that you're imagining the filesystem being mounted as a subdirectory of the mount point.
That's not the case.
If you mount what you call `file_system_1` at, say, `/something/mount_point` then the path that refers to root of the file system will be `/something/mount_point... |
Perhaps your confusion comes from the fact that you're imagining the filesystem being mounted as a subdirectory of the mount point.
That's not the case.
If you mount what you call `file_system_1` at, say, `/something/mount_point` then the path that refers to root of the file system will be `/something/mount_point... |
It’s a trick question. Finding the k-th number takes O(k). Finding the 8-th item can be done in a constant number of steps so it takes O(1). |
null |
It’s a trick question. Finding the k-th number takes O(k). Finding the 8-th item can be done in a constant number of steps so it takes O(1).
But with this kind of question, you are unlikely to do this just once. As an example, if you want the k-th item for each 1 <= k <= n, that only takes O(n) steps. If you want i... |
null |
This can be solved with 2SAT. No need for 3SAT.
Finding $L,H$ so that $M$ satisfies $M(b_0) = m_0, \dots, M(b_p) = m_p$ is an instance of 2SAT. Notice that in each constraint $M(b)=m$, both $b$ and $m$ are constants, not variables. So you have a constraint of the form
$$L_{\text{lo}(b)} \land H_{\text{hi}(b)} ... |
null |
null |
null |
This problem comes from a competitive programming problem. I'll restate it(feel free to see it [here][1]):
> A balanced bracket sequence is a bracket sequence(including open and
> close only) of even length such that we can add 1 and + to make it a
> valid mathematical expression. Given a balanced bracket sequen... |
How prove this graph statement related to bracket sequence |
|algorithms|graphs|correctness-proof| |
How to understand this graph problem related to bracket sequence? |
SunOS 4.1 supported something like what I think you're getting at, called the Translucent File System. The idea is you could stack multiple filesystems in the same location.
When searching for a file, searching was performed from the top of the stack downwards, until the first file with that name is found.
Howeve... |
If you use MPI to implement your parallel program, you can define your own reduction operator (besides using standard, predefined operators). This allows implementation of complex, user's defined reduction.
In particular, your object instances A and B are respectively the first and the second parameters of the fun... |
I know matrix multiplication of matrices with real numbers is bounded by $ \Omega (n^2 log(n))$, but what about if all numbers are natural? Can we use the same methods to get a lower bound for this case and how should I do this? Also, what is the current known bound for this case? |
Matrix multiplication of natural numbers |
|matrix-multiplication| |
Given a directed graph, you can construct a new graph $G'$ where you replace each vertex $v$ with two vertices $v_{\text{in}}$ and $v_{\text{out}}$. Then you add the edge $v_{\text{in}}v_{\text{out}}$ with capacity equal $v$'s capacity in $G$. Then for each edge $vu$ in $G$, you add the edge $u_{\text{out}}v_{\text{i... |
> Definition 2.3 (PAC-learning) A concept class $C$ is said to be PAC-learnable if there exists an algorithm $A$ and a polynomial function $poly(·,·,·,·)$ such that for any $ε > 0$ and $δ > 0$, for all distributions $D$ on $X$ and for any target concept $c ∈ C$, the following holds for any sample size m ≥ poly(1/ε, 1/δ... |
PAC-learning framework: Why the sample size must also be polynomial if the full sample is received by the algorithm |
|machine-learning| |
On page 11 in the book *Foundation of Machine Learning*, 2nd edition MIT press, the author wrote:
> Definition 2.3 (PAC-learning) A concept class $C$ is said to be PAC-learnable if there exists an algorithm $A$ and a polynomial function $poly(·,·,·,·)$ such that for any $ε > 0$ and $δ > 0$, for all distributions $D$... |
On page 11 in the book *Foundation of Machine Learning*, 2nd edition MIT press, the authors wrote:
> Definition 2.3 (PAC-learning) A concept class $C$ is said to be PAC-learnable if there exists an algorithm $A$ and a polynomial function $poly(·,·,·,·)$ such that for any $ε > 0$ and $δ > 0$, for all distributions $D... |
Given are the coordinates of a convex polygonal area ("field"), a moving circle of radius r ("crayon") and a home location for the crayon ("home") well outside the field.
**Main goal**: Get the shortest total end-to-end path of the crayon so the crayon fills most of the area of the field.
**Price functions**
- ... |
Minimum time inpainting a polygon with constraints |
|algorithms|optimization|polygons| |
Algorithm:
1. Recursively keep removing degree 1 nodes from the graph.
2. Now, there are only either degree 0 nodes, or nodes with degree >= 2.
3. Now, check the degree of *v*. If its degree is 0, then *false*, otherwise *true*. |
I wondered if, for a fixed integer k ≥ 3, how can I construct a circuit for each n ∈ N, that takes as input an n-bit integer x and outputs whether 3/k==0?
Considering an n-bit integer as input:
e.g. ...10101110, where a0 is the rightmost bit and aN the leftmost bit, mod 3 has a cycle of 2:
(a0 * 2^0 + a1 * 2^1... |
For Instance, if I allowed the user to pass in expressions like "35 + 2 * 5" as strings, how would I go about writing such a program?
Also, what topics does this question fall under? |
How to evaluate an arbitrary mathematical expression |
|programming-languages|semantics| |
Well, this is a common problem, that is used similarly for making a programming language. I do not know exactly what branch is belongs to, my guess would be something similar to computational linguistics, but this is of course, a simpler case I believe.
Anyways, I would probably go ahead and make a token system and ... |
So, the question goes as follows:
Justify the validity of following statement:
"If x^2 bit dataword is encoded with two dimensional parity check code having x + 1 rows then it is possible to correct upto x bit errors"
|
A mathematical question on error detection |
|computer-networks| |
For a bit of context, I was going through the previous year questions of my college computer networks course and found this in one of the papers. I don't even know how to go about solving this problem, it would be really helpful if someone could help me with this.
The question goes as follows:
Justify the valid... |
***Problem:***
Imagine you are an agent with a knapsack, who travels a known route of cities. All cities are different: $C_1 \rightarrow C_2 \rightarrow \dots \rightarrow C_n$. Each city offers you to buy fixed commodity or to sell it (but only to buy or to sell, never both). Prices are known and available; availabl... |
Find max total revenue in a directed graph |
|graphs|linear-programming|network-flow|knapsack-problems| |
What is a tight upper bound on the number of maximal induced trees in a connected triangulated planar graph. One such tree is shown in the illustration below.[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/yDGiE.png |
Number of maximal induced trees in a connected planar graph |
|algorithms|graphs|combinatorics|discrete-mathematics|planar-graphs| |
Insertion sort is quadratic. You would never, ever consider doing insertion sort for 500 input items. Not even 50.
You can only ever discuss this matter with an actual implementation on an actual machine. So Big-O is totally irrelevant. You don't get to the stage where it is relevant. The average time to sort n ite... |
You can solve the problem in time $O(n)$ using dynamic programming.
For $i=0, \dots, n$ and $v=0, \dots, 100$, let $r[i,v]$ be the maximum revenue that you can obtain when you only visit the first $i$ cities and you need to end your journey with a volume of exactly $v$ in your knapsack. If that's impossible, let $r[i,... |
[Pumping lemma](https://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages) is allowed to be used in this assignment so I have tried to make $|0^{m+b|y|-|y|}| = |xy^b| = a!, a\ge |y|,a\ge n$ so that $gcd(|0^{m+b|y|-|y|}|,n) \neq 1$. |
How to proof that $L=\{0^m1^n\;|\; \mathbf{gcd}(m,n)=1\}$ is not regular |
|formal-languages|regular-languages| |
The following answer assumes that volumes are integers.
You can solve the problem in time $O(n)$ using dynamic programming.
For $i=0, \dots, n$ and $v=0, \dots, 100$, let $r[i,v]$ be the maximum revenue that you can obtain when you only visit the first $i$ cities and you need to end your journey with a volume of ex... |
Your problem can be solved by reducing it to a min-cost max-flow problem where a unit of flow represents one unit of commodity. The A negative cost represents a profit.
Create a directed graph containing $n+3$ vertices in total: there are three vertices named $s$, $t$ and $t'$, and the remaining $n$ vertices are $C_... |
Your problem can be solved by reducing it to a min-cost max-flow problem where a unit of flow represents one unit of commodity. The A negative cost represents a profit.
Create a directed graph containing $n+3$ vertices in total: there are three vertices named $s$, $t$ and $t'$, and the remaining $n$ vertices are $C_... |
([Context][1])
Given two byte arrays of length 16, say $L$ and $H$, one can define a mapping $M$ from the set of all bytes to itself in the following way.
If $0 \le b \lt 256$ is a byte, let $\text{lo}(b)$ denote the lower 4 bits of $b$ and let $\text{hi}(b)$ denote the higher 4 bits of $b$.
Let $L_i$ (resp. ... |
Your problem can be solved by reducing it to a min-cost max-flow problem where a unit of flow represents one unit of commodity. A negative cost represents a profit.
Create a directed graph containing $n+3$ vertices in total: there are three vertices named $s$, $t$ and $t'$, and the remaining $n$ vertices are $C_1, \... |
null |
I am trying to solve a problem where I am given a directed graph with $n$ nodes where, from any given node, I can reach one and exactly one node. Nodes contain integers from $1$ to $n$. Starting at node $1$, the problem consists in writing an algorithm which determines on which node we end up after moving along $k$ edg... |
In a directed graph, efficiently determine node reached after traveling k edges from the starting node |
|algorithms|graphs|optimization|dynamic-programming| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.