instruction
stringlengths
35
29.1k
In the context of a distributed database, I'm trying to understand why 2PC (as described in e.g. https://www.cs.princeton.edu/courses/archive/fall16/cos418/docs/L6-2pc.pdf) is better than the following hypothetical protocol between a client, master, and slave: client tells master to commit master commits it master tel...
I have been assigned a task to come up with an algorithm for evenly distributing prizes over a given time frame, I am looking for advice as I am a bit stumped on where to start. Here are my requirements: Prize Types: Prize types are types of prizes which can be added by a user, there can be any number of prize types ...
Question I am considering the use of Cuckoo filter for a business case. To simplify the explanation here is an analogy of my needs: There are over $n = 30 000$ first names that exists in the whole world I have a Cuckoo filter storing the names of people who gave me a gift at least once I am certain that the Cuckoo fil...
Find a function that bounds from above and below (asymptotic) the rank of the root r in an AVL tree, i.e. find a function $f(n)$ so there exists a constant $c>0$ that for every AVL tree with $n$ nodes so $c * f(n)\le rank(r)\le n-c*f(n) $. $rank(r)$ gets his maximum value when his sub-left tree contains maximal number ...
After reading an answer at this link: https://serverfault.com/questions/503345/three-duplicate-acknowledgementss I am confused. Do ACK values repeat when a packet is lost or when an out of sequence packet is received? For example in the diagram, the ACK values are same at the 12th and 13th segment. However, there's a d...
I need to tell whether $\quad\exists a \quad T(n) = \omega(n^2)$ $T(n) = T(\frac{n}{2}) + aT(\frac{n}{4}) + n^2\\\\ \forall n<10 \quad T(n) = 1$ And if there is such $a$ I need to find the minimum one. I have tried to use recurrence tree but im unable to generalize $T(n)$ to a finite sum and im quite out of ideas on h...
I am trying to understand the following text which defines a greedy algorithm for center selection problem: It would put the first center at the best possible location for a single center, then keep adding centers so as to reduce the covering radius, each time, by as much as possible. It turns out that this a...
Suppose I'm using the algorithm below to perform Depth-First Search in a 2d Grid. It seems like it should be possible to adjust it to perform a Knight's Tour with little change. For example I would replace for each offset in ["up", "down", "left", "right"] with for each offset in possible Knight moves. EDIT: I woul...
If you were asked to construct a pda that recognizes all strings over the alphabet {a,b,c,d}, that is L={w | w belongs to (a,b,c,d)*} How would that be constructed? My idea is to have one state as the initial and final state and have all transitions loop on the same state without pushing or popping anything from the st...
This is the first question I'm asking here I'm trying to understand whether we can construct a PDA with a maximum of 3 states for every possible CFL or not? if so how?
I am learning about algorithmic complexities and I have this claim which I need to prove or disprove: $f(n)$ and $g(n)$ are asymptotically positive functions, if $f(n)=\Theta(g(\log(n))$ then $f(n)=\Theta(\log(g(n)))$. Is it true?
I have a set that is too large to hold in memory but I have a function that I can use to compute a value within the set given an index. I'm curious if there's a standard way to shuffle this set, a pseudo-shuffle is acceptable and expected. I imagine a function that is initialized with some parameters, including the si...
Typing out negative weight cycle again and again is kind of annoying, so for the rest of the question I'm going to abbreviate it to NWC. I'm writing an optimized version of Bellman-Ford's Shortest Path Algorithm on a directed, weighted graph. When I give it a regular graph with no NWC's, it works fine, and finds the an...
In many papers like Empirical Evaluation of the Tarantula Automatic Fault-Localization Technique there is a good explanation about how tarantula algorithm can be used with test suits. Is there any book or even explanation of how this could be usefull in case of model checking? with abstract reachability graph?
I know both have runtime complexity $\mathcal{O} (V+E)$, but Tarjan's algorithm does a single DFS pass, whereas Kosaraju's does two DFS passes. Both need extra space (e.g. a dynamic set, often a stack, for the former to keep track of low links, and e.g. a linked list for the latter to do the second traversal in decreas...
I continue to learn the complexity myself, currently I am interested in the complexity of space. I have read several books and tried some exercises as a practice. I would like to have your idea on the following problem. Show that the problem of the existence of a cycle in a directed graph is a $NL-complete$ problem. To...
int function(int n) { int i; if (n <= 0) { return 0; } else { i = random(n - 1); return function(i) + function(n - 1 - i); } } Consider the recursive algorithm above, where the random(int n) spends one unit of time to return a random integer which is evenly distributed within the rang...
For any general graph G(V,E) , the maximum matching can be calculated in O(√V.|E|) time using the following algorithm : https://www.researchgate.net/publication/221499631_An_Osqrtv_E_Algorithm_for_Finding_Maximum_Matching_in_General_Graphs The following problem has 5-parts : - 1)Calculate maximum matching of Graph G Ca...
I read recently that for an unambiguous grammar the left hand derivation need not necessarily be equal to the right hand derivation. Can someone give an example of this?
I finished watching a video about pipelining https://www.youtube.com/watch?v=eVRdfl4zxfI which I thought made sense. Latency is the amount of time it takes to complete each instruction. Even with pipelining, the time it takes to complete an instruction is still the sum of the time it takes for every stage, in this case...
Given a relational schema $R(V,W,X,Y,Z)$ with functional dependencies $F = \{VW \to X, X \to YZ, W \to VX, V \to W, Z \to XY\}$. What are the keys of $R$? Is the key just $V$? If so, is $\{ R_2(V,W,Z), R_3(V,X,Y) \}$ the lossless-join decomposition of $R$?
Actually i am preparing for an exam and in the last year exam this que. was been asked. i.e The maximum decimal integer number that can be stored in memory of 8-bit word processor computer ? a) (128)10 b) (127)10 c) (129)10 d) (255)10 Answer of this que. as given in the answer key is b) 127. And I have no idea how t...
Is it possible to implement an efficient priority queue (as efficient as a heap) only using the stack data structure? The usual efficiency for a priority queue which is implemented using a heap is : get min - $O(1)$ extract min - $O(\log n)$ add - $O(\log n)$ Would it be possible to do something with the same complex...
I tried to study the maximum matching for a line-graph , i.e , $L(G)$ of a graph , $G(V,E)$ , from here : https://www.sciencedirect.com/science/article/pii/S0012365X97001039 But could not understand it , can anybody explain it in detail . I understood how to create the corresponding tree , but after that I could not...
Show that the problem of the existence of a cycle in a directed graph is a $NL-complete$ problem. I have already successfully demonstrated that this problem $\in NL$. But I'm stuck on how to take it apart that it's $NL-hard$. To show that the problem is $NL-hard$, we can start from problem $s; t-connectivity$ ($s$ = s...
I have some question related to the Linear Programming problem: If we have an objective function that needs to be maximized and let the feasible region be unbounded such that there is no finite optimum solution. My question is what is the meaning of "finite" here? If we need to solve LP using the simplex method, we ne...
What is the time complexity of the Edmonds-Karp algorithm (not the Hopcroft-Karp algorithm) for finding a maximum cardinality matching in bipartite graphs? Is it still $O(|V||E|^2)$, or it has a better time complexity in this special case?
Can anyone give an example of a NDTM for a problem (which cannot be solved with DTM) with transition function?
Consider the unit hypercube in $\mathbb{R}^n$ with all non-negative coordinates, and one point anchored at $0^n$. I've been working on a problem where I want to generate the (exponentially many) corners of this cube (as a list of 0's and 1's) but I want to generate them in "distance" order. That is starting from a cor...
Is $O(\log(n^n)) < O(\log(n!))$? Is there any good/practical algorithm with this kind of complexity? And also, to check my understanding of algorithmic complexity, are these two $> O(n\log(n))$? I'm just starting with this topic and not really sure if I'm getting it right. Thanks and stay safe.
Given two problems $P_1$ and $P_2$. $P_1$ is NP-complete in the strong sense and we want to prove that $P_2$ is also NP-complete but the reduction from $P_1$ to $P_2$ is not polynomial. Can we say that $P_2$ is NP-complete?
I am looking for an algorithm/code that will provide stable matching for two unequally sized sets of elements (clubs and students) with an unequal set of preferences. There is a large pool of students looking to join a club, and a comparatively small pool of clubs for those students to join. Each student ranks only the...
I've researched quite a bit about this topic. Since I'm kind of a fan of Exact Sciences, I love everything to have a crystal-clear and determined definition, without any ambiguous or dubious points. Dynamic Array, according to the Wikipedia's article, is a Data Structure. Article states, that: Dynamic array (also call...
The functions definable in untyped lambda calculus are the computable functions, for which it is in turn possible to define equivalences to the concepts of Turing machines, recursive enumerability and Type-0 grammars. But what about typed lambda calculus -- where on the Chomskian computability hierarchy are the functio...
I work on a project: an online dictionary where the user can find definitions of a word he's looking for. My supervisor asked us to add synonyms using machine learning. He recommend us to use Bayes algorithm. but I don't see how to do this, how to put every word in a category and make probabilities. Please how can I us...
There's lots of ways to prove a language is not context free. Going through some exercises, I'm stuck at a question that asks me to prove that a language is indeed context free. $L = \{a^{(n+1)} b^{(m+2)}c^{(n+4)}\ |\ m, n ≥ 0 \}$ I see that the langauge is equivalent to $L = \{aa^nbbb^mccccc^n\}$, but I'm not sure if ...
I am trying to "reinvent" Kleene's predecessor myself. The following code snippet should be self-explanatory. The idea is to make a 2-tuple and count up from zero, i.e. lambda f: lambda x: x, as described in this article: #!/usr/bin/env python3 NULL = lambda x: x ZERO = lambda f: lambda x: x TRUE = lambda T: lambda F...
I am stuck on solving this problem and cannot understand how is the ceiling function omitted or solved. Please help. The equation: $\sum_{h=0}^{\lfloor\lg n\rfloor} \lceil\frac{n}{2^{h+1}}\rceil O(h) $. But this transformed to: $O\left(n \sum_{h=0}^{\lfloor\lg n\rfloor} \frac{h}{2^h}\right)$ My question concerns on om...
Consider following problem: Given an undirected tree answer following type of queries. (No. of queries and vertices can be as high as $10^5$) $\text{LCA}(r, u, v)$: Find the Lowest Common Ancestor of vertices $u$ and $v$ assuming vertex $r$ as the root. Now, in solution it's given that answer will always be one th...
For an arbitrary bitstring $(x_1, x_2,\ldots, x_n)$ and an $n\times n$ invertible binary matrix $M$ (fixed ahead of time), I would like to construct a circuit $C$ acting on these $n$ bits whose output will be such a bitstring $(y_1, y_2,\ldots, y_n)$ that: $$ \begin{pmatrix} y_1 \\ y_2 \\ y_3 \\ \ldots \\ y_n \end{pmat...
Is there a way to solve this recurrence using master theorem: $$T(n) = 4T(n/2) + Θ(n^2/\log n)$$
I am trying to understand the concept of NRU from the following link. I have got some problem in understanding the text below: NRU page replacement Algorithm If the hardware does not have these bits, they can be simulated as follows. When a process is started up, all of its page table entries are marked as not in ...
I am currently working my way through Michael Nielsen's ebook Neural Networks and Deep Learning and I am reading about overfitting and (L2) regularization. In this subsection, the process of L2 (a.k.a weight decay) regularization is introduced as being the process of adding the term $$ \frac{\lambda}{2n} \sum w^2 $$ to...
In book Concurrent Programming: Algorithms, Principles, and Foundations of Michel Raynal, in Section 16.5.1, Theorem 75 says Compare&swap objects have infinite consensus number. and in Section 16.5.2, Lemma 40 says The mem-to-mem-swap object type has consensus number n in a system of n processes. Then, in Section ...
I'm having trouble proving if the following language is recursive, recursively enumerable, or not r.e. at all: the set of all encodings of Turing machines $M$ such that the number of positions in the tape used by $M$ when the input is 0011 is less than 10. I'm suspicious the problem is unrecognizable but I can't come ...
I've started reading more about statistical learning theory, specifically this paper right here and I cannot understand the following part: It turns out the conditions required to render empirical risk minimization consistent involve restricting the set of admissible functions. The main insight of VC (Vapnik-Cherv...
So suppose I have a graph consisting of a tuple $(V,E,A,g)$ where $V$ denotes vertices, $E$ denotes edges, $A$ denotes a subset of $V$ (i.e. $A \subseteq V$), and $g:A\rightarrow\mathbb{N}$ is a function. We can call this graph instance $\textit{consistent}$ if we can find a subset $B \subseteq V$ \ $A$ such that for ...
I am master degree student at Computer Science Department. I started master degree at this year. Now I'm reading two papers about computer vision. Actually before time I didn't have experience about computer vision. so I am not familiar with the concepts used in this field. OK. I want start question. I am reading these...
How functions like rnorm in R (and similar functions) create a random sample ? If I want to implement one algorithm to simulate this procedure what can I do? When you have the pdf or pmf of a distribution how can you use this to create a random sample with a computer? Is there some book on this topic?Is this a numerica...
Let $G(m,n)$ be A bipartite graph $G$ with paritions $m$ and $n$ with the property that partition $\mathit n$ has two types of nodes (type1 or type2). Given $G(m,n)$ and $k \in \mathbb Z+$: Does $\mathit S\subset \mathit m$ where |$\mathit S$| $=$ $\mathit k$ exist so that none of $\mathit S$'s nodes are adjacent to n...
Binary Decision Diagrams (BDD) take a set of binary variables $x_1, x_2,..., x_n$ as input. Is there a data structure similar to BDDs where each variable takes more than two values? Each variable's values should be independent of every other variable. For example, $x_i$ could be assigned the three values $\{0,1,2\}$ an...
The syntax STLC is usually written: $e ::= x |\lambda x : \tau . e|(e \space e)|c$ However, the application rule appears to accept all expressions on the left hand side. Shouldn't the application rule be written: $(\lambda x : \tau . e \space e : \tau)$ ? The only time an application makes sense both intuitively and ty...
Consider the following general form of a layered architecture : I need to check my understanding about the second layer from top . More specifically I need to check my understanding the regarding the meaning of "User interface management " . According to my understanding , UI management is the code that underlies the...
Being new to complexity problems, I've met a question that is quite similar to the Vertex Cover Problem and I am not sure if this one is NP-Hard. We know that the vertex cover problem is the following: given a graph $(V, E)$, selecting a set of vertices $S$ such that every edge $e \in E$ in the graph is connected to so...
Trying to understand complexity well, I found myself with the following problem. Consider the following algorithm to detect if an undirected graph $G = (V, E)$ has a cycle. Imagine that $V = \{1 ...|V|\}$ (in other words that the vertices are numbered from $1$ to $|V|$ ). An explorer plants a flag on point $1$ and the...
Say we have a set $S$ of $n$ irrational numbers $\left\{a_1, ..., a_n\right\}$. Are there any known algorithms that can determine a scaling factor $s \in \mathcal{R}$ such that $s * a_i \in \mathcal{N} \;\forall a_i \in S$, assuming that such factor exists? If multiple exist, how about the smallest one? Moreover, I wo...
I have this problem for which I am struggling to find an efficient dynamic programming algorithm. Would be thankful for some help!! Let $A = \{ a_1, a_2, ..., a_n \}$ be a set where $a_i \in \mathbb{N}$ for $i=1,...,n$. The goal is to determine whether there exist two disjoint subsets $M,N \subset A$ such that the sum...
How can we decrypt an RSA message if we only have the public key? For example, Message: 21556870,12228498 Public Key: (e = 15852553, n = 44331583) I know that these formulas exist: gcd(e, φ(n)) = 1 ed mod φ(n) = 1 so my idea was that i could put the value of e in the first formula, then derive d that is a part of the...
I am trying to implement set theory in type theory from scratch, just for self pedagogical purposes. Specifically, I'm using the Lean Prover, and defining the element-of relation from scratch using the symbol $\epsilon$, just for pedagogical purposes. What I'm trying to do However, I'm unsure how to even define the not...
Consider a valid string with bitwise operations (AND, OR, XOR), and also placeholders $X$, where each $X$ stands for an arbitrary number from $\{0,1\}$. There are $n$ many $X$s, so there are $2^n$ possible sequences. How many out of the $2^n$ strings have value $0$? How many have value $1$? My approach to this pro...
In the picture below from CLRS, I fail to understand why exactly $h(k)$ = the $p$ highest-order bits of the lower w-bit half of the product. For context, this is supposed to compute $h(k) = \lfloor m (k A \; \text{mod} 1) \rfloor $ For further context, CLRS mentions the following, but I still don't quite get why th...
Define language $L’$ for given regular language $L$ as: $$L’=\{uv | u,v\in\Sigma^{*}, vu\in L\}$$ is language $L’$ also regular? Hello, I need some help with solving this question. I need somehow to determine where to divide each word. Or actually - in what state of its automata will that language be. If that makes ...
I have to proof that $L = \{ a^{2i} b^{2j} \mid i,j \in \mathbb{N} \}$ is a regular language, and how it meets the Pumping Lemma condition. For the PL, there is a string $xyz \in L$ such that $y \neq \epsilon$ and any string $xy^nz$, for any $n \ge 0$, is in $L$. From what I understand, I cannot use the pumping lemma t...
Okay, so I have been doing competitive programming for the past few days in C++. And day before yesterday, I stumbled upon this concept of linked list. Now, what I do while implementing most problems pertaining to linked list is that I store all the values of the linked list nodes in a vector, and do operations on the...
I know that it is decidable for an NPDA to accept a string $w$, i.e. a TM can receive as input the description of an NPDA along with a string and test if the NPDA accepts the string. But are there languages where given an NPDA description as input, the TM may not halt, i.e. since the simulated NPDA also does not halt.....
I'm emulating 128-bit arithmetic. At the moment I'm calculating $x^2$ by computing $x\cdot x$. What might be some alternative methods that aren't simply dressing up multiplication?
I'm aware of how $FIRST$ and $FOLLOW$ sets are used to construct a parsing table for $LL(1)$ grammars. However, I've encountered this statement from my notes: With $\epsilon$ productions in the grammar, we may have to look beyond the current non-terminal to what can come after it In my opinion, this suggests that $...
For my project I can have 0-500 moving squares. The largest possible square width is at most 3 times longer than the smallest possible square width. The squares can move up to 3 of their own body's width per second. About 1 square is added and about 1 square is deleted every second. What I'm trying to implement now is ...
Introduction I'm not really understanding my algorithms class. One of our HW assignments is to design an efficient algorithm for this graph Questions Give an efficient algorithm to find the fastest route for Alice to leave home, reach some gas station, then get to work. On her way home, Alice wants to visit both a g...
I'm trying to come up with an alternate DFA for accepting (a|b)*abb than the one present in the dragon book. Here's the one I tried: It seems valid to me but I'm not sure. Also, is there a way to check for validity of automatons so that I don't end up bugging you guys next time?
Due to the unforeseen pandemic, I am unable to speak to my tutor about the following question. I have emailed him, but I have not had an answer for weeks. Can someone please enlighten me. Image and question to be answered below. Please provide an explanation, as I am struggling to find an answer:
So the Gale-Shapley algorithm is just one way to output one stable matching instance. Is there any algorithm that can allow us to output all stable matching solutions ? Thanks
In implicit complexity theory they construct natural programming languages that are complete for various complexity classes. An example, while there are many others, is Bellantoni-Cook where they show that FP can be characterized by such a language (called system B). What I'm wondering is what do successes such as Bell...
I have the following problem. I need to determine whether this language is regular or not: $L:= \{ w \in \Sigma^*: \forall \alpha ∈ \Sigma, |w|_\alpha \text{ is even or divisible by 3}\}$ $|w|_\alpha$ => $|w|$ is the length of the word $w$ and $|w|_\alpha$ is the number of $\alpha$ characters in that word. For example:...
Why exactly does quadratic probing lead to a shorter avg. search time than linear probing? I fully get that linear probing leads to a higher concentration of used slots in the hash table (i.e. higher "clustering" of used consecutive indices). However, it's not immediately trivial (to me at least) why that translates ...
My understanding is that one way to build a perfect hash, as per CLRS, is to use two levels of hashing, with universal hashing functions at each level. More specifically, CLRS shows that assuming $n$ is the total number of keys, and $n_j$ the number of keys hashed to the value $j$ for the second level, we can then ma...
How do I construct a context-free grammar for the following language? $$L = \{w\#x \mid w, x \in \{0, 1\}^*, |w| = |x|, w \neq x^R \} $$
I was reading through the classic CLRS with the intention of reviewing the hash tables theory, more specifically the hash function definition I just wanted a reference to quote. I cannot find a formal definition given but I think it's fair to say a hash function (not univerisal) $h$ is a surjective map from a set of ke...
I am working on a type system supporting overloading. I have a rough idea of how type inference is usually implemented in such a scenario, but I am wondering how - after type inference is completed - the correct implementation of an overloaded operator can be chosen. Or, in other words, how the inferred type can be pas...
I'm studying for an Algorithms and Data Structure test. There is a type of question that is usually always asked by my professor but I don't know how to answer/solve it. Question 1: An Algorithm with an worst-case execution time of 3n*(log n), being n the number of elements in the input, is: a) An algorithm with an ex...
TRUE or FALSE: Let $L_1, L_2$ be any two regular languages over the same alphabet $\Sigma$, then the language $L=\{w\in\Sigma^* \mid w\in L_1 \text{ or } w\notin L_2\}$ is regular. So we have to determine whether $L_1 \cup \overline{L_2}$ is regular or not. Proof: First attempt: First we have to prove that a compleme...
I was solving some old MCQs and found this question: A RAM chip has 7 address lines, 8 data lines and 2 chip select lines. Then the number of memory locations is _____. (A) $2^{12}$ (B) $2^{10}$ (C) $2^{19}$ (D) $2^{13}$ Assuming a word consisting of a byte, this should have 2 chip select lines, meaning total $2^2$ c...
I am taking a course on programming language design and we got to the DFA part. It is known to be formally defined by a 5-tupple but they did not make it very clear to us why a DFA can have multiple final states. I know that the languages ​​that it can accept are involved, but nothing else.
I'm not sure how to go about solving this. I tried this: Suppose L is a Turing decidable language. Turing Machine M1 is a decider of L and M2 is a decider of the complement L We construct a TM U that simulates M1 and M2 on a word w. For any word w in complement L (this is infinite as it is the set of all possible words...
No more information required. I would just like to know how to use the information provided.
I find this extremely wrong, that a lot of books, articles, video tutorials, online courses or trainers define Minimum/Maximum Heap data structure as a particular type of the Binary Heap data structure.. however! according to the definition of what is Heap Data Structure, that's wrong! Heap can be perfectly fine either...
I have a set of $n$ objects $\{1,2,\ldots,n\}$ where object $i$ has weight $w(i)$ and we have a capacity $W$. I would like to pick a subset $S=\{a_1,\ldots,a_m\}\subseteq \{1,2,\ldots,n\}$ of the objects in order to minimize $$\sum_{j=0}^m(a_{j+1}-a_{j}-1),$$ (assuming that $a_0=0$ and $a_{m+1}=n+1$) while respecting t...
If so, where can I find a proof of it? If not, is there a counterexample? By powerset of a regular language I mean the set of all subsets of a regular language. Thank you, Marcus.
Consider the following processes : 1) My First Question is if we need to schedule them using preemptive priority scheduling with Round-Robin for equal processes priorities with a quantum of 3. Here is my answer to this problem : Sorry about that bad drawing. My problem here is at time 13. At this time we have two p...
I'm implementing a Fibonacci Heap, where the lists are stored as a circular doubly-linked lists. What I'm trying to do is given a pointer to a random node in one linked list, and a random node in another, I want to merge them together in O(1) time. I tried drawing this out, but I couldn't seem to figure out how to do t...
I would like to ask for intuition to understand the difference between a CFG generating $\Sigma^*$ and a regular grammar generating $\Sigma^*$.. I got the examples here from Sipser. Let $ALL_{CFG}$ refer to the language that a given CFG generates $\Sigma^*$, and let $ALL_{REX}$ refer to the language that a given regula...
I read in CLRS that the number of possible parenthesizations for a product of $n$ matrices is given by the recursive formula: $$ P(n)= \begin{cases} 1 & \text{if } n = 1,\\ \sum^{n-1}_{k=1} P(k)P(n-k) & \text{if } n \ge2. \end{cases} $$ This comes from the following two facts: For $n=1$ there...
I have a grammar like this: A → BAB | B | ε B → 00σ | ε What is the meaning of σ in the second rule?
Suppose we defined a set $S = \{x\mid0 \leq x \leq 2^n-1\}$. Notice that all element in $S$ can be represented with a $n$-bit binary string. Now consider subset $S_i$ such that, $$S_{y_i} = \{y \in S\mid d(y,y_i) \leq t\},$$ where $y_i$ is the $i$th element of $S$ and $d(y_j,y_i)$ is the hamming distance between the bi...
Suppose my algorithm runs in time $O(nL^2)$, where $n$ is the size of the input, and $L$ some other parameter, which can get arbitrarily large w.r.t. $n$. My algorithm does not run in polynomial time, since $L$ can get arbitrarily large w.r.t. $n$. So I'd like to categorize it elsewise. Fixed Parameter Tractable algori...
I have a set of points A in my space (geo points but I can assume they are on a 2D plane). I have another set of points B. For every point in B I want to find every point in A inside a radius R with center in the considered point from B set. I did it with KDTree, this provide me a very fast and easy algorithm to create...
I need to reduce Vertex Cover to Half Vertex Cover using a Karp reduction: Vertex Cover: Given a graph $G = (V,E)$ and an integer $k$, is there a subset of $V$ of size $k$ which intersects all edges? Half Vertex Cover: Given a graph $G = (V,E)$ and an integer $k$, is there a subset of $V$ of size $k$ which intersects e...
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn't come up with a solution, nor find one anywhere on the web. Given an array of integers, find two disjoint, contiguous subarrays such that the absolute dif...
I often read that Floyd-Warshall is a good fit for dense graphs and Johnson's for sparse ones. While it's easy to see why Johnson outperforms Floyd-Warshall on sparse graphs, I'm noticing that Johnson's with Fibonacci Heaps does no worse than Floyd-Warshall in terms of asymptotic runtime. More specifically, from what ...
I'm reading "Computer Architecture A Quantitative Approach" (5th edition) and I'm having a hard time understing this table: I understand how Misalignment happens, i.e., some byte, half-word, word, or double word it's not a multiple of the address where the element is being stored or accessed. The part that I don't und...