instruction stringlengths 0 29.8k ⌀ |
|---|
Find the largest segment within a queried range? |
|data-structures| |
|complexity-theory|time-complexity|data-structures| |
Imagine there is a linear list or array.
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ retur... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i<=e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum.
... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maximum... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maxi... |
null |
Let $a_i$, $b_i$, etc., be a literal, i.e., a variable or the negation of a variable.
3-SAT concerns formulas in CNF form: $(a_1 \vee a_2 \vee a_3) \wedge \dots \wedge (b_1 \vee b_2 \vee b_3)$ (3-CNF). The problem of whether or not such a formula has an assignment of its Boolean variables such that it evaluates to ... |
Why can't 3-SAT be solved efficiently if you convert all clauses (x ∨ y ∨ z) into (u ∨ z) by introducing a variable? |
null |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term `largest` we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is maxi... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
|complexity-theory|time-complexity|data-structures|segment-trees| |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
null |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
Personally, I'm not enamored of the "rules-based reasoning vs case-based reasoning" categorization; I'm not sure it is a particularly useful mindset for modern machine learning. For instance, deep learning is one of the most effective ML methods used today in several domains, yet it doesn't seem to fall into either of... |
null |
null |
**Exam Question:**
A five-stage pipeline has stage delays of 150,120,150,160 and 140 nanoseconds. The registers that are used between the pipeline stages have a delay of 5 nanoseconds each.
The total time to execute 100 independent instructions on this pipeline, assuming there are no pipeline stalls, is _______ nanos... |
Execution Time in Stage Pipeline |
|computer-architecture|cpu-pipelines| |
**Exam Question:**
A five-stage pipeline has stage delays of 150,120,150,160 and 140 nanoseconds. The registers that are used between the pipeline stages have a delay of 5 nanoseconds each.
The total time to execute 100 independent instructions on this pipeline, assuming there are no pipeline stalls, is _______ nanos... |
Read it like this: total time = $n*tp + (k-1)*tp$
$n*tp$ is the time the instructions take .. sort of. But it would be the time between when the first instruction starts, and when the last instruction *starts*. That means the program has not finished yet, some instructions are still in the pipeline, we have to wait ... |
I have a 3D scan of an object with multiple faces, for example a standard 6 face die. The scan is a point cloud file of the die.
I am able to convert the point cloud into a mesh and retrieve faces from the mesh. But what I'm not able to figure out is how to smooth the faces so instead of having thousands of faces I en... |
3d Mesh and face smoothing |
|computational-geometry| |
Let's brush up pipelining a bit. To summarize, the goal of pipelining is to make the ***clocks per instruction (CPI)*** approach $1$, which means that as you keep **increasing the number of instructions they take only $1$ clock cycle(which is the time taken by the slowest stage in the pipeline) to complete**.
**Ass... |
Let's brush up pipelining a bit. To summarize, the goal of pipelining is to make the ***clocks per instruction (CPI)*** approach $1$, which means that as you keep **increasing the number of instructions they take only $1$ clock cycle(which is the time taken by the slowest stage in the pipeline) to complete**.
**Ass... |
Let's brush up pipelining a bit. To summarize, the goal of pipelining is to make the ***clocks per instruction (CPI)*** approach $1$, which means that as you keep **increasing the number of instructions they take only $1$ clock cycle(which is the time taken by the slowest stage in the pipeline) to complete**.
**Ass... |
It is well known that classical regexes recognize exactly regular languages. But in practice, many programming languages have extensions to the regex syntax which potentially broaden the field of recognized languages. (For example, recursive regexes, lookarounds, ...)
Are there any papers or is there literature that... |
Power of regex extensions |
|formal-languages|reference-request|regular-expressions|research| |
null |
Read it like this: total time = $n*tp + (k-1)*tp$
$n*tp$ is the time the instructions take .. sort of. But it would be the time between when the first instruction starts, and when the last instruction *starts*. That means the program has not finished yet, some instructions are still in the pipeline, we have to wait ... |
The longest stage takes 160ns + 5ns = 165ns. That means one instruction can leave the fourth stage every 165ns, not quicker. You just calculate the time until the first instruction leaves the 4th stage, then the time until the 100th instruction leaves the 4th stage, and the time until the 100th instruction exits the pi... |
null |
An abstract data type is defined by a domain (possible values taken by the type) and the operations that are defined on it. Usually, one lists the minimal set of operations sufficient to achieve a given task.
**First example:**
We define the ADT "parity". The underlying set is the naturals, and the following oper... |
An abstract data type is defined by a domain (possible values taken by the type) and the operations that are defined on it. Usually, one lists the minimal set of operations sufficient to achieve a given task.
**First example:**
We define the ADT "parity". The underlying set is the naturals, and the following oper... |
null |
I want to optimally assign $m$ jobs equally to $n$ workers, where $m>n$. Assume $m = an$ for some integer $a$, so that each worker must get exactly $a$ jobs. I know this can be done by duplicating the workers to have $a$ copies of each, and then solving using the Kuhn-Munkres algorithm, which would result in $O(m^3)$.... |
fastest algorithm for rectangular linear assignment problem |
|time-complexity|assignment-problem| |
I am asking this question because for some reason ascii codes from range `128 - 255` have a size of 2 bytes but their composition is 8 bits which makes them a "byte". So I am confused as to why this certain ranges have 2 bytes when all of them only consist of 8 bits for example :
**127 → 01111111 (1 byte)**
```
>>... |
What defines a byte? |
|logic| |
A "byte", as defined by the C and C++ standard, is the accessible unit of memory, and exactly large enough to hold one char, signed char, or unsigned char. It must be at least 8 bits, but can be larger.
A "byte" that is exactly 8 bits in size is also called an "octet". Octets are always 8 bit, bytes are not.
As... |
We are given $k$ segments $(s_1,e_1),(s_2,e_2),(s_3,e_4),...,(s_k,e_k)$ where $s_i\le e_i$.
Now we are given a query interval $[L,R]$ to find the largest segment $(s_i,e_i)$ contained within $[L,R]$.
By the term **largest** we mean among all the segments contained within $[L,R]$ return the one whose $e_i-s_i$ is ma... |
We measure the running time of an algorithm $A$ as a function of the input *to that algorithm*, not as a measure of the length of inputs to any subroutines or subalgorithms that $A$ might invoke.
Let $L_1$ be the size of the input to LP1, $L_2$ be the size of the input to LP2 before substitution, and $L_3$ be the si... |
{"OriginalQuestionIds":[127579],"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
|formal-languages|regular-expressions|computation-models| |
null |
If space and amount of hardware is no concern, then you can do what most CPUs do: For two n-bit numbers, use n^2 AND gates to produce n^2 zeroes and ones, then use n^2 full adders to reduce the number of values by 1/3, do that again until you can get the final result with one set of full adders.
Time = O(log n), ha... |
null |
If space and amount of hardware is no concern, then you can do what most CPUs do: For two n-bit numbers, use n^2 AND gates to produce n^2 zeroes and ones, then use n^2 full adders to reduce the number of values by 1/3, do that again until you can get the final result with one set of full adders.
Time = O(log n), ha... |
Simply avoid all the crossings.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/axZOI.png |
null |
Just a fun puzzle that occurred to me. Given the function below which converts decimal integers to binary strings, is it possible to predict which decimal numbers will lead to binary strings with no zeros?
I.e. is there a way to ensure this function only returns strings of 1s *without building the string and checkin... |
Decimal To Binary Conversion: Predicting Numbers With No Zeros |
|binary| |
A binary string with only 1's represents a number that is a power of 2 minus one.
So if the rules allow to test whether a decimal number is a power of two then the solution is to add one to the number and keep deviding it by two and checking whether the remainder is zero in each step. |
null |
A sequence of positive real numbers **S1, S2, S3, …, SN** is called a superincreasing sequence if every element of the sequence is greater than the sum of all the previous elements in the sequence. E.g: 1, 3, 6, 13, 27, 52.
Given a sorted sequence **A**, I want to iterate over all superincreasing combinations of **... |
Enumerate all superincreasing subsequences |
|algorithms|complexity-theory|dynamic-programming| |
A sequence of positive real numbers **S1, S2, S3, …, SN** is called a superincreasing sequence if every element of the sequence is greater than the sum of all the previous elements in the sequence. E.g: 1, 3, 6, 13, 27, 52.
Given a sorted list **A**, I want to iterate over all combinations of **A**, which are super... |
Your problem can be solved in $O(\log k)$ time per query by augmenting layered range trees. Let me start with a slower solution first, and then I discuss how the time complexity can be improved.
Consider each segment $[s_i, e_i]$ as a $2$-dimensional point with an associated weight $w_i$. In your case $w_i = e_i - s... |
Your problem can be solved in $O(\log k)$ time per query by augmenting layered range trees. Let me start with a slower solution first, and then I discuss how the time complexity can be improved.
Consider each segment $[s_i, e_i]$ as a $2$-dimensional point $(s_i, e_i)$ with an associated weight $w_i$. In your case $... |
null |
I don't know what the "rectangular linear assignment problem" is, but your problem can be solved in $O(n^{2 + o(1)} \log a)$ time, by [reducing to max flow](https://cstheory.stackexchange.com/a/51804/5038) and then using a state-of-the-art max flow algorithm, such as the recent algorithm by [Chen et al](https://arxiv.o... |
May not be the best solution in terms of complexity, because of duplicate summation operations with further elements, but much better in the general case.
def superincreasing_combinations(g):
ln = len(g) - 1
operate = {}
ret = set()
for i, e in enumerate(g):
operate[(... |
null |
I am preparing a list of algorithms for which big theta expression for (worst case) runtime is not known. This is for a class to demonstrate the point that tight analysis of an algorithm may not be easy at times. I am interested practically useful and hopefully simple (not required though) algorithms - importantly the ... |
Algorithms with different upper and lower bounds |
|algorithms|asymptotics|big-o-notation| |
null |
In my problem of interest I have an arbitrary, finite set $S \subset \mathbb{Z}^3$. And I would like to minimally cover it with any of the axis-aligned cubes of fixed size $\ell \in \mathbb{N}$.
I know there exist approximation algorithms with logarithmic-ish approximation factors for the covering problem in general... |
Efficiently covering a finite set of points in $\mathbb{Z}^3$ by fixed size, axis-aligned cubes? |
|approximation|set-cover| |
Suppose I have L bits. First, I want to multiply the L bits with L orthogonal codes of length N, and then I want to add all the vectors.
So, first, I have to do a scalar multiplication with a vector and then addition. Please refer to the figure for more clarity.
Thanks in advance.
[` RPC, which adds a new entry in a database, and `Delete(entry)` RPC, which deletes an existing entry from a database.
The problem happens, when `Insert(entry)` RPC is followed by `Delete(entry)` RPC, but due to various reasons (e.g. network latency), t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.