instruction stringlengths 35 29.1k |
|---|
My question is related to memory segmentation in 8086. I learnt that,
8086 has a 20 bit address bus. And so it can address 2^20 different addresses. Which means it has an memory size of 2^20, i.e, 1MB.
I have a few doubts:
What I understand from the fact that 8086 has a 20 bit address bus is that it could have 2^20 ... |
For example I know the union of 2 either decidable or recognizable languages is decidable or recognizable. But say the union of two languages is decidable, does this tell us anything about themselves?
|
I am currently studying Computer Networking, and I was reading about the different types of Application Layer Protocols. In the book I am reading (Computer Networking: A Top-down Approach) it is mentioned that: "Once the client
sends a message into its socket interface, the message is out of the client’s hands and is
“... |
What is a good book or resource to find practical exercises of analysis of the complexity of concrete algorithm implementations (that is, which asymptotic complexity does a particular code have)?
I'm interested not in solving algorithms but in practising finding out their complexity. I have seen a couple of these kind... |
$$
5n^4\log{n} - \frac{100n^2}{\log_4(n^2)} + 40
$$
I am currently studying algorithm analysis and i need to express this function in terms of big O, theta and omega, so I should find C, and N0 for each case I solved big Oh with c=40 and n0 = 1 but I am stuck here any help ?
|
I am currently doing a project where I have to detect if the the microscopic images given are blurry. I tried canny edge detection but they seem to perform not so good in detecting blur. I realised that I should rather look exactly for blur image detection. I found that modern cameras use contrast detection but I don't... |
Its a question from a test in machine learning.
I have 3 binary variables x1,x2 and x3 (which means that each one of them can be either 1 or 0), each one of them has a binary output y (can be 0 or 1).
for a general probabilistic classifier (it could be any probabilistic model except that its not a model that relies on ... |
A functional is a function which takes another function as a parameter.
The fixed point of a function is an input such that
F(x) = x
Given an example functional,
T(F,x,y) = if x = 0 return 0
else return y + F(x - 1,y)
what is the fixed point of the functional?
The functional looks similar to a recursive ... |
I have this language
$L = \{a^{n}b^{3n}c^{2m} : m,n \ge 1\}$.
I have to determine a free context grammar that generates L.
Looks easy BUT i have a question about the grammar I found.
First things first, this is my grammar:
$S \Rightarrow BC$
$ B \Rightarrow aBbbb\ \backslash \ abbb $
$ C \Rightarrow Ccc \ \backslash ... |
I want to solve the following using master theorem.
$T(n)=4T(n/8) + \sqrt n (\log_2 n)^2$
I have: $a=4, b=8,f(n)=\sqrt n (\log_2 n)^2$
I calculate $n^{log_b a} = n^{\log_8 4} = n^{2/3}$
I compare $f(n)=\sqrt n (\log_2 n)^2$ with $n^{2/3}$, and see that $f(n)$ grows faster than $n^{2/3}$.
So using master theorem, rul... |
Let us suppose that we have a mutation rate of 5%. What does this mean?
Each gene of each individual has 5% of probability of change to another value? At the end, around 5% of the genes of each individual in the population will be changed.
Each individual in the population has 5% of probability of having a random gene... |
For example:
$f(n) = n(log_2 n)^4$ vs $g(n) = n^{1/3}$
Does f(n) grow slower than g(n) as a general rule, even for decimal exponents? I tried doing a limit test but symbolab limit calculator is saying that Steps are currently not supported for this problem.
I graphed them over a large range and it does appear that g(n)... |
I recently started learning about randomized online algorithms, and the Wikipedia definitions for the three adversary models are very unhelpful to put it mildly. From poking around I think I have a good understanding of what an oblivious adversary is. From my understanding, the oblivious adversary must determine the "w... |
In a Turing machine I read that it can go only right or to left. But in my book [elements of theory of computation, Book by Christos Papadimitriou and Harry R. Lewis ] it says that Turing machine operates in two discrete steps
1) put the control unit in new state.
2)Either: replace the symbol already there by the symbo... |
Looking at the examples here and here both refinement type and liquid types look very similar. What are the differences and similarities?
|
There are two sorted arrays A and B containing distinct values. How to find all the pairs $(a,b)$ such that $a \ge 3b$ and a is in A and b is in B. This needs to be done in linear time.
I have tried solving it but it is taking me $n \log n$ time, not $n$. I simply use binary search to look for the value of $b$ correspo... |
I have come across the following optimisation subproblem:
Geometric Disjoint Set Cover. Consider a collection $C$ of (not necessarily distinct) ranges taken from a universe range $X \subset \mathbb{R}^d$. Does there exist a $k$-partition of $C$ into set covers of $X$?
I am particularly interested in the case where ra... |
There are some different cache replacement policies could be implemented in CPU. As far as I know, ones have better hit ratio on specific type of code than others, but if that type changes (for example, loops and scan of long file), other replacement policy may become more effective. Did somebody try to investigate how... |
Given that,
$T(n) = \sum_{i=2}^{n} \log_i n$
I need to find the asymptotic boundary of $T(n)$.
Answer given is $\theta(n)$.
Please provide explanation.
|
How likely is for a pseudorandom number generator to generate a long sequence of similar numbers? "Similar numbers" could be same numbers, or numbers from a given range.
For example, if we consider PRNG algorithm being a simple counter counting from 0 tom MAX, the distribution is uniform and there's a guarantee of not ... |
I'm implementing push contour feature for web application. It is an ability to change the contour by touching it. Mouse pointer becomes a circle that bumps contour (like in Photoshop). Contour is polyline object and pushing circle is some point with defined radius.
Sequence of actions on mousemove is following:
Detect... |
I have a question about some theoretical CS. Particularly, designing an NFA diagram (nondeterministic finite automata) from some conditions.
I think I understand how to construct NFA's under most simple circumstances, however, the types that I am struggling with are not conditions.
Here is one that has me really stump... |
In bioinformatics they study biological data. I have seen codes dealing with DNA sequences. However, they are treated as string literal. I was wondering if there were data structures or classes in OOP sense ( even partial representation) for RNA and DNA.
Any help would be greatly appreciated.
CS
|
For an assignment for one of my courses, one of the questions is to provide a regular expression for the language:
"the set of strings such that the number of 0’s is divisible by six, and the number of 1’s
is divisible by five." over the alphabet {0, 1}.
I made a DFA for this language and it has 30 states. However, goi... |
Problem:
Consider $[k] = \{ 1, 2, \dots, k \}$ and function (of two arguments) $f: [k]^{2} \rightarrow \mathbb{N}$ that is defined for all $(n, m) \in [k]^{2}$ (all ordered pairs of numbers from $[k]$). Also, we know that for all $n, m \in [k]$ $$f(n, m) = f(m, n) .$$
Also, consider the set $S_{k}$ of all permutations ... |
In a Binary Tree, can two nodes have the same value? For example:
3
/ \
4 4
/ \
1 2
They are two different nodes, but they have the same value. Here is code:
function TreeNode(val) {
this.val = val;
this.left = this.right = null;
}
const r = new TreeNode(3);
r.left = new TreeNode(4);
r.right = ... |
I'll do my best to explain my question but what I'm wondering is how to calculate a theoretical running time of an algorithm. In my textbook I have questions written as such:
If a $\Theta(\log_2{n})$ algorithm requires 20 seconds to execute on an input of one million elements, approximately how long should it take on ... |
It seems that in a full AVL tree, the left edge is always the minimum-cost path. For example, take the following full AVL tree:
The min-cost path would be 8-6-5. However this is not the case with other AVL trees. Take the previous tree with an additional 4 inserted:
Here the min-cost path would be 8-6-7 rather than 8... |
Let there be graph $G = (V, E)$. $G$ has neither loops nor parallel arcs.
$V = A \cup B, \, A \neq \emptyset, \, B \neq \emptyset, A \cap B = \emptyset$
For simplicity's sake, let's consider $G$ is directed.
$\forall \ e \in E \ \, e.tail \in A, \, e.head \in B, \, e.length \in (\mathbb{Z} \cap [1, 100]) \cup -\infty \... |
Given a graph $G(V, E)$ with capacities on the edges such that all edges have a capacity of $\sqrt2$ apart from one edge with a capacity of 2. need to find max flow efficiently.
I can run Dinic on this graph or FordFulkerson but I know it can be more time-efficient.
What I have tried -
transform all edges capacity to b... |
Here, n = no. of rows and m = no. of columns
Suppose, there are three matrices - A[3][2] : {{1,2},{3,4},{5,6}} ;
B[3][2] : {{1,2},{3,4},{5,6}} ;
C[3][2] : {{2,1},{3,4},{5,6}} .
Here A=B , A!=C and B!=C .
So, task is to check equality between all possible combinations of 2-dimensional matrices from a given set of matri... |
Recently I've read wiki page about Robert Kowalski (Prolog author) and stumbled upon interesting concept of Event Calculus. The wiki article mentions only few applications of this logical language. I am wondering if any tools are using EC for program verification (similarly to Effect Systems).
Is there any technology (... |
Let's say I have a list of n items - i1, i2, ..., in.
These items are similar to one another based on some similarity function, say similar_func(item_x,item_y) where item_x,item_y belong to list i1, i2, ... in. This function returns a number that ranges from 0 to 1, where 0 means not similar at all and 1 means exactly ... |
Let there be graph $G = (V, \, E)$. $G$ has neither loops nor parallel arcs.
$V = A \cup B, \, A \neq \emptyset, \, B \neq \emptyset, A \cap B = \emptyset$
For simplicity's sake, let's consider $G$ is directed.
$\forall \ e \in E \ \, e.tail \in A, \, e.head \in B, \, e.length \in (\mathbb{Z} \cap [1, 100]) \cup -\inft... |
Let there be graph $G = (V, E)$. $G$ has neither loops nor parallel arcs.
$V = A \cup B, \, A \neq \emptyset, \, B \neq \emptyset, A \cap B = \emptyset$
For simplicity's sake, let's consider $G$ is directed.
$\forall \ e \in E \ \, e.tail \in A, \, e.head \in B, \, e.length \in (\mathbb{Z} \cap [1, 100]) \cup -\infty \... |
It's a homework problem.
Assume $\Sigma = \{a ,b\}$, I am asked to construct a regular expression that does not have both the substrings bba and abb.
My idea was: construct a regex that matches everything except bba, construct a regex that matches everything except abb and OR them together.
The first answer I thought o... |
I'm trying to understand this dynamic programming related problem, adapted from Kleinberg's Algorithm Design book.
You’re consulting for a group of people (who would prefer not to be
mentioned here by name) whose jobs consist of monitoring and analyzing
electronic signals coming from ships in coastal Atlantic waters. T... |
I'm looking for the name of a data structure. It is organized like a balanced tree. The elements need not be comparable. Instead of asking if the tree contains a thing (like you would with a collection of comparables), you can query for any k'th element in logarithmic time. You can insert before or after any k'th e... |
I was skimming the Deep Blue overview paper and on page 242 it says: "The search control does not really implement the regular αβ search algorithm. Rather it implements a minimum-window αβ search algorithm. This eliminates the need for value stack." I know the basics of alpha beta pruning/search, but couldn't find any ... |
Show $T(n) = T(\lfloor n/2 \rfloor) + T(\lfloor n/4 \rfloor) + T(\lfloor
n/8 \rfloor) + n$ is $\in O(n)$.
I will make the bound to be $\in O(cn)$ instead.
Proof by strong induction.
Base case n =1
$T(1) = c$ and $cn=c*1=c$ $\checkmark$
Inductive Hypothesis : $T(k) \in O(ck)$ for $1\le k<n, n>1$.
Inductive Step: Pr... |
Why is the complexity of BFS & DFS frequently written as O(V+E) vs. O(max(V,E)) when the 2 are equivalent?
I feel like the latter conveys more meaning and is more simplified, and we can more easily see that the time grows as a function of the number of vertices OR edges, whichever is greater, whereas the latter reads "... |
It is well known that in $NFA-\epsilon$ the extended transition function is defined as it follows:
\begin{align*}
\hat\delta: Q &\times \Sigma^* \rightarrow \mathbb{P}(Q) \\
\hat\delta(q,\epsilon) &= ECLOSURE(q) \\
\hat\delta(q,\alpha x) &= \bigcup_{p_i \in \hat\delta(q,\alpha)}ECLOSURE(\delta(p_i,x))
\text{ for } \al... |
UPDATE: I abandoned this initial approach in favor of a more powerful invariant I worked out after posting. I've detailed that one in an answer below.
I'm new to algorithm correctness proof-writing but am keen to improve my skill there.
I have a first attempt here, but I think I'm missing a final step. The algorithm i... |
Given a function E(x) which outputs 0 is x is even and 1 is x is odd, prove that this function is primitive recursive.
My attempt is as follows
$$ E(x) = x \mod 2$$
To show that any function is primitive recursive, it must be obtained by composition and recursion from the initial functions $s(x) = x + 1; n(x) = 0$ ... |
I had to solve a problem on finding the minimum vertex cover on a bipartite graph, and I used the Kőnig's theorem and reduced it to maximum matching problem on bipartite graph, which is easily solvable, however I'm not sure how to find the actual minimum vertex cover from the edges I have. I easily get the size, howeve... |
I'm trying to convert the following NFA to a regular expression.
I've attached my work below and end up with the expression $aa^*bb^*$. As far as I can tell, this doesn't seem correct but I've been working at it for quite a while. Can anyone tell me where I went wrong? And if it happens to be correct, can you tell me... |
There is a leetcode question about merging k sorted arrays. I would like to be able to explain the time complexity of the following naive solution:
function mergexsSortedArrays(xs) {
if (xs === null || xs.length === 0) {
return [];
}
let l1 = xs[0];
for (let i = 1; i < xs.length; i++) {
let l2 = xs[i]... |
I am currently reading the definition of a triple-array trie as described here.
More precisely, I am trying to understand the nature of the three arrays:
base. Each element in base corresponds to a node of the trie. For a trie node s, base[s] is the starting index within the next and
check pool (to be explained lat... |
Say i have cropped an image and have hidden some part of it, like shown below
Is it possible for anyone to download this image and able to decipher what the hidden text is?
|
I have a list of recurring tasks (1k+ tasks) and I am trying to find a optimal scheduling given a shared constrained resource.
In other respects the tasks are independent of each other
Each task is configured to run recurrently at a given interval (i.e "cron" job).
For instance a particular task could have been config... |
This is a practice problem from my algorithms class. (And no, it was not assigned as homework. I can't prove this, but you don't have to answer if you don't believe me.) To me this seems like a very difficult problem to show NP-completeness for since due to its abundance of features, it's tricky to mold a known NP-comp... |
I recently learned about the conversion, but I seem to be stuck.
I need to convert the following CFG to CNF:
$S → XY$
$X → abb|aXb|e$
$Y → c|cY$
There is no S on the right side, so I did not need to add another
I removed the null productions $X → e$
$S→XY|Y$
$X→abb|aXb|ab|$
$Y→c|cY|$
I removed unit production
$S→Y$ ... |
I wanna know if what this link https://stackabuse.com/shell-sort-in-java/'s calculation of the complexity of shell sort is true.
Here's the shell sort algorithm:
void shellSort(int array[], int n){
for (int gap = n/2; gap > 0; gap /= 2){
for (int i = gap; i < n; i += 1) {
int temp = array[i];
... |
I have to implement a state machine in some special hardware which has a lot of limitations. This hardware can be understood as a box that gets events as inputs and could output events.
The state machine is very small 3-4 states that are al connected as a ring 0->1->2->3->0 plus some states have loops with themselves.... |
Recently I was working on a LeetCode question
Compute and return the square root of x, where x is guaranteed to be a non-negative integer.
Since the return type is an integer, the decimal digits are truncated and only
the integer part of the result is returned.
Example 1:
Input: 4
Output: 2
Example 2:
Input: 8
Out... |
Given a hash function H, it's possible that H(a) = H(b) = c
Let's assume we have a big data set [N1 ... Nk], with K items and we hash each item in this set
After operation is done, we'd get a set of hashes [H1 ... Hm] where m < k, meaning we had collisions
What would be the most memory-efficient way(without storing all... |
This may seem off-topic question but I am really wondering how CS folks could help in situations like coronavirus. What novel problems arise from such disease? From CS and ML/AI perspectives, is there anything that Computer Scientists could do to better combat the coronavirus?
|
So I'm not really sure even what to be googling for solutions to this. Hence this question, hopefully, someone can point me in the right direction.
Here's the situation, I have a weighted undirected graph of nodes and arcs. I have an implementation that uses A* for pathfinding on this graph. However, I now have a situa... |
The longest palindromic substring problem is certainly an interesting intellectual exercise, and seems to be popular in coding interviews in industry. As an interesting puzzle, its popularity for interviews is not too hard to understand--it's not too hard to find an $O(N^2)$ solution, and if someone manages to come up ... |
Apart from the start-up instructions, what other programs are stored in the ROM?
|
I am reading Computer Networks by Andrew S. Tanenbaum and I wonder if there is a mistake in the protocol as I can't find any solution for the following scenario.
Suppose the transmitter (A) has only one frame (X) to send, and the receiver (B) has nothing to send. B receives X and sends a frame with an empty info field ... |
I came across following problem:
$L=\{M$ is a turing machine $M$ accepts two strings of different length $\}$
$L=\{M$ is a turing machine $M$ accepts atleast two strings of different length $\}$
Which one Recursively Enumerable (RecEn)? Which one Recursive (Rec)?
I feel both are not recursively enumerable and hence... |
I'm trying to run an analysis of a set of nested loops so that I can determine the value of variable sum after the outer loop is finished. The code is as follows:
sum = 0;
for (i = 0; i < n; i++) {
for (j = 0; j < i*i; j++) {
if (j % i == 0) {
for (k = 0; k < j; k++) {
sum++
}
}
}
}
Not... |
Ryser has shown that the permanent of an $n \times n$ matrix $A=(a_{ij})$ can be expressed as
\begin{align}
Perm(A) = (-1)^n \sum_{s \subset [n]} (-1)^{|s|} \prod_{i=1}^n \sum_{j \in s} a_{ij},
\end{align}
where $[n]=\{1,2,\dots,n\}$. This algorithm runs in $\mathcal{O}(2^{n-1}n^2)$ time. I've been trying to derive th... |
I understand the this (or self or Me) is used to refer to the current object, and that it is a feature of object-oriented programming languages. The earliest language I could find which has such a concept was Smalltalk, which uses self but was wondering where and when (which programming language) the concept was first ... |
It is known that some problem P is at least weakly NP-hard. What does at least part of the statement mean? Is it possible that problem P is strongly NP-hard? Is this a stronger, i.e. more precise, claim? Can we prove the problem is strongly NP-hard with polynomial time reduction?
|
The game of Pentomino is a tiling puzzle game played on a grid. A Pentomino piece is a two dimensional shape of five non-diagonally connected tiles. There are exactly 12 unique pieces (ignoring rotation/reflection). The goal of the game is to fill the board with the available pieces without overlapping.
This question ... |
We have given an array of size $N$, consisting of positive integers, and an integer $H$. We also know that an array is stable iff $|A_i - A_{i-1}| \leq H$ for each $1<i<N-1$. We can modify the element by adding +1 to some element or by adding -1 to some element, we don't have a limit on how much we can use those operat... |
I'm attempting to solve the following problem:
Balls are falling from the sky. We know at which location (on a
straight line) will each ball drop, and we know the time (in seconds)
at which will the ball reach the ground. We are trying to catch them
into a ball net, which we can move left or right, but each move... |
I haven't been able to find a full proof of Floyd's cycle detection algorithm. All proofs that I have been able to find just explain why the distance from the start of the graph to the start of the cycle is equal to the distance that hasn't been traveled within the cycle.
But 1) how do we prove that tortoise and hare w... |
My algorithms and data structures' book states that to create a dynamic array the following procedure is followed:
Let $d$ be the length of an array $ a $ and $n $ the number of elements stored in it. Each time an insertion operation is done, if there is enough space $(n+1<d)$, $n $grows by 1; otherwise if $n=d$, we ... |
I wanted for an example such as:
Everyone has a mother.
I've seen that it is represented in FOL as: $\forall x \exists y:$ Mother(x, y)
I'm seeing that as:For every x, there exists a y, such that y is a mother of x.
I want to know why isn't the following suitable:
$\forall x:$ hasMother(x)
Which I feel can be said as: ... |
Note: I have read somewhere that finding all linear extensions of a partial order is in general a #P-complete problem (which apparently means difficult, and thus no closed form expression), but just because the general problem is difficult does not necessarily mean that specific cases can not be easy. This seemed like ... |
I often hear about benefits of FOL, but I wonder what are some of its real world applications?
Could someone please provide samples/case studies of applications of FOL that address real world challenges?
What are typical tools / programming languages used in developing such applications?
Note: If this is not the co... |
In a current exam-prep exercise, we were tasked to prove the following formula using natural deduction of first-order logic:
$(\exists x. P \lor Q) \rightarrow P \lor (\exists x.Q)$ for arbitrary $P,Q$ where $P$ does not have free occurences of variable x.
I managed to do the prove, until I arrived at the following:
$\... |
This is the algorithm I was trying to find the runtime of (doSomething) -
Procedure findMinMax(int A[], int start, int end)
int min = max = A[start]
int i = j = start
for(int k = start; k <= end; k++)
if(A[k] < min)
i = k
min = A[k]
if(A[k] > max)
j = k
max = A[k]
end for
return {i, j}
end findMinMax
Procedure swap(i... |
The task is to find an infinite set of strings $a_1,a_2\ldots$, where $|a_{i+1}|>|a_i|$ and to find a compression algorithm $f$ for these strings, such that $|f(a_i)|=o(\log_2 |a_i|)$ with $i\to\infty$.
I have considered a set of strings with minimal entropy: $a_1=b, a_2=bb$, etc. The optimal compression algorithm for ... |
I'm trying to prove a greedy algorithm works for a specific problem:
You have $n$ jobs and some finite number of machines. (The number of machines doesn't matter; we assume you have enough to run all the jobs.) Each job $j$ has a size $s_j$. Each machine $i$ has a constant associated with its speed, $p_i$. The cost of... |
I am trying to figure out what kinds of graphs are better suited to BFS and which are better suited to DFS. However i'm struggling to visualise what kind of graphs favour which search. Could someone give some simple graph examples and explain which search strategy would be more efficient/faster for the given graph?
|
Can one build a priority queue using stacks, such that the priority queue has the same complexity for each operation.
Could it be done? If so how? If not what is the best solution that can be done?
Each operation of a stack using an array is $O(1)$ whereas almost all operation of priority queue is $O(logn)$.
an impleme... |
In a CS context, I have often come across the expression to back out meaning to say that a function is returned from before performing its actual task, as in this imaginary code comment:
double divide(double dividend, double divisor) {
if (divisor == 0) {
return 0; //divisor is zero => back out early
}
return... |
I am a bit confused with a problem that I am having.I am trying to do an amoritized analysis and I am able to represent the function that I want to use using code. I coded the function as follows:
sum = 1;
for(i = 1;i < n;i++){
sum = ceil(1.5 * sum);
}
The code is suppose to represent $\lceil....\lceil\lceil\lce... |
A log-space Turing machine has a read-only input tape, a write-only output tape and uses at most $O(\log n)$ space in its read-write work tapes. The classes $L$ and $NL$ contain those languages which are decided by deterministic or nondeterministic log-space Turing machines, respectively. The two-way Turing machines ma... |
Reference Question from Forouzon Book Computer Network.
Find the status of the following generator related to two isolated, single-bit errors.
$$x^{15} + x^{14} + 1$$
Answer given :
This polynomial cannot divide any error of type $x^t + 1$ if t is less than 32,768. This means
that a codeword with two isolated errors th... |
I have a language where each type of symbol is only allowed a particular number of times, but the order isn't important. For example, lets say there are three symbols $a, b, c$, and a valid string in the language consists of at most 5 $a$, 3 $b$ and 2 $c$ characters. So $ababbc$ is valid, $ccbbbaaaaa$ is valid, but $ab... |
I am getting more and more familiar with the whole concept of time complexity but I have never encountered an example where more than one parameter is involved. Therefore, is it possible(well, I am sure it is :")) and how to prove
a^n = Θ(logn)
or any other, similar-looking expression?
c1 * logn ≤ a^n ≤ c2 * logn
w... |
For circuits with $n$ input bits, we know that, for any function $s$, there are at most $O(s(n)^{s(n)}) = O(2^{s(n) \log s(n)})$ circuits with size at most $s(n)$.
Say two circuits $C_1$ and $C_2$ are different if the function they compute is different, that is, there is an $n$-bit string $x$ such that $C_1(x) \neq C_2... |
What are the limitations of the Symbolic Model Checking?
As far as I know, "state-space explosion" can still happen by this technique but it can explore much larger state space.
So, is the Symbolic Model Checking always better than the conventional model checking? If not, when to apply which one?
By the conventional m... |
Given directed graph $G = \langle V, E \rangle$, such that some vertices are red, and some vertices are black, and some edges are blue or green, decide for all vertices $v \in V$ if there is path from $v$ to some red vertex with alternating edge colours (no edges of same colour are adjacent in the path, e.g. blue -> gr... |
I don't understand the highlighted text below in CLRS 3rd Ed.:
I'm not sure I even understand what the sentence is trying to say. For example:
What do they mean by "... operations containing $\mathcal{O}(m)$ INSERT operations"? Which operations contain which?
If the (total) expected time is $\Theta(n)$ how can any o... |
I have been assigned the min-coin change problem for homework. I have to calculate the least number of coins needed to make change for a certain amount of cents in 2 scenarios: we have an infinite supply of coins and also where we only have 1 of each coin. I was able to quickly implement the solution for the first scen... |
I believe primary clustering is a problem with the linear probing method of hash collision resolution. But the description makes it sound like there can be multiple clusters of contiguous blocks. I thought there could only possibly be one block, since linear probing will go through all addresses sequentially?
|
int n = 1000;
int cnt = 0;
for (int i = 0; i < n; i++)
cnt++;
Is the above code O(n) or O(1)? If I run the above code many times, it still iterates 1000 times. I'm really confused. I assumed it's O(1), but I'm not sure about it. Could anyone verify this?
|
See below a screenshot from CLRS 3rd Edition (Section 11.5, "Perfect Hashing"). The last sentence of the last paragraph says that the choice of $m_j = n^2_j$ leads to collision-free constant-time lookup.
Why? Is it because:
It assumes that one could, in theory, try or sample several hashing functions $\mathcal{h} \in... |
I's like to guess the running time of recurrence $T(n)=3T(n/8)+n$ using iterative-substitution method. Using master theorem, I can verify the running time is $O(n).$ Using subtitution method however, I arrive at a different answer than expected..
$T(n)=3T(n/8)+n\\
=3T(3T(n/8^2)+n)+n=3^2T(n/8^2)+3n+n\\
=3^2(3T(n/8^3)+n)... |
Jump search is a search algorithm for sorted lists which runs in $O(\sqrt n)$ time, but has the advantage of only making backwards steps at the end (and given the ability to make arbitrarily long backwards steps, guarantees only a single backwards step); thus, it may be preferable to binary search if reverse traversal ... |
Let $A$ be an input alphabet - a finite set of symbols. Elements of $A$ are called the characters.
The alphabet I am interested in is the set of all ordinary letters a, b, c, ..., z.
The texts (also called words or strings) over $A$ are sequences of
elements of $A$. The length (size) of a text is the number of its ele... |
If I have one spanning tree from a connected and undirected graph, how can I generate all other spanning trees of this graph by modifying this spanning tree one edge at a time? All intermediates must also be spanning trees of the graph.
|
I came across this problem: Show that in every infinite computably enumerable set, there exists an infinite decidable set.
As an attempt to solve the problem, I could only think of a proof by construction. Without loss of generality, let the alphabet be $\Sigma=\{0,1\}$. The construction goes as follows, suppose that $... |
I came across following in Huffman coding:
Minimum Hamming distance to correct up to s errors is $2s + 1$ because that way the legal codewords are so far apart that even with $s$ changes the original codeword is still closer than any other codeword.
Then I came across following:
Consider dataword length of $m$ bits... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.