instruction
stringlengths
35
29.1k
Let $S$ be a subset of $[0,1]^l$. Is there some data structure that can represent $S$ and can perform the following operations/queries efficiently*? $ADD(s \in [0,1]^l)$ - operation which updates $S$ to become $S\cup \{s\}$ $REMOVE(s \in [0,1]^l)$ - operation which updates $S$ to become $S \setminus \{s\}$ $PERMUTE(\s...
In Types and Programming Languages by Pierce et al: The recursive equation specifying the type of lists of numbers is similar to the equation specifying the recursive factorial function on page 52: factorial = λn. if n=0 then 1 else n * factorial(n-1) Here, as there, it is convenient to make this equation into a prop...
Why do we use the CYK algorithm? In my book is written that with CYK algorithm you can faster see if a word is generated by a given Grammer. However I dont get it, because I need like 5 min in order to divide the word into other subwords.. and so on and only few seconds just to derive the word using the predicates.
I have a spatial graph-like structure. The structure consists of vertices in the 3D space and connecting edges. Are there any algorithms available that would identify the rotational symmetries of these structures? In particular, I'm interested in all the rotational axis along which I can rotate the structure to overlap...
I am trying to see if a recurrence relation where $f(n)$ has some constant factor $k$, e.g. $f(n)=kn$ where $0 < k < 1$, is $O(n)$. I am reaching a different result depending which route I take. Given the following recurrence relation: $$T(n)=2T(\frac{n}{2})+f(n)$$ $$T(n)=2T(\frac{n}{2})+kn$$ Since $0 < k < 1$, we can ...
I'm trying to find a substring in an infinite sequence of numbers (Similar to Substring in a infinite sequence of numbers) and am a little stuck on improving my algorithm. I know there is already an answer given in the question I linked above, but I want to try and improve my brute force algorithm. Given a sequence $S...
A language L is called hereditary if it has the following property: For every nonempty string x in L, there is a character in x which can be deleted from x to give another string in L. Prove by contradiction that every nonempty hereditary language contains the empty string. Here's my attempt: To prove by contradiction,...
this is a piece of Assembly code section .text global _start ;must be declared for using gcc _start: ;tell linker entry point mov edx, len ;message length mov ecx, msg ;message to write mov ebx, 1 ;file descriptor (stdout) mov eax, 4 ;system call number (sys...
Let $L$ be a language defined over $\Sigma = \left \{ a, b \right \}$ such that $L = \left \{ x\#y \mid x,y \in \Sigma^*, \# \text { is a constant and } x \neq y \right \}$ State whether the language L is a CFL or not? Give valid reasons for the same. Now, I think that the given language is not a CFL. I have used the ...
I want to input some words, and out comes the next word(s). Neural nets are really hot at the moment, and I'm afraid of throwing a neural net at something, when one is not really needed. Or... maybe it is needed? My current options are: Predict next word(s) using N-grams Predict next word(s) using a neural net There ...
I'm doing a course on randomized algorithms and I've encountered a question that I'm struggling to solve. Given a system of $m$ linear equations with $n$ variables over finite field $\mathbb{F_2}$ where every equation is of form $a_1x_1+...+a_nx_n=b \mod 2$ and $x_i,a_i,b\in\{0,1\}$ and multiplication and sum are $\m...
I'm trying to design a data structure that supports the following operations in $O(1)$ time: $\operatorname{query}(\ell)$: Yield some auxiliary datum associated with list $\ell$ (just a single integer for my use case). $\operatorname{update}(\ell,v)$: Set the auxiliary datum of list $\ell$ to $v$. $\operatorname{list}...
The usual demonstration of the halting problem's undecidability involves positing an adversarial machine (call it $A_0$) that runs the decider machine (call it $D_0$) on itself and performs the opposite of the answer it gets. But it would be possible to construct a machine $D_1$, that checked for the exact source code ...
I am wondering if a Bayesian Optimization framework (e.g. Google's Vizier) can be used in lieu of a traditional solver like Gurobi or CPLEX. In trying to answer this question, I realized that I don't know enough about optimization theory to answer a more general question: Just how interchangeable are heuristic approac...
I was following a discussion on a website, where a fellow scholar claims that this grammar S→ aAa | bAb | ϵ A→aA | bA |ϵ is not CSG, so it should also NOT be a CFG. But this grammar properly satisfies the rules of CFG according me, on the other hand it fails to satisfy the conditions of CSG, which states that-- In a...
I was reading about clustering coefficient distribution, and it seems that it is independent of node degree for the case of random networks, or even scale-free networks. I'm wondering why this is the case conceptually. I do understand that the degree distribution in the case of a random network shows a Poisson behavior...
In the first chapter of "Parameterized Complexity Theory" by Flum and Grohe, an example is presented to find a hitting set of minimal cardinality. In Fig. 1.3, the author says a black colored leaf is the minimal with respect to set inclusion and a hitting set consists of the vertices labeling the edges on the path fro...
I want to make sure that the code that the written code is precisely doing what it is expected to do. For example, if I want to search in an array particularly using linear search, I don't want binary search to pass the test. Unit test to test the method "search" would pass irrespective of the implementation which is ...
I have created an extremely simple byacc grammar (ok, it's not really that simple but I simplified purposefully to be a minimal complete verifiable example): %token NEWLINE SPECIFIER %token EQUALS STRING VAR %start st %% st: toplevel; toplevel: | toplevel VAR EQUALS STRING NEWLINE | toplevel list NEWLINE ; list: ...
I had generated a random password from a website which unfortunately has put me into trouble. The password contains 26 characters which includes alphabets, numbers and special characters. My trouble started when it was found that among the 26 characters there was a 4 letter Malayalam word (spelled in English) which is ...
i was reading Binary Search in the wikipedia and i came across this part of 'rightmost index of an element in an array of duplicate elements'. i understood the process of determining the leftmost index, but for rightmost index, i am unable to get it. Here is the link : Binary search Algorithm: function binary_search_ri...
"er" is the Danish equivalent of "is" in English. I need some help with the square root one. Additionally, it would be nice to know if the other ones are correct.
F(n) = n-100 G(n) = n-200 I am trying to show the asymptotic relationship between these two functions using limits. I take the limit n->∞ f(n) / g(n) and I get the result 1 which is constant c. From the Big O theorem, From the Big Omege theorem, My question is: How I supposed to determine whether they are f = O(g(n...
BPP is defined as the class of polynomial-time random algorithms which have an error probability of at most 1/3. But why was 1/3 chosen? If we have an algorithm with some error probability less than 1/2, then we can run it several times, taking the most common result, to obtain an error probability of less than 1/3 whi...
Assume that we have n sealed boxes. There are k boxes with a ball inside. The goal is to approximate k by an additive error epsilon, using the minimum number of box probing. I know that this is possible using O(n/k. 1/epsilon^2) box probing but I don't know the algorithm and its analysis.
The problem in front of me is to write a function (from scratch) to permute n elements, where n is an argument. I decided to break it down to applying Knuth's shuffles algorithm, therefore I needed to write a pseudorandom number generator. So now my task is to write a simple function F(seed,n) that will help me gener...
Dask is a flexible library for parallel computing in Python. This piece of code define some simple functions. def inc(x): return x + 1 def double(x): return x + 2 def add(x, y): return x + y data = [1, 2, 3, 4, 5] output = [] for x in data: a = inc(x) b = double(x) c = add(a, b) output.a...
In Types and Programming Languages by Pierce, when talking about untyped arithmetic expressions in Chapter 3, there are two theorems: $-→$ is single-step evaluation relation: 3.5.4 Theorem [Determinacy of one-step evaluation]: If $t -→ t'$ and $t -→ t''$ , then $t' = t''$ . $-→ ∗$ is multi-step evaluation relation: ...
I am not very sure about the difference between syntax and semantics. Does each of the following concepts belong to syntax or semantics? terms values: terms that are possible final results of evaluation. types (typing) context evaluation (rules) typing (relation)? Here are two examples from Types and Programming La...
From Types and Programming Languages by Pierce A term $t$ is in normal form if no evaluation rule applies to it— i.e., if there is no $t'$ such that $t -→ t'$. and A term $t$ is typable (or well typed) if there is some $T$ such that $t : T$. In the pure simple typed lambda calculus: we consider another fundamen...
If $L^2$ is regular. Does that imply L is regular. I think L need not be regular. But I can't find any example where L is not regular but $L^2$ is regular. My teacher told me an example where L={$0^k$ | k is composite} clearly L is not regular. But he claims that $L^2$ is regular. I don't know why it is regular? Pleas...
struct and class in C++ are nearly identical (as covered for example here). But why is this so? What did happen when C++ was developed and eventually standardized, that struct was allowed to define a full OOP class, yet class keyword was also added? There must be a historical reason for this, but I did not find an answ...
I am working with a time series which is, in fact a pressure signal. There are special "events" in the signal that I am looking for.for example where the signal suddenly goes up or down or where there is an abrupt peak in the signal.I have shown some of them with red arrows in the picture. I am familiar (but not an exp...
I know Solr and the likes are able to provide faceted search out-of-the-box. But how is faceted search actually implemented technically? How are those engines able to efficiently search for items based on a dynamic list of attributes given by a query and to provide pagination at the same time? Definition : https://en.w...
A standard exercise in formal language theory uses Lagrange's four-square theorem to construct a language $L$ such that $L$ isn't regular but $L^2$ is regular. (Let $A = \{ a^{n^2} : n \geq 0 \}$. Then $A$ isn't regular, but $A^4 = \{ a^n : n \geq 0 \}$ is regular, hence either $L = A$ or $L = A^2$ fits the bill; in fa...
I am reading the naive conversion to CNF, this procedure is explaining in this book book, but I have not found a conplexity analysis of this algorithm: elimination of equivalence Elimination of Implications elimination of double negation De Morgan Laws distributive law I found one implementation of this method in thi...
Suppose that we have two algorithms for the same task (e.g. search): AlgC: has bounded worst-case complexity, e.g. O(n.logn) AlgH: is a heuristic algorithm that is experimentally faster than AlgC, but there is no tight complexity bound for AlgH. If we want to have an algorithm that is FAST but also has a guaranteed ...
I'm trying to get the regular expression of an automata but an state has a form that I don't know how to solve, the form on its simplest example is: $$q_{2} = 1q_{2} \cup 0q_{2}$$ What's the procedure to solve this form? Thanks in advance
Background: Recently, I obtained the following equivalent problem to SAT. We are given as input a CNF formula with $n$ variables and $m$ clauses. Suppose we have an $n$-dimensional hyper-cube centered at the origin. We perform the following cut-and-color operation $m$ times, each time for a clause. Let’s say there are ...
I am studying about the arrays vs heap for make a priority queue For check the heap implementation I am reviewing this code: Heap , but I have the following question. Heap is based on array, and for creating an array you need O(n), for inserting into a heap you need O(logN), so if you have a unordered list of task and...
Given $0 \leq m < k$ and $p \geq 2$ it's defined $$A_{k,m,p} = \{ \alpha \in \{0,1,\dots,p-1\}^* | \alpha \text{ is a p-ary representation of } x \backepsilon x \text{ mod } k = m \}$$ It is needed to give a general method to construct an automaton which accepts this language. I'm trutly lost about the procedure in th...
Title says it all, but to clarify: Define a problem, called $IsInNP$, as follows: Given a Turing Machine $M$ that always halts, $IsInNP$ is the problem of deciding if the problem that $M$ recognizes is in $NP$. What is the complexity class of $IsInNP$? Is it even decidable? Is the answer the same for any other comple...
Somewhere on stackexchage, I, or someone else asked what was the proper term for Turing completeness minus the infinite memory (e.g. a Turing machine that one can actually build, no bigger than your typical data center). Answer was inconclusive. Also, someone else asked somewhere else on stackexchange about the number...
The Sipser book says, Complement of HAMPATH is not in NP. I tried to find the solution for this, actually, a rigid proof like HAMPATH, which can state Complement of HAMPATH is in/not in NP, but I could not come up with any. This is what I think, We are given a path from s to t(which can be a certificate for the problem...
I was looking at the Fisher–Yates shuffle algorithm and followed the Python implementation for it. Python starts from the end of the array to the start. Looking at the algorithm I didn't see any benefits in doing so compared to starting with the start and going to the end. I was wondering, considering that looping back...
I know that in order to convert a numeral in base-8 to a numeral in base-2 I can write each octal digit as a binary word of 3 bits. I know that 2^3 = 8 that is exactly the dimension of the base of the octal system. I just cannot understand the fundamental reason why it works. Is it just a coincidence?
Say I have: page size = 2^12 bytes physical memory = 2^24 bytes logical address space = 2^32 How many page-table entries are needed in case the program uses the whole logical address space?
I have problems with the understanding why a subset of a undecidable language is decidable. We've proved in the lecture that $HALT$$_T$$_M$$=${$<M,w>$|M is a TM and M halts on input w} is undecidable. Can someone give an example of a subset from $HALT$$_T$$_M$ and explain why it is decidable? Is $\Sigma^*$ a valid subs...
If I have n lines in a programming language like Python (globally or inside a function): .. .. # from here .. .. .. .. # to here .. .. or def example(): ... ... # from here ... ... ... ... # to here ... ... can I always transform it to a function of the form s1, s2, s3 … = func...
From Types and Programming Languages by Pierce 23 Polymorphism 23.7 Erasure and Evaluation Order in a full-blown programming language, which may include side- effecting features such as mutable reference cells or exceptions, the type- erasure function needs to be defined a little more delicately than the full era-...
I was having a look at the block product principle for finite monoids. I wanted to see the derivation of LTT = Acom$*$LI, using an example. But I can't come up with a non-trivial example of a monoid in LI. Any help is appreciated.
I am using C++03. I have a stream of chars and I need to find the first token from a group of tokens. That is, I need to find the lowest indexed match. Specifically, the stream is just an char array, and the tokens of interest are listed below. The start of a token can occur anywhere in the stream (and not necessarily ...
I came across the following question: Which of the following risk may arise, when same key is used to encrypt both directions of a communication channel, that are not present if using different keys in both direction? The answer to the question was reflection attack. The other options provided were denial of service, e...
(Apologies if this or an equivalent question has been asked in the past; I didn't see anything that answered this question.) I'm designing an algorithm to compute a heuristic for a Gin game engine. (The game I'm implementing might not be exactly Gin [it's a game I learned as a child] but it's extremely close.) For thos...
Given a 3d mesh, for example the stanford bunny, how can I segment the mesh in a way that each segment has a roughly equal size between them? Assuming the target number of segments is given as an input. To keep things simple, let's start with assuming the vertices are uniformly distributed in the mesh, therefore the p...
Suppose I have a directed graph $G = (V, E)$ (or, which is the same, a relation on the set $V$ as defined by the adjacency matrix) that may contain three vertices $x, y, z$, such that $xy, xz, yz \in E$ — that is to say, the relation restricted to $x, y, z$ is transitive, there is a triangle. Let us call this situation...
What is the minimal degree $d$ required so a B - tree with $44*10^6$ keys will have a height $h$, such that $h\leq 5$ My attempt was to build the tallest tree possible with minimum degree $d$ and $n = 44,000,000$ keys and then solve for $d$. That would mean any other tree with a minimal degree $d'$ such that $d'\geq ...
Types and Programming Languages by Pierce says: 22.7 Let polymorphism A final point worth mentioning is that, in designing full-blown programming languages with let-polymorphism, we need to be a bit careful of the interaction of polymorphism and side-effecting features such as mutable storage cells. A simple examp...
In Types and Programming Languages by Pierce, Chapter 11 is simple extensions of the simply typed lambda calculus with any simple base types. Section 11.12 introduces Lists. How does the section allow list operations to be applied to lists with elements of any type? Specifically, my confusions are: Does Section 11.12...
What will happen in a Prolog program, if I set two rules/facts which contradict each other.. will it go with the rule/fact that appears first.. or it will show an error?
I was reading the LR() parsers from the Dragon Book where I came across these lines: To construct canonical LR(0) collection for a grammar, we define an augmented grammar and 2 functions, CLOSURE and GOTO. for example say if we have a grammar like--> S → BB B → cB/d Then in augmented grammar we define it as S' → S...
Algebraic semantics is one type of semantics that uses algebraic expressions for connecting the formal descriptions of initial and final states of some operation of some operation that is defined in the programming language. I can not imagine more general and more versatile semantics, but yet - it is not used in today ...
Is there a site that keeps track of the "current best algorithms", e.g., for certain combinatorial optimization problems? In the latter there exists a range of classic problems such as MIN st-CUT or MAX FLOW, for which the best algorithms seem to be somewhat hidden in the literature.
In Types and Programming Languages by Pierce, Chapter 23 Universal Types has a summary of System F in the following figure, in particular, "type abstraction values" and their types "universal types". In all the examples I have seen so far in the chapter, in particular Section 23.4 Examples, (not sure if I miss any exam...
I am a complexity beginner, actually a quantum physicist. In their famous BosonSampling paper, Aaronson and Arkhipov show amongst other things a polynomial time machine solving the problem of BosonSampling exactly, would result in the collapse of the Polynomial Hierarchy. If you are not familiar with BosonSampling or ...
Is there an algorithm that gets as an input 2 arrays (arr_origin, arr_dest) that represent spheres with a set radius (R) in a 3d space, (x,y,z) points. And finds a route for the spheres from origin to dest without collisions, in the fastest way given each sphere can move at a speed from 0 to V?
In Sipser's Introduction to the Theory of Computation he uses the notation $2^{\mathcal{O}(f(n))}$ to denote some asymptotic running time. For example he says that the running time of a single-tape deterministic turing machine simulating a multi-tape non-deterministic turing machine is $\mathcal{O}(t(n)b^{t(n)})=2^{\ma...
I was told by my professor that "It takes c * ln(n) bits to store a number n, where ln() is base 2 and c is a constant." Thus, to store a number 8, we need ln(8) = 3 bits(I think const c can be ignored here.), but isn't 8 stored as "1000" in a computer, which is 4 bits? Thanks.
I am trying to do the recurrence relation for my algorithm, but it has two variables $T(n,m)$. For sufficiently small $n$, $m$ is practically the same as $n$, but $m$ cannot grow beyond some constant $k$. So once $n$ grows beyond $k$, $m$ turns to constant $k$. So it has two different stages. I have done the relation i...
Section 24.2 in Types and Programming Languages by Pierce compares ADT and existential objects,in terms of how well they support strong binary operations: Other binary operations cannot be implemented without concrete, privileged access to the representations of both abstract values. For example, suppose we are imp...
Section 24.2 in Types and Programming Languages by Pierce defines ADTs in existential types: A conventional abstract data type (or ADT) consists of (1) a type name A, (2) a concrete representation type T, (3) implementations of some operations for creating, querying, and manipulating values of type T, and (4) an ...
Disclaimer: If not interested in my background, skip directly to the question below! I am a complete newbie when it comes to complexity theory. I come from a physics background and I am currently working through the complexity-theoretical arguments behind Boson sampling and and other quantum supremacy proposals. These ...
I am familiar with the oft-cited method of bitwise addition using XOR and left shift for the carry, applied recursively. I was wondering if this is the least computationally expensive way to achieve simple addition modulo 2^n using bitwise operators.
I've already read several blogs and questions on stack exchange, but I'm unable to grasp what the real drawbacks of memory mapped files are. I see the following are frequently listed: You can't memory map large files (>4GB) with a 32-bit address space. QUESTION #1: Why? Isn't that the whole point of virtual memory? ...
In a lecture video the instructor introduced the quadratic probing method for hash tables. The formula he gave was the following: $h(k,i) = (h'(k) + c_1 + c_2i^2)$ $\% M$ where $h'$ was h "prime". So, what I am supposed to conclude for $h'(k)$ to be? Is it any different from the value I get by computing $h(k)$
If we divide (1.0/0.0) we will get +Infinity and if we divide (-1.0/0.0) we will get -Infinity. How does a computer calculate this value internally?
I have this problem where I want to fill every black shape with a line. Every dot of the shape needs to be visited by the line. Preferably creating the shortest line. Any idea how I can achieve this or to what algorithm to look at? I do not have any experience with algorithms so please keep it simple.
In the 2nd phase of the Louvain algorithm, self-loops are given by the sum of all the intra-community weights. I'm wondering from their own figure, why all of the self-loops seem to have 2w weights, rather than w. Note in the blue community for instance: 2 intra-community edges, self loop has weight 4.
I want to transmit a 32bit message in eight groups of 5bit each. This leaves me with 8bits to use for error checking. Overall, a group is likely transmitted without error, but when there is an error transmitting a group, there are probably multiple bits wrong. If I use one parity bit per group, I have a 50% chance to d...
What I am planning to do is to calculate the height and estimate the slope of the segmented Object. The camera will be static and the Object of Interest is the slope of the beach. I am finding harder to use depth camera, as the minimum distance between slope and camera is 150 meters. I have tried Unet Semantic Segmenta...
In Types and Programming Languages by Pierce, how does the following achieve the definition of an existential type in terms of universal type, by polymorphic version of Church encoding of pairs? 24.3 Encoding Existentials The encoding of pairs as a polymorphic type in §23.4 suggests a similar encoding for existent...
Lets say we have the following loop and want to find its time complexity: 0: def example_loop(n): 1: i = 0 2: while i < n: 3: print(i) 4: i = i + 1 One possible approach is to first determine that for each individual row it's $\Theta (1)$ (row 4 is $\Theta (1) + \Theta (1) = \Theta (1)$). Thus,...
I have the following problem: There is a "clean" sequence of sequences, say: clean = [ [1, 2], [3], [4, 5] ] And a "noisy" sequence which is not segmented: segmented = [1, 100, 2, 3, 3, 101, 4, 5] I would like to partition segmented into exactly len(clean) parts such that the sum of the edit distances of ...
I wonder how events, or more broadly reactive programming, could be managed in a simple stack-oriented language. For example, let's imagine a context where there is a button that displays a small message when you press it. How could an entire program on the stack handle the case where the user presses the button withou...
The question is already stated in the title.
I'm recently trying to study the paper "Graph Partitioning with Natural Cuts": https://www.microsoft.com/en-us/research/wp-content/uploads/2010/12/punchTR.pdf There is a term edge-connected components in section 3.1 Detecting Tiny Cuts: The first pass identifies all edge-connected components of the graph using depth-f...
In the book Introduction to Automata Theory there is a question 9.3.4 that asks if a question "whether a language L(M) is infinite" is RE or non-RE? I've seen the answer, that its non-RE, however I tried a reduction from a Universal Turing machine language(which is RE) and it also seemed to work. Since a language can't...
In Bandit Based Monte-Carlo Planning by Levente Kocsis and Csaba Szepesvári (2006) they propose the UCT algorithm which is derived from the UCB1 algorithm. UCB1 algorithm: $$X_j + \sqrt{\frac{2\ln n}{n_j}}$$ where $X_j$ is the average reward for machine $j$, $n_j$ is number of times $j$ has been played and $n$ is the ...
I have an array of polygons which are arrays of points. There are no gaps and none of them overlap like a Voronoi diagram. Unlike a Voronoi diagram I cannot simply find the nearest centroid to select a polygon, this returns the correct polygon most of the time but sometimes the point lies within a neighboring polygon. ...
I know 3SAT is NP-complete and QSAT is PSPACE-complete. However, is it true that $$\exists X_1 \forall X_2 \cdots Q_k X_k \colon \varphi(X_1, \ldots, X_k)$$ is complete for $\Sigma_k$, the existential side of level $k$ of the polynomial hierarchy if each clause in $\varphi$ has at most 3 literals (or some other constan...
Consider the following recursion: $\begin{cases} T(n) = 2T(\frac{n}{2}) + \frac{n}{\log n} &n > 1 \\ O(1) &n = 1 \end{cases}$. The master theorem doesn't work, as the exponent of $\log n$ is negative. So I tried unfolding the relation and finally got the equation: $T(n) = n[1 + \frac{1}{\log(\frac{n}{2})} + \f...
Given an undirected connected graph, I wrote the following algorithm based on BFS. The algorithm detects wether this graph contains a cycle. If it contains a cycle then prints it. I'm pretty sure that it works just fine, but I don't really know how to prove its correctness properly. Here is the pseudo-code: Let s be t...
What are the definitions of a type constructor and a type operator? What are their differences and relations? I think a type operator is a function whose parameters are n types and return is a type. A type constructor also means the same thing. I use them exchangeably. But some reply used type constructor when my ques...
Can somebody give intuition how to answer those questions? From one side I can say that most of them are undecidable because we can reduce the halting problem to them (or halting problem can appear because we don't know about given TM anything so it can behave unpredictably, can simply loop on any input), but on anothe...
I'm interested in the intersection of linguistics and computer science, I've been reading on Chomsky hierarchy, and would like to know if there exist lambda calculus types that are equivalent to the Chomsky types, especially the type-1 that's context-sensitive and has the linear-bounded non-deterministic Turing machine...
Given an array A(1 indexed based) of positive integers.For each element A[i] find the minimum index (say idx) such that the product of all the elements from index 1 to idx is divisible by A[i].where(1<=idx<=i). constraints are: the number of elements of the array 1<=n<=10^5 and 1<=A[i]<=10^5. For example let A[]={2,4,...
I understand that vector clocks are preferred over lamport clocks because sometimes lamport clocks cannot account for the casuality and we use extra space to store the timestamps in the vector clocks. What i dont understand is about the resetting of the vector clocks. Why do the vector clocks overflow and how the reset...
In my slides for my algorithms class, I have a method of finding the complexity of recursive functions called Recurrence Relation with "partizione bilanciata" which means "balanced partition". My course is in Italian and looking online in English I could not find any trace of this method, I know of the recursive tree, ...
Given a directed weighted acyclic graph G=(V,D,W) and a subset of edges D' of D. The problem is to find the longest path in G that passes by exactly one edge of D'. What is the complexity of this problem?
Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example: $$ \begin{align} \textrm{Event 1} &\rightarrow \textrm{[1, 2, 3]} \\ \textrm{Event 2} &\rightarrow \textrm{[2, 4]} \\ \textrm{Event 3} &\rightarrow \textrm{[4]} \\ \textrm{Event 4} &\rightarrow \textrm{[2, 3]}...