instruction stringlengths 35 29.1k |
|---|
How does the search operation for a red-black tree work and how does it take $O(\log n)$ time, where $n$ is the number of items? I know a red-black tree takes $O(\log n)$ recolorings and $O(1)$ rotations, but I was specifically interested in a good description of its search operation.
|
When a process inside a monitor with Mesa semantics finishes, another process can acquire the monitor. Now there can be starvation here when there is a thread with a lower priority.
Are there monitors of Mesa-semantics type that don't cause starvation and thus have bounded waiting?
|
This is not homework, but from a past exam. I do not know how to solve this one at all. Can anyone please take the time and show me how to do these? Thank you.
Prove that $5^n \in O(6^n)$, but that $5^n \notin \Theta(6^n)$. (Doing this shows that $6^n$ bounds $5^n$ from above, but that $6^n$ is not the tightest such b... |
Suppose that you have a DFA $M=\left(S,\Sigma,s_0,\delta,{s_f}\right)$ with $s_f\neq s_0$.
Suppose further that, for all $a\in\Sigma$, $\delta\left(s_0,a\right)=\delta\left(s_f,a\right)$.
Show that for any non-empty word $w$ over $\Sigma$, we have $\delta^{*}\left(s_0,w\right)=\delta^{*}\left(s_f,w\right)$.
I know the... |
The function is this:
function max-element
if n = 1
return A[1]
else
x = max-element(A[2...n])
if A[1] > x
return A[1]
else
return x
So to create to recurrence relation i've done this, which i'm unsure of...
T(1) = 2, because the function will only execute the first if and return if n=1... |
I've come across that question :
"Give examples of two regular languages which their union doesn't output a regular language. "
This is pretty shocking to me because I believe that regular languages are closed under union. Which means to me that if I take two regular languages and union them, I must get a regular langu... |
I came across this question today on stackoverflow. It asks:
Find the largest, $2$nd, $4$th, $8$th, ..., $2^{\log n}$-th largest element in an arrary. Use $O(n)$ algorithm. $2^k$
I've come across this before and know how it can be done, but I've been been trying to find examples of algorithms that incorporate the abo... |
Is it the same as find minimum for a binary search tree?
I know recoloring runs in O(logn) and rotations are O(1).
Even if we are wanting it to find the 'k-th' smallest key in the red-black tree.
Could someone help me understand it in more detail? Thank you!
|
Let L = {ab,aa,baa}.
I need to find L^4. From my understanding, I union the set.
So:
L^1 = {ab,aa,baa}
L^2 = {abab,abaa,abbaa,aaab,aaaa,aabaa,baaab,baaaa,baabaa}
L^3 = {abababab,abababaa,abababba,....} ??
I concatenate L^3 with L^2 as I did above correct? And then I concatenate L^4 with L^3?
|
I am trying to create a dfa for L={w: every run of a's has length either two or three}
this is my attempt at the solution..i feel like I am missing something..?
|
I have to design a Non-deterministic Turing machine that accepts only non-palindromes in $NTime(n\log n)$.
I think this would be easy on a 2-tape DTM. Simply copy the string onto the second tape – $O(n)$ time – and then check both tapes (one from beginning and the second from the end) – $O(n)$ time again.
However, I ca... |
I am looking for a software, a library or an algorithm that can be trained to recognize about a dozen speaker independent voice commands. The commands will be very distinct phrases of 4-5 words each. They can be chosen to sound very different from each other. Additionally, the commands will be in more than two differen... |
Some CPUs have a flags register (ARM,x86,...), others don't (MIPS,...). What's the advantage of having a CMP instruction to update the flags register followed by a branch instruction instead of using a zero register and conditional branches to check for sign, overflow etc?
|
Let's say that lists are defined as
List a = Nil | Cons a (List a)
Then, in Haskell is List x the greatest or least fixpoint? I'm asking because the lfp should exclude infinite lists (but you can build them in Haskell), whereas the gfp should exclude finite ones.
|
When I read computational complexity I encounter problems like 3-SAT, set cover, knapsack. In the first two variables are discrete. In knapsack the weights and values are integer and all three problems have a combinatorial structure, what I mean is selecting a finite number from a finite set.
How about problems in cont... |
In a relational model,
a schema is something which specifies the name and data type of each field.
The word "schema" is also used in "conceptual schema", "physical schema" and "external schema".
What do "schema" mean separately in the above two cases? Are they
related?
Are they related to the "schema" in cognitive... |
There are several coding operations that (I suspect) most compilers will change into more efficient operations at the assembly or machine code level. I have several questions about whether or not the compiler does any of this work, and if it's even best for the compiler to automatically do so.
(Note: These examples use... |
Suppose we are given a universal set $U$ and a family of subsets of $U$, denoted by $F$ (elements in $F$ are subsets of $U$). We assume that all elements in $F$ can cover $U$, i.e., $U\subseteq \bigcup_{e\in F}e$. Consider the following max-cost set covering problem:
$\text{argmax}_{E\subseteq F} |E|$
s.t. $U\subseteq... |
Let's say I am building a time clock app. The employee can log into the interface and then enter time for multiple projects so that we can generate reports for billing as well as payroll.
A table in the database will record the time-in and time-out for each project as a row. A user should be able to sign out and back i... |
Using the Deterministic Finite Automaton (Q, Σ, Δ, q_0, F):
Alphabet: Σ is {(0 0), (0 1), (1 0), (1 1)}
Definition of Δ to strings recursively:
Δ*(q, ε) = q for all q ∈ Q
Δ*(q, xa) = Δ(Δ*(q, x), a) for all q ∈ Q, x ∈ Σ*, a ∈ Σ
Given a string, s ∈ Σ*, we define left(s) and right(s) to be the numbers represented in cust... |
looking for some help, or at least if I'm going the right direction...
Are there functions $f$ and $g$ such that $f$ is $O(g)$ and $g$ is $O(f)$ and NO constants $c_1$ and $c_2$ exist for which $f(x) = c_1 \cdot g(x) + c_2$?
I want to say that there is not, because the definition of big O states that if $f(x)$ is $O(... |
Given numbers $n,k\in \mathbb{N}$, we consider $\mathcal P$ to be the set of all possible partitions of $n$ balls into $k$ bins.
Alternatively, $\mathcal P$ is the set of all $k$-ary vectors in $\{0,1,\ldots,n\}^k$ such that the sum of the entries is exactly $n$.
For example, if $n=4$ and $k=3$, we get:
$$\mathcal P =$... |
$ G $ and $ H $ are the generator and parity check matrices respectively of a linear block code.
Let $ G_1 = G(:, 1:n-s) $ (Matlab style representation of sub matrices). That is, $ G_1 $ is equal to the first $ n-s $ columns of $ G $, and $ G_2 = G(:, n-s+1:n) $. Let $ H_1 = H(:, 1:s) $ and $ H_2 = H(:, s+1:n) $, wher... |
Can anyone tell me how using cosine similarity to see the correlation between two documents actually shows you if someone is plagiarising the other? I understand how cosine similarity works but don't understand how using this shows how closely related they are when the cosine deals with vectors and angles. How can this... |
I'm reviewing the definition of recursion and in my notes are two questions about a recursive problem. One question asks about the base case, the other one about the small version of the problem, I always get confused about which is which... can you help me to find a way to better understand these concepts?
The example... |
The answer for this question is 81. But I count figure out why. Can someone explain to me how does this work. Thank you.
|
I often heard that "program = algorithm + data structure".
But I notice that
It seems to me that a data structure is (or may be) just a data type or extension thereof. Is it correct? But a data type is a part of a programming language, but a data structure isn't.
the operations/methods in a data structure actually im... |
This problem is based on an order picking problem with a forward area.
The problem description is as follows. We have a warehouse with a set of items $I$ and a forward area $F$ of size $k$. Each day, there is a set $D$ of deliveries. Each delivery $d_i$ is a set of items such that $d_i \subset I$ and $|d_i| < k$. The ... |
Someone recently shared with me the following problem (which I guess appeared in some kind of past coding contest):
Given $n$ points $P_i=(x_i,y_i)$ in the 2-dimensional plane, find the point $Q=(x,y)$ that minimizes the average distance from $P_i$ to $Q$.
In other words, we want to find $Q$ that minimizes the object... |
I was learning about Benes networks and was wondering why they formed bipartite graphs (and thus are two colorable) when one draws a constraint graph for them. The constraint graph is based on the intuition that we don't want two paths for packets to intersect because we want to show that the congestion is 1 (i.e. that... |
Why is it that if the edges of an undirected graph G can be grouped into two sets such that every vertex is incident to at most 1 edge from each set, then the graph is 2-colorable.
The reason that I am guessing this happens is because the graph is bipartite. But I was not sure about this... I was trying to show it was... |
In most 3d applications, the scene is projected onto a rectangular area. As the field of view increases, you see terrible distortions near the edges of the screen. Why do modeling engines limit themselves to a projection matrix when they cannot produce reasonable perspectives above 90 degrees? Why are these engines not... |
This fact seems obvious but I was unsure how to go about proving it very rigorous.
Let $|V| = n$ and $|E| = m$ for some connected graph $G$. Then consider the following proposition:
If a graph is connected then $|E| \geq n-1$, i.e. it needs at least n-1 edges.
The fact seems simple and maybe obvious but I was unsure ... |
Are there any known algorithms that correctly output "yes" to an NP-complete problem without implicitly generating a certificate?
I understand that it is straightforward to turn a satisfiability oracle into a satisfying-assignment finder: just iterate over the variables, each time asking the satisfiability oracle to so... |
Why does the empty clause is logically equivalent to a contraddiction:
$\square \cup \square \Longleftrightarrow \perp$
and why the empty cube is logically equivalent to a tautology:
$\square \cap \square \Longleftrightarrow \top$ ?
|
In purpose of load balancing I need to approximatively predict rendering time my graphics software (in the specific case it's Autodesk Maya) needs to render a task given an input file (.ma/.mb) and rendering parameters.
An intuitive way to do it is to render several frames from different parts of a scene and to extra... |
I have come across many amortized analysis using a potential function. They all look magical to me. Everything works perfectly but I never got the intuition behind how they come up with such a "magical" potential function which makes everything work. My question is can someone share their experience in developing a pot... |
Prove, using only the definition of $O()$, that $2^{\sqrt{x}}$ is not $O(x^{10})$.
I have been doing a few exercises on Big O and this is the first time I have encountered the variable in the exponent. I was wondering how to disprove this function. Any help would be appreciated
|
$\{a^mb^nc^n\mid m,n \ge 1\}$ intuitively seems like a non-regular language. It looks like the machine needs to remember the number of $b$s (which isn't limited). The pumping lemma can be used to prove a language is non-regular. In reference to the Wikipedia article linked (see "Use of Lemma"), every string I have trie... |
I've written a recursive function of a tree, and I would like to know what it's called! It's not quite the same as the height or the width of a tree, but it seems kind of like a width.
Assuming the tree $T$ is binary, we can define the function $f(T)$ as follows. If $T$ has a only a single node, let $f(T) = 1$. Othe... |
Consider the a butterfly network as defined on the following OCW notes on page 208. An explantation of it can also be found on the following page.
I was wondering if someone had a proof or an intuition on why there is a unique path from each input to each output on a butterfly network.
|
this is my first question in CS so I apologize if this question is off-topic.
If we use Newton`s Method for finding square root then complexity is $O(M(n))$ (using Wikipedia Notation: $M(n)$ is the algorithm to multiply two $n$-digit numbers).
I am interested to know whats the constant hidden in Landau notation in thi... |
Often I will encounter the use of - or even use myself - the value -1 as an edge case in otherwise integer data structures. For instance, as the value for "irreplaceable" in a Replacement Cost field.
This is especially useful where null is either unrecognised; semantically overburdened; or converted into empty when mi... |
How can I find out the time complexity for the brute-force implementation of matrix multiplication for:
Two square matrices ($n \times n$),
Two rectangular matrices ($m \times n$) and ($n \times r$)?
|
I was asked this question in an interview and struggled to answer it correctly in the time allotted. Nonetheless, I thought it was an interesting problem, and I hadn't seen it before.
Suppose you have a tree where the root can call (on the phone) each of it's children, when a child receives the call, he can call each o... |
Suppose you have a function quality(x) that returns the quality of a sequence of letters x. Given a string such as "howareyoutoday," what is the most efficient way to determine that the segmentation is "how are you today" (i.e. quality(how)+quality(are)+quality(you)+quality(today) is the maximum quality possible)?
I wa... |
In popular literature, complexities are usually used in a very imprecise manner, often to describe the runtime performance of an algorithm and denoted with "$O$". My question is about these Landau symbols.
Take Quicksort for example, which is often cited as being $O(n^2)$ in the worst case, but $O(n \log(n))$ in the be... |
Given a sequence of comparable objects $a_1, a_2, \ldots a_n,$ how quickly can we find the longest subsequence $s$ such that $s_i > s_1$ for $i > 1$? Or equivalently, how quickly can we find
$$
\underset{i}{\arg\max} \; \# \{j \mid a_j > a_i, i < j \le n \}
$$
Can it be done in less than $\Omega(n\,\lg n)$ comparisons... |
If we can achieve consensus, does it imply we can achieve mutual exclusion? Is there a difference?
Example : Paxos solves the consensus problem, can it also be used to solve mutual exclusion?
|
Imagine we have a multiple-choice exam with N questions.
Suppose we have a set of K answer sheets to the exam and their total scores (1 for a correct answer on a question, 0 for incorrect).
How much information can we extract from this set about the true answers to the exam, and what is the shape of the space of possib... |
I have been reading about Big O notation. People writing about Big O often use the terms $f(x)$ and $g(x)$. For instance, I often see people write things like $f(x) = O(g(x))$ or $f(x) \in O(g(x))$.
Obviously $f(x)$ is the running time of the given algorithm we are comparing against infinity, but what does $g(x)$ repre... |
As I understand, to show that a certain problem P is NP-hard we can reduce a known NP-hard problem, Q, to problem in P in polynomial time. To show that the problem P is NP-hard in strong sense, we can reduce a know NP-hard problem Q to problem P in pseudo polynomial time.
Is it possible to show that a certain problem P... |
I have already read different things about hamming distance, hamming code, detection and correction of memory errors, but I am still not understanding many things.
I know that the hamming distance between 2 codewords is the number of bits to be reversed to convert one codeword into the other.
I know that the hamming c... |
I was confronted with this problem in an online programming challenge and it has been bugging me since:
In the problem, you are given a list of 16-bit numbers, say
$a_0, a_1, ..., a_n$. An "XOR subsequence" is defined as the exclusive-or combination of every element in a consecutive subsequence of the list. The problem... |
I was wondering about a variation on the Stable Marriage Problem. Initially, we have two sets of entities, usually males and females, and they have preference lists ranking the other group, and through a series of proposals, we end up with a stable matching.
Thinking of it like medical schools and applicants, each med... |
I'm preparing for an exam about Trees. One of the questions that appear in Mark Allen Weiss' "Data Structures and Algorithms Analysis in C++" is:
Prove by induction that if all nodes in a splay tree is accessed in
sequential order, the resulting tree consists of a chain of left
children.
When I take a set a set o... |
I am new in writing recursive algorithm so I tried this problem from SPOJ but I could not formulate the recursive relation from where I can find the optimal solution. Can anyone help me to see the optimal solution of the problem below please.
There are N pilots working for his company (N is even) and N/2 plane crews n... |
How can prove that $2^n \nmid n!$
using binary representation for $n!$ and $2^n$.
|
Let L be the language containing all the pairs (G,v) where G is a directed graph and v is a vertex in G such that G contains a cycle that contains v and the number of different vertices that appear in that cycle is odd. Find the smallest class (NP, P or NL) that contains L.
Clearly L is in NP, I didn't manage to show... |
Given the language
$\{ <M> \mid\:$ M is a Turing machine and there is some w ∈ Σ* for which the computation M(w) takes more than 10 transitions$\}$
How can one prove that this language is decidable?
|
I know that the first instruction stored in BIOS is "mapped" to memory address 0, and that a signal on the reset pin to the microprocessor causes this instruction to be fetched, beginning the POST and all the chain-loading involved in the boot process.
I also know that there is a Memory-Management Unit (MMU?) at the ha... |
I am looking for an algorithm with time complexity in $\mathcal O(|V|)$ that determines whether a given graph $G=(V,E)$ is a caterpillar tree.
A caterpillar tree is a tree that has a path to which all nodes are connected by a maximum of one edge. So for every vertex v there is a vertex u on the path so that the discta... |
I found that Fundamentals of data structures (1982) by Ellis Horowitz and Sartaj Sahni draws my attention naturally, probably because of
their formal treatment of data structures, and
their choice of topics and
their way of organizing the topics into chapters and sections.
But the book was published in early 1980... |
I often heard that using data structures help to reduce (time or space) complexity of some operations.
I wonder if that is achieved at the cost of something else?
When solving a problem, is something still conserved, over all
choices of data structures and algorithms, just like the
conservation of energy? Such as som... |
what's the prerequisite topics needed for understanding computational complexity theory and analysis of algorithm ...including big-O and Big-theta notations and these staff. I want a mathematical background and good book suggestions for each topic ... thanks
|
In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more integers (at least one of which is not zero), is the largest positive integer that divides the numbers without a remainder. For example, the GC... |
I have finished developing an app for Android and intend to publish it with GPL -- I want it to be open source.
However, the nature of the application (a game) is that it asks riddles and has the answers coded into the string resource. I can't publish the answers!
I was told to look into storing passwords securely -- b... |
This question is related to formal model checking theory, but I cannot find a tag for it.
Let $P_{safe}$ be a safety property.
$BadPref(P_{safe})$ is the set of bad prefixes for $P_{safe}$
A Safety property $P_{safe}$ over Atomic Proposition $AP$ is regular
if its set of bad prefixes is a regular language over $2^{AP}$... |
I've looked around the net for an answer to this question and it seems as if everybody implicitly knows the answer except me. Presumably this is because the only people who care are those who have had tertiary education on the subject. I, on the other hand, have been thrown in the deep end for a high school assignment.... |
This is the question:
By definition of the IEEE754 standard, 32-bit floating point numbers
are represented as follows:
S (1 bit) E (8 bits) M (23 bits) S: Sign bit E: Exponent M:
Mantissa
Which of the following is the correct “mask bits” in hexadecimal to be
used for extracting only the exponent part o... |
Here is the description of the data structure I am looking for:
Initial Original Data
Index | Frequency |
1 3
2 1
3 7
4 2
5 6
Now it should be kept Sort-ed by their frequency inside the data structure like this,
Index | Frequency | Cumulative Frequency |
2 ... |
The subnet mask for a particular network is 255.255.31.0.
Which of the following IP address belongs to this network?
172.57.88,62 & 172.56.87.233
10.35.28.2 & 10.35.29.4
191.203.31.87 & 191.234.31.88
128.8.129.43 & 128.8.161.55
Little bit confuse about 3rd octet of SM ( i.e .31 ) But got the point that 5 bit was hi... |
In the model of (functional) programming languages as a category where the objects are types and the arrows are functions, I'm trying to really understand what's really the identity arrow.
Barr-Wells "Category Theory for CS" says you need the id function, but I wonder: it really has to be the "do nothing" function? For... |
Here is a proof that $0^*1^*$ is not regular, even though it is regular. I'm having a hard time figuring out what is wrong with the proof.
Assume $0^*1^*$ is regular. Let $p$ be the pumping length as defined by the pumping lemma. Let $s = 0^{p-1}11$, then $|s| \ge p$ and $s \in 0^*1^*$. According to the pumping lemma, ... |
I'm studying for an exam called Computer Fundamental, and started taking some previous exam but the given documents i had is way inadequate to solve all the question mentioned, like this one :
Which of the following is the correct combination of variousaddressing
modes? Here, X1 is an address which is stored in ... |
I struggle with understanding why the satisfiability in the first-order logic is undecidable. Could you explain it with some examples? I've also seen that satisfiability in some first-order formulas are decidable.
Please explain it with as much as many examples.
|
In a graph tree, is there any "smart/existing/efficient" algorithm to find linear segments of defined length?
For example given a tree graph:
g = {1 -> 2, 2 -> 4, 3 -> 6, 4 -> 8, 6 -> 12, 1 -> 3, 2 -> 5, 3 -> 7,
4 -> 9};
TreePlot[g, VertexLabeling -> True]
How can one find all linear segments of length 4. In thi... |
I needed help finding the context free grammar of this string
$$
10^{n}10^{n}1
$$
So far an idea I have is
$$
S\rightarrow 1S1S1\mid 0S \mid \varepsilon
$$
Any assistance you can provide would be greatly appreciated!
|
I am reading Frigo's "Cache-Oblivious Algorithms" paper and I need help understanding his cache complexity expressions for the base cases.
He starts on page 3 with "An $s \times s$ submatrix is stored on $\Theta (s + s^2/ \mathcal{B})$ cache lines. I can see the reason for $s^2/ \mathcal{B}$ is because we have $s^2$ n... |
this may seem to be a pretty basic question, but it is something i have been puzzling over for some time.
when calculating the activations of nodes in a hidden layer in an ANN using sigmoid neurons for use with the backpropagation algorithm - should the output of the neuron be thresholded or not?
say the activation vec... |
I understand how I would do this if the problem were as such
$8n + 5$ is $O(n)$
$c>0$ and an integer constant $n(not 0) \geq 1$ such that $8n + 5 \leq cn$ for every integer $n \geq n(not 0)$
we could let $c= 13$ and $n(not 0) = 1$
or we could let $c = 9$ and $n( not 0) = 5$.
I'm just not sure how to go about $6n^2 +12n... |
Also,
is n O(n lg n)?
I'm trying to understand this notation to better understand Big O. (Apparently they ask you questions about Big O in interviews, so I wanted to learn). I found a few formulas that I didn't understand.
|
I am trying to show the following problem is NP-hard and would like some help.
Inputs: Integer $k$, and unordered set of $N$ numbers, $O$
Output: the $\max \sum\limits_{S_i \in S} \operatorname{mean}(S_i)$
where $S=\{S_1,S_2,...,S_k\}$, $O=S_1 \cup S_2 \cup \dots \cup S_k$ and elements of $S$ are disjoint.
In simpler... |
According to this chart, DCFLs are closed under reversal.
However, I am not convinced as the intuitive proof (reversing the arrows of the controlling finite state machine and switching the pushes and pops) for this seems to depend on non-determinism in choosing the null transition to take from the initial state (since ... |
I've found an heuristic algorithm[scatter search] that solves the common version of MDMKP(MultiDemand Multidimensional Knapsack Problem)[the one that maximizes] but what about the minimize version? is there any algorithm for that kind of problem? is it possible to obtain the solution to the minimum MDMKP from the maxim... |
Asked this at programmers Stack Exchange, was recommend to ask here :
What would be the big o for the algo:
for (i=0; i < n*n; i++)
for(j=0; j<i*i; j++)
As per my understanding 1st loop will loop upto n^2 times. 2nd loop will go around n^2 times.
Am I right or is it a O(n^6) representation.
Also is there a easy way ... |
I'm a teacher assistant in my university and my next topic is recursion. what way is the best to teach recursion so that the student can grasp the concept easily and can think recursively?
I was thinking about explaining the stack structure to teach recursion but I'm worried that they get stuck in tracing the process. ... |
I was reading this article about types, and started wondering how static type checkers could enforce other properties in programs. For example, say I wanted to create a language which would allow checking at compile time that a particular function was only called at most once every 300ms. How would I go about specifyin... |
This may not be strictly a computer science question but is related.
Whenever there is some function that computes more than two elements, is it possible that all elements are computed at once? Or is computing in composite/series a required limitation of the brain?
For instance, to add three numbers, we add two and the... |
For every rational function $p(x)/q(x)$ where $p$ and $q$ are polynomials with non-negative integer coefficients, does there exist a polynomial function $h$, such that, if you input a reduced fraction $a/b$ of length $m$ into $p(x)/q(x)$ and the output is of length $n$, then $m\leq h(n)$?
The length can be taken as the... |
Just as the question asks, I am trying to understand the relationship between the number of accept states a DFA has (not necessarily the total number of states) and the languages it can accept.
I understand that the pumping lemma can be used to show that if a language has a length greater than the number of states, wh... |
I was working on a project and I needed to display N squares inside a rectangle area and I want them to be as large as possible, no rotations. More formally:
Problem: Given N equal-sized squares and a rectangle with width W and height H, find out the maximum size of the squares L such that the squares fit inside the re... |
Could someone explain this proof to the following question?
Lemma 22.1 from intro to algorithms
Let $G=(V,E)$ be a directed or undirected graph, and let $s\in V$ be any vertex. Then, for any edge $(u,v)\in E$,
$$\mathrm{dist}(s,v)\leq \mathrm{dist}(s,u)+1\,.$$
Proof.
If $u$ is reachable from $s$, then so is $v$. In th... |
I have problem that is reducible to the following:
From a collection of stacks, find all items whose "keys" are on all stacks.
My current solution to this problem is to just pop things off as quickly as possible store the items in the language's set type, compute the intersection every once in a while (the stacks are r... |
Assuming i have 4 blocks of cache memory, Using the LRU (Least Recently Used)
replacement algorithm on this following sequence of access to memory blocks: 1 2 3 4 5 2 5 4 1 5 2 3 :
1 2 3 4 5 2 5 4 1 5 2 3
1 1 1 1 5 5 5 5 5 5 5 5
2 2 2 2 2 2 2 2 2 2 ... |
The elements of $\mathbb{Z}$ can be enumerated as $0, 1, -1, 2, -2, 3, -3, \ldots$. Similarly, the points of the lattice $\mathbb{Z}^2$ can be enumerated
$$(0,0), (1,0), (0,1), (-1,0), (0,-1), (2,0), (1,1), (0,2), (-1,1), \ldots$$
I would like to extend this algorithm to $\mathbb{Z}^n$. Is there a simple way to do tha... |
@Babou's answer to a recent question reminds me that at one time I think I read a paper about the equivalence (in terms both of the facts that can be inferred or proved and the time complexity of running the inference algorithm) of data-flow analysis, abstract interpretation, and type inference.
In some sub-cases (like... |
I'm trying to figure out a good (and fast) solution to the following problem:
I have two roles I'm working with, let's call them players and teams having many-to-many relationship (a player can be on multiple teams and a team can have multiple players). I'm working on creating a UI element on a form that allows a user ... |
Let A be an fixed array of size n. Q(i,j,k) is number of elements from A[i] to A[j] which are less than k.
Currently I am using segment tree with each node containing sorted array of leaf elements. This answers the query in O((log n)^2) with O(n*log n) space and per-processing.
Is there a way to answer this in O(log n... |
Tarjan's off-line least-common-ancestors algorithm is given as follows:
LCA($u$)
Make-Set($u$)
Find-Set($u$).$ancestor$ = $u$
for each child $v$ of $u$ in $T$
$\quad$ LCA($v$)
$\quad$ Union($u$,$v$)
$\quad$ Find-Set($u$).$ancestor$ $= u$
$u.color = $ BLACK
for each node $v$ such that $\{u, v\} \in P$
$\qua... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.