text
stringlengths
81
47k
source
stringlengths
59
147
Question: <p>I'm having hard time understanding time complexity of my solution for <a href="https://leetcode.com/problems/combination-sum/" rel="nofollow noreferrer">combination sum problem</a>. The problem is as follows:</p> <blockquote> <p>Given a set of candidate numbers (<code>candidates</code>) (without duplica...
https://cs.stackexchange.com/questions/121142/complexity-of-recursive-algorithm
Question: <p>There is this Prim's algorithm I am studying, the time complexity of which is $O(n^2)$ (in the adjacency matrix).</p> <p>As far as I have understood,that is because we have to ckeck all the nodes per every node, that is, when checking the first node's best edge, we have to check edges from the current nod...
https://cs.stackexchange.com/questions/85870/time-complexity-of-prims-algorithm
Question: <p>I'm a bit confused how worst case complexity is estimated for the <a href="http://en.wikipedia.org/wiki/DPLL_algorithm" rel="nofollow">DPLL algorithm</a>. Is it in terms of number of clauses, number of variables, or something else?</p> Answer: <p>In the papers I've read the time complexity of DPLL is expr...
https://cs.stackexchange.com/questions/14004/is-the-dpll-algorithm-complexity-in-terms-of-of-clauses-or-of-variables
Question: <p>Can someone explain why the complexity of a query for LA is √n when we only decompose the tree into long-paths? How can we show/prove that?</p> <p>How can we prove that the <strong>number of paths can be as high as O(√n)</strong> ??? Please help, I've been struggling for a couple of days now.</p> <p>Stage ...
https://cs.stackexchange.com/questions/130826/level-ancestor-query-long-paths-algorithm-complexity-of-sqrt-n
Question: <p>In a sorting algorithm, While computing the complexity of an algorithm why do we only account for the number of comparisons done but not the number of swappings done? And what's the formal definition of complexity?</p> Answer: <p>The formal definition of complexity of an algorithm is the runtime in terms ...
https://cs.stackexchange.com/questions/157219/definition-of-complexity-of-an-algorithm
Question: <p>Using the following recursive Fibonacci algorithm:</p> <pre><code>def fib(n): if n==0: return 0 elif n==1 return 1 return (fib(n-1)+fib(n-2)) </code></pre> <p>If I input the number 5 to find fib(5), I know this will output 5 but how do I examine the complexity of this algorithm? How ...
https://cs.stackexchange.com/questions/14733/complexity-of-recursive-fibonacci-algorithm
Question: <p>I have a question about the Euclid's Algorithm for finding greatest common divisors.</p> <p>gcd(p,q) where p > q and q is a n-bit integer.</p> <p>I'm trying to follow a time complexity analysis on the algorithm (input is n-bits as above)</p> <pre><code>gcd(p,q) if (p == q) return q if (p ...
https://cs.stackexchange.com/questions/72200/euclids-algorithm-time-complexity
Question: <p>For a school project I am doing on linear programming, I've implemented the simplex algorithm in Python. </p> <p>I was hoping to check the complexity on a number of matrices. </p> <p>Preferably, they would have to be in standard form ($Ax=b$ and $x\geq0$) (or easily put into standard form) and would have...
https://cs.stackexchange.com/questions/76347/simplex-algorithm-experimental-complexity
Question: <p>I'm trying to find the longest palindromic subsequence for any string and I've tried two approaches: </p> <ol> <li>Recursive Algoritm</li> <li>Dynamic Programming</li> </ol> <p>Dynamic programming should be the better option in this case because of the time complexity but the time complexity of both algo...
https://cs.stackexchange.com/questions/93104/complexity-of-longest-palindromic-subsequence-algorithm
Question: <p>I'm little confused by computing a time complexity for <code>Dijkstra</code> algorithm. It is said that the complexity is in $O(|V|^2)$ - <a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm" rel="nofollow" title="Wikipedia - Dijkstra">Wikipedia - Dijkstra</a>, which I understand. It's because for...
https://cs.stackexchange.com/questions/57226/complexity-of-the-dijkstra-algorithm
Question: <p>Assume I know that there is an algorithm of complexity<br> $ \mathcal{O}( log ( \vert V \vert^2 \vert E \vert ) ) $ for a Graph $G(E,V)$.</p> <p>How do I compare this for example to the complexity of<br> $ \mathcal{O}( \vert V \vert^2 + \vert E \vert ) $ or other complexity algorithms on $G$. </p> <p>Th...
https://cs.stackexchange.com/questions/52796/compare-complexity-of-graph-algorithm
Question: <p>I need help with finding out the time complexity of the following algorithm:</p> <pre><code>procedure VeryOdd(integer n): for i from 1 to n do if i is odd then for j from i to n do x = x + 1 for j from 1 to i do y = y + 1 </code></pre> <p>This is my attempt:</p> <p>$$ Loop1 = \Thet...
https://cs.stackexchange.com/questions/14298/time-complexity-of-algorithm
Question: <p>Say I have the following statement:</p> <blockquote> <p>If <span class="math-container">$f(n) = O(s(n))$</span> and <span class="math-container">$g(n) = O(r(n))$</span>, then <span class="math-container">$f(n) - g(n) = \Theta(s(n) - r(n))$</span>.</p> </blockquote> <p>What would be a counterexample to ...
https://cs.stackexchange.com/questions/100944/counterexample-to-an-algorithm-complexity-statement
Question: <p>I've read there are ways you can determine all reachable pairs using Strongly Connected Components. But, I want to calculate all reachable nodes on the fly - so I don't have to store a massive reachability matrix in RAM. What sort of time complexity would be possible for an algorithm to calculate all reach...
https://cs.stackexchange.com/questions/124959/what-time-complexity-is-a-reachability-algorithm
Question: <p>I am to find the time complexity of my algorithm and I found one method <a href="https://en.wikipedia.org/wiki/Time_complexity" rel="nofollow noreferrer">here</a>.<br> However I am really not sure about it correctness thus I would like to check it.<br> There is my algorithm (N is a set (len(N) is constant)...
https://cs.stackexchange.com/questions/68745/finding-time-complexity-of-an-algorithm
Question: <p>Dynamic programming algorithm for Knapsack is stated to have complexity $\mathcal O (nW)$.</p> <p>However, I've also seen the complexity stated as $\mathcal O (n^2V)$, where $V=\max v_i$.</p> <p>(Here $n$ is the number of items and $W$ the weight limit).</p> <p>I see from the algorithm that the first co...
https://cs.stackexchange.com/questions/43175/complexity-of-dynamic-programming-algorithm-for-knapsack
Question: <p>I am trying to calculate the complexity of the euclidean algorithm for finding the greatest common divisor (gcd) (recursive version). </p> <p>Here's the pseudo code:</p> <pre><code>algorithm euclid(a,b) if b = 0 then return a else return euclid(b, a mod b) end if </code></pre> <p>My initial thou...
https://cs.stackexchange.com/questions/90573/recursive-euclid-algorithm-for-gcd-complexity
Question: <p>I've just started reading about the complexity of algorithms, but everywhere I look, it is only defined for one input $n$. For example an algorithm is cubic if its complexity is $O(n^3)$.</p> <p>But what about when the complexity depends on several inputs? For example if an algorithm has complexity $O(n^2...
https://cs.stackexchange.com/questions/53650/complexity-of-an-algorithm-with-multiple-inputs
Question: <p>I have some questions that I don't understand about time complexity.</p> <ol> <li>Given that the worst case complexity of the algorithm <span class="math-container">$A$</span> is <span class="math-container">$O(f(n))$</span> and the best case complexity of <span class="math-container">$A$</span> is <span c...
https://cs.stackexchange.com/questions/139140/time-complexity-of-algorithms
Question: <p>I am really bad at calculating correctly the complexity of a given algorithm. I would like to know if there is some book or online resources where I can find many exercises that ask to calculate the complexity of a given algorithm. </p> <p>Thank you! </p> Answer:
https://cs.stackexchange.com/questions/97402/calculating-the-complexity-of-an-algorithm-exercises
Question: <p>How to understand at least a small introduction to the complexity time for algorithm , how i can know that algorithm need O(log^2 N ) and so on is there any basic reference for this topic , needed in my project </p> Answer:
https://cs.stackexchange.com/questions/62727/complexity-time-needed-for-any-algorithm
Question: <p>I'm wondering about the optimal complexity - or at the very least, some way of achieving non-terrible complexity - of a particular stack variant, that I'm calling a 'nonrepetitive stack'.</p> <p>A nonrepetitive stack is like an ordinary stack, except that a push that would result in a repeated subsequence ...
https://cs.stackexchange.com/questions/154426/optimal-algorithmic-complexity-of-a-nonrepetitive-stack
Question: <p>I want to analyze a clustering algorithm that clusters data stream. Since the stream can be unbounded, I cannot write O(N^2), or explicitly denote the size of the stream. How can I use the arrival rate of the data for the computation complexity? Do you have any other idea for correct analysis of stream com...
https://cs.stackexchange.com/questions/87316/computation-complexity-of-stream-algorithm
Question: <blockquote> <p><strong>$n$ : length of text T</strong> </p> <p><strong>$m$ : length of pattern P</strong></p> </blockquote> <p>When I study Rabin-Karp algorithm, I learned the best case of this algorithm is $\theta(n-m+1)$. Because if a hashed number is too small to modulo by some other number.</p> ...
https://cs.stackexchange.com/questions/93009/time-complexity-of-rabin-karp-algorithm
Question: <p>How do I calculate the complexity of this Algorithm below? I would like to know how I calculate the sums that form to obtain a formula as a function of n? I know that in general this algorithm has O(n^3) complexity, but how can I do that?</p> <pre><code>int i,j,k,s; for(i=0; i &lt; N-1; i++) for(j=i+...
https://cs.stackexchange.com/questions/163411/complexity-of-an-algorithm-with-nested-loops
Question: <p>I have algorithm that contains next loops:</p> <pre><code>for (int i = 0; i &lt; size; ++i) { for (int j = i + 1; j &lt; size; ++j) { //Do stuff } } </code></pre> <p>I found that this algorithm has $O(n^2)$ complexity but I can't understand why? I.e. if $N = 4$ then $n^2 = 16$ but my loo...
https://cs.stackexchange.com/questions/63216/the-complexity-of-the-algorithm-with-loops
Question: <p>How do i calculate the complexity of this algorithm at the best case and its complexity at the worst case and the average complexity by assuming that the probability that the element is in the list is 0≤p≤1 and that all sites are equal probability</p> Answer:
https://cs.stackexchange.com/questions/92416/calculate-the-complexity-of-binary-search-algorithm
Question: <p>I am designing a graph algorithm. Some steps of the algorithm, are set operations (union, difference, intersection, set-membership).</p> <p>Can I assume them as $~ \mathcal{O}(1)$ operations? Have someone used them as $~\mathcal{O}(1)$ in his paper?</p> <p>What minimum complexity should I assume for thes...
https://cs.stackexchange.com/questions/67053/complexity-of-set-oprations-in-algorithm
Question: <p>I've just designed an algorithm to prune a tree related to a particular fluid dynamics problem, and I need to determine its computational complexity; however, since I'm just a newcomer (from mechanical engineering) to the computational complexity theory, I'm not sure about the following reasoning:</p> <p>...
https://cs.stackexchange.com/questions/86698/computational-complexity-of-a-tree-pruning-algorithm
Question: <p>I decide to learn more about dynamic programming, so I started reading the Dynamic Programming chapter from the CLSR book.</p> <p>The first example problem presented there is Rod Cutting (15.1). Given a rod of length n and a list of prices for rods of any sizes figure out how to cut the rod so that the pr...
https://cs.stackexchange.com/questions/92859/time-complexity-intuition-for-recursive-algorithm
Question: <p>That's what I'm formally asking:</p> <p>Let the algorithm <span class="math-container">$A$</span> have the worst-case time complexity <span class="math-container">$\Theta(f(n))$</span>, such that for any algorithm <span class="math-container">$B$</span> with the worst-case time complexity <span class="math...
https://cs.stackexchange.com/questions/165152/can-a-time-optimal-algorithm-have-a-time-complexity-better-than-its-space-comple
Question: <p>From the <a href="https://en.wikipedia.org/wiki/Smallest-circle_problem#Welzl%27s_algorithm" rel="nofollow noreferrer">wiki</a> this is the algorithm and we know that final complexity is O(n) but how we reached to this , is my problem :</p> <pre><code>algorithm welzl is input: Finite sets P and R of po...
https://cs.stackexchange.com/questions/147944/check-welzls-algorithm-time-complexity
Question: <p>I developed an algorithm but just not sure what is the complexity of the algorithm. I provide a brief description of it below:</p> <p>"For $N$ user case, there are $B(N)$ Decision Variables. $B(N)$ is Bell Number, for those of you who are not familiar with Bell Numbers please be noted that $B(N)$ grows ex...
https://cs.stackexchange.com/questions/77021/i-do-not-know-if-my-algorithm-complexity-is-p-np-or-np-hard
Question: <p>I've developed the following backtrack algorithm, and I'm trying to find out it time complexity.</p> <p>A set of $K$ integers defines a set of modular distances between all pairs of them. In this algorithm, I considered the inverse problem of reconstructing all integer sets which realize a given distance ...
https://cs.stackexchange.com/questions/13181/time-complexity-of-a-backtrack-algorithm
Question: <p>We have started learning about analysis of recursive algorithms and I got the gist of it. However there are some questions, like the one I'm going to post, that confuse me a little.</p> <h3>The exercise</h3> <blockquote> <p>Consider the problem of multiplying two big integers, i.e. integers represented by ...
https://cs.stackexchange.com/questions/14685/complexity-of-a-recursive-bignum-multiplication-algorithm
Question: <p>I'm reading side by side my class notes and Papadimitrious' Computational Complexity book. At this point they are talking about space complexity. They give rules for computing space employed in an algorithm that runs on a multi-tape Turing machine:</p> <ol> <li>We count the cells used.</li> <li>If we don'...
https://cs.stackexchange.com/questions/79946/definition-of-space-complexity-when-algorithm-cycles
Question: <p>I am very much confuse that why complexity of this program is O(n)?</p> <pre><code> int j = 0; int i; For (i = 0; i &lt; n, i++) // O(n) { For (i = 0; i &lt; n, i++)//O(n) { While (j &lt; n)// O(n) { Statement; j++; } } } </code></pre> <p>I am totally ...
https://cs.stackexchange.com/questions/86238/algorithm-complexity-of-this-program-is-on-or-on3
Question: <p>Is it possible an algorithm complexity decreases by input size? Simply $O(1/n)$ possible?</p> Answer: <p>Consider an algorithm with some running time bounded by $f(n)$ and suppose that $f(n) \in O(1/n)$. That means that there is some constant $c$ such that for sufficiently large values of $n$, it holds th...
https://cs.stackexchange.com/questions/3495/complexity-inversely-propotional-to-n
Question: <p>I have written the following algorithm </p> <ul> <li><span class="math-container">$select(\Pi)$</span> select the first elements from <span class="math-container">$\Pi$</span>. When there are no element in <span class="math-container">$\Pi$</span>, it return <span class="math-container">$\emptyset$</span>...
https://cs.stackexchange.com/questions/106224/termination-proof-and-complexity-of-a-algorithm
Question: <p>Let A[1 : n] be a vector of n integers such that all elements except O(n^2/3) elements are between 1 and 10n. Design an algorithm with linear complexity that sorts A.</p> <p>Beyond the algorithm, what I can't fully understand is why we are provided with the information &quot;all elements except O(n^2/3)&qu...
https://cs.stackexchange.com/questions/157540/design-an-algorithm-with-linear-complexity
Question: <p>While I understand the process of considering/observing an algorithm and finding an average time, necessary to perform an operation that happens in this algorithm, I still cannot quite gasp the idea, or rather the expression:</p> <p><strong>&quot;The Algorithm has an amortized time complexity which is cost...
https://cs.stackexchange.com/questions/153341/algorithm-with-amortized-time-complexity
Question: <p>For example:</p> <p>If algorithm A takes an input of size n, and has a time complexity of O(a^n) and a space complexity of O(1)</p> <p>Is there a way to increase the space complexity to something like O(n^2) that would guarantee that the time complexity would decrease?</p> Answer: <blockquote> <p>If a...
https://cs.stackexchange.com/questions/110934/is-there-any-relationship-between-time-complexity-and-space-complexity-of-an-alg
Question: <p>I have a certain algorithm which I can run, but I do not have access to its code. Thus, it works as a black box. I would like to now the order of complexity of this algorithm on a certain set of instances, which grow in size as a function of <span class="math-container">$n$</span>.</p> <p>Now, I have coll...
https://cs.stackexchange.com/questions/112083/how-to-find-an-algorithms-complexity-from-actual-running-times
Question: <p>The worst case time complexity of a given algorithm is <span class="math-container">$\theta(n^3logn)$</span>.<br /> Is it possible that the worst time complexity is <span class="math-container">$\Omega(n^2)$</span>?<br /> Is it possible that the worst time complexity is <span class="math-container">$O(n^4)...
https://cs.stackexchange.com/questions/128174/can-an-algorithm-complexity-be-lower-than-its-tight-low-bound-higher-than-its
Question: <p>When I read introductory textbooks I get contradictory answers. In some cases efficiency and complexity are treated the same and the big-O notation is used to indicate that (for example) for an O(n) algorithm the time to execute is linearly proportional to the input dataset size.</p> <p>From other sources...
https://cs.stackexchange.com/questions/71858/definition-of-efficiency-versus-complexity-of-algorithm
Question: <p>Does there exist an algorithm for which an exact complexity <em>provably</em> cannot be expressed in <a href="https://en.wikipedia.org/wiki/Closed-form_expression" rel="nofollow">closed-form</a>? </p> <p>Here closed-form means a <em>finite</em> composition of addition, subtraction, product, division, fact...
https://cs.stackexchange.com/questions/60622/algorithm-with-no-closed-form-exact-complexity
Question: <p>In the <a href="https://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm" rel="nofollow">Bentley–Ottmann algorithm</a>, Regarding :</p> <blockquote> <p>Find the segments r and t that are immediately below and above s in T (if they exist) and if their crossing forms a potential future event in...
https://cs.stackexchange.com/questions/52979/bentley-ottmann-algorithm-time-complexity-issue
Question: <p>I tried to calculate the worst case of binary search (not binary search tree). My calculations: <span class="math-container">$$T(n) = T\left(\frac{n}{2}\right) + 1$$</span> <span class="math-container">$$T(n) = T\left(\frac{n}{4}\right) + (1+1) = T\left(\frac{n}{8}\right) + (1+1+1) = {\dots} = T\left(\frac...
https://cs.stackexchange.com/questions/67387/binary-search-algorithm-worst-case-complexity
Question: <p>I have the following algorithm which takes as an input a non negative integer n : <br/> i = n <br/> while i &gt; 0 do : <br/> <span class="math-container">$\,$</span> <span class="math-container">$\,$</span> <span class="math-container">$\,$</span> <span class="math-container">$\,$</span>i = i - 1 <br/> <...
https://cs.stackexchange.com/questions/159948/need-help-verifying-the-complexity-of-an-algorithm
Question: <p>Given this shell sort algorithm implementation:</p> <pre><code>void shell(float ∗a ,int l ,int r) { int i, j, h; for ( h = 1 ; 3∗h +1 &lt;= r−l; h = 3∗h + 1 ); for (; h &gt; 0; h / = 3) { for (i = l+h; i &lt;= r; ++ i) { for (j = i; j &gt;= l +h &amp;&amp; a[j] &lt; a[j−h]; j −= h) { ...
https://cs.stackexchange.com/questions/160442/shell-algorithm-knuth-sequence-time-complexity-analysis
Question: <p>In 1950s a number of methods for <a href="https://en.wikipedia.org/wiki/Circuit_minimization_for_Boolean_functions" rel="nofollow">circuit minimization for Boolean functions</a> have been invented. Is there an extension of those methods or anything similar for optimising time or space complexity of algorit...
https://cs.stackexchange.com/questions/51516/is-there-an-algorithm-for-algorithms-time-space-complexity-optimisation
Question: <p>I'm new to recurrence relations and master theorem so trying to learn. Say there's an algorithm <span class="math-container">$A$</span> whose input is the root of a binary tree <span class="math-container">$T$</span>. <span class="math-container">$A$</span> recurses so that it's called on each and every no...
https://cs.stackexchange.com/questions/165081/time-complexity-of-tree-algorithm
Question: <p>I have found a algorithm to check whether a Hamiltonian Cycle Exists in the graph or not, but not able to compute/analyse it's time complexity.</p> <p>The algorithm is as follows :</p> <ol> <li>Label all the vertices with distinct prime numbers.</li> <li>Label all edges with weight equal to 1.</li> <li>N...
https://cs.stackexchange.com/questions/50072/time-complexity-and-optimization-for-the-algorithm
Question: <p>I am totally new in this area.</p> <p>Lets say we have a list of random numbers and we have to find one peak value (only one is fine), and a peak is if <span class="math-container">$a \geq$</span> than its both neighbours (or one if it is in on the edge). For example:</p> <p><a href="https://i.sstatic.net/...
https://cs.stackexchange.com/questions/170041/complexity-of-peak-finding-algorithm-for-n-dimensions
Question: <p>this is my first question in CS so I apologize if this question is off-topic.</p> <p>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). </p> <p>I am interested to know whats the constant hid...
https://cs.stackexchange.com/questions/30558/constant-in-complexity-of-sqrt-algorithm
Question: <p>I am somewhat a beginner, and I have often seen complexity being calculated for various algorithms but they never actually gave me a very clear idea about how it is done. Can someone please point some resources where I can learn to calculate the complexity of an algorithm?</p> <p>Secondly, is there some s...
https://cs.stackexchange.com/questions/12475/using-software-to-calculate-the-complexity-of-an-algorithm
Question: <p>I have an algorithm here and it wants me to calculate the complexity:</p> <pre><code>for (i=1;i&lt;n;i++) for (j=1;j&lt;i*i;j++) if (j%i==0) for (k=0;k&lt;j;k++) sum++; </code></pre> <p>First of all, I think that i have different complexities for best, average and worst case but I ...
https://cs.stackexchange.com/questions/76465/calculate-the-complexity-of-an-algorithm
Question: <p>Consider the basic non-recursive DFS algorithm on a graph G=(V,E) (python-like pseudocode below) that uses array-based adjacency lists, a couple of arrays of size V, and a dynamic array stack of size &lt;= V. If I understand correctly, this is a cache oblivious algorithm since no information about the memo...
https://cs.stackexchange.com/questions/65409/what-is-the-algorithmic-complexity-of-dfs-under-the-cache-oblivious-model
Question: <p>I'm just wondering what the correct notation is when referring to an average case complexity of an algorithm that was calculated by doing empirical analysis.</p> <p>For example, I have tested my algorithm and fitted the results to the curve $f(n)=2.65\times 10^{-15}\cdot(2.17^{n})$ and in my report right ...
https://cs.stackexchange.com/questions/14960/notation-for-average-case-complexity-of-an-algorithm
Question: <p><strong>Some context:</strong> I'm to write a program that sorts the lines of a file in C for Linux. Since I have to read all lines of the file (<code>fgets()</code> for example) I'm thinking about inserting them in a tree like structure in a sorted manner using the so called tree sort algorithm.</p> <p>L...
https://cs.stackexchange.com/questions/12714/whats-better-for-an-algorithm-complexity-olog-n-or-amortized-olog-n
Question: <p>Consider the following dynamic card game with a regular deck of 26 red cards and 26 black cards. A dealer draws the unturned cards one by one, and we can ask him to stop at any time. For every red card drawn, we get 1 dollar and lose 1 dollar for every black card drawn. The problem consists in finding an a...
https://cs.stackexchange.com/questions/52668/complexity-of-dynamic-card-game-algorithm
Question: <p>A dumb question in complexity theory.</p> <p>Let's consider an algorithm that solves the following problem:</p> <p>is <span class="math-container">$e^{n}$</span> time passed?</p> <pre><code>f(n): 1. let t = get_current_time() 2. wait(e^n) 3. return get_current_time()-t </code></pre> <p>Naively, I'...
https://cs.stackexchange.com/questions/167613/complexity-of-algorithm-waiting-en-seconds
Question: <p>A non-recursive linear Suffix Array construction algorithm is presented in this thesis: <a href="https://www.uni-ulm.de/fileadmin/website_uni_ulm/iui.inst.190/Mitarbeiter/baier/gsaca.pdf" rel="nofollow noreferrer">Linear-time Suffix Sorting</a>. The author claims that, overall, the algorithm runs at $O(n)$...
https://cs.stackexchange.com/questions/92336/suffix-array-construction-algorithm-linear-complexity-constant
Question: <p>I've reading up on Kosaraju's algorithm to compute the strongly connected components of a directed graph and I found that</p> <ol> <li>using an adjacency list representation gives a time complexity of $\Theta(V+E)$.</li> <li>using an adjacency matrix representation gives a time complexity of $O(V^{2})$.</...
https://cs.stackexchange.com/questions/39955/kosarajus-algorithms-time-complexity
Question: <p>I am trying to calculate the time complexity of an algorithm using <code>n</code> in the code below.</p> <p>I have a working solution to a coding challenge to sort a stack using only another stack, and I've added a counter variable <code>n</code> that is incremented anywhere an element in the stack is pus...
https://cs.stackexchange.com/questions/112130/calculating-time-complexity-of-algorithm-using-incrementor-variable
Question: <p>I solved a practice interview problem that was sent me by Daily Coding Problem mailing list. I am now curious about the exact time complexity of my solution.</p> <h2>Problem Statement</h2> <blockquote> <p>Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it ca...
https://cs.stackexchange.com/questions/106350/time-complexity-of-a-tree-based-algorithm
Question: <p>Does there exists a computable problem P such that:</p> <ul> <li>Is proven that P can be solved with an algorithm that has a certain complexity.</li> <li>The best algorithm know unluckily is still slower (greater complexity) than the proven bound.</li> </ul> <p><strong>Example:</strong></p> <ul> <li>A p...
https://cs.stackexchange.com/questions/63005/problems-with-proven-complexity-but-no-algorithm-yet-found
Question: <p>I was solving a problem, where one part of it was the following:</p> <p>"Given a m-sided dice ([1,m] values) that will be rolled n times, calculate the possibility that the total sum of rolls will be higher than b"</p> <p>Initially, I implemented a naive exponential solution, discovering the whole state ...
https://cs.stackexchange.com/questions/68491/complexity-of-exponential-algorithm-optimised-with-memoization
Question: <p>I have a background in computer architecture and only cursory understanding of process networks. For a paper I am writing I need to understand prefix monotonicity properly. </p> <p>For now I have "a stream transformer is prefix monotonic if its output for a given input record r is dependent only on the in...
https://cs.stackexchange.com/questions/7685/what-is-prefix-monotonicity
Question: <p>Graph Neural Networks (GNNs) have proven to be powerful tools for modeling relationships in structured data, but one of their main limitations is their difficulty in capturing hierarchical structures within a graph. Message-passing methods primarily focus on local relationships, which can limit their abili...
https://cs.stackexchange.com/questions/171414/how-can-we-improve-the-capture-of-hierarchical-structures-in-graph-neural-networ
Question: <p>For a while, all classification tasks in natural language processing were based on simple RNN's, which operate in a very word-by-word order. Adding gating mechanisms increased ability to "look back", and the newer addition of context vectors which can train attention to different words during the task hav...
https://cs.stackexchange.com/questions/99987/are-there-any-neural-nlg-systems-which-dont-generate-in-left-to-right-order
Question: <p>I have read the GPT-1 paper, and my understanding is that it works as follows: <span class="math-container">$U$</span> is input tokens, <span class="math-container">$h_0=UW_e+W_p$</span>, <span class="math-container">$h_i=\text{transformer_block}(h_{i-1})$</span> and the output is a probability vector <spa...
https://cs.stackexchange.com/questions/160891/why-gpt-model-is-a-higher-order-hidden-markov-model
Question: <p>How were the <a href="https://openai.com/blog/better-language-models/" rel="nofollow noreferrer">GPT-2</a> token embeddings constructed? </p> <p>The authors mention that they used Byte Pair Encoding to construct their vocabulary. But BPE is a compression algorithm that returns a list of subword tokens tha...
https://cs.stackexchange.com/questions/116184/question-about-word-embeddings-in-a-specific-language-model-gpt-2
Question: <p>I am currently working my way through <em><a href="https://arxiv.org/abs/2005.14165" rel="nofollow noreferrer">Language Models are Few-Shot Learners </a></em>, the initial 75-page paper about <a href="https://en.wikipedia.org/wiki/GPT-3" rel="nofollow noreferrer">GPT-3</a>, the language learning model spaw...
https://cs.stackexchange.com/questions/156130/what-are-the-175-billion-parameters-used-in-the-gpt-3-language-model
Question: <p>In models like GPT-2, TXL and Grover, is there a good way to know which input weights (tokens) resulted in each token of the output? </p> Answer:
https://cs.stackexchange.com/questions/115948/is-there-a-way-to-connect-a-deep-language-model-output-to-input
Question: <p>I looked at the Wikipedia pages for <a href="https://en.wikipedia.org/wiki/Byte_pair_encoding" rel="nofollow noreferrer">Byte Pair Encoding (BPE)</a>, <a href="https://en.wikipedia.org/wiki/Sequitur_algorithm" rel="nofollow noreferrer">Sequitur</a>, and <a href="https://en.wikipedia.org/wiki/Re-Pair" rel="...
https://cs.stackexchange.com/questions/171396/difference-between-byte-pair-encoding-bpe-sequitur-and-re-pair
Question: <p>I am looking for a python NLP library that can generate a proper product description based on product features provided to it.</p> <p>Till now, i have tried <strong>transformers</strong> library and this is the code:</p> <pre><code>from transformers import pipeline def generate_description(specs): # C...
https://cs.stackexchange.com/questions/167540/generate-product-description-from-product-specifications
Question: <p>I am confused on the inputs of a Long-Short Term Memory (LSTM) for the slot filling task in Spoken Language Understanding. </p> <p>Before I worked on this, I implemented a language model with a Recurrent Neural Network (RNN) and then with a LSTM. The input to the RNN and LSTM language models was a one hot...
https://cs.stackexchange.com/questions/71032/what-are-the-inputs-to-an-lstm-for-slot-filling-task
Question: <p>One of the hyperparameters for LSTM networks is temperature. What is it?</p> Answer: <p><strong>Temperature</strong> is a hyperparameter of LSTMs (and neural networks generally) used to control the randomness of predictions by scaling the logits before applying softmax. For example, in TensorFlow’s Magent...
https://cs.stackexchange.com/questions/79241/what-is-temperature-in-lstm-and-neural-networks-generally
Question: <p>I have a time series that I want to predict with an LSTM. I am able to get very good results using 50 datapoints predicting 51, but I struggle to get any accuracy using something like 200 datapoints to predict 220. After an epoch, my network outputs 0 for all inputs. Is there a technique for predicting ...
https://cs.stackexchange.com/questions/60138/time-series-prediction-with-an-lstm
Question: <p>Last year, Ilya Sutskever and collaborators came out with a <a href="http://papers.nips.cc/paper/5346-sequence-to-sequence-learning-with-neural-networks.pdf" rel="nofollow">paper</a> about a recurrent LSTM net that learns sequence to sequence mappings for machine translation. It's somewhat surprising that ...
https://cs.stackexchange.com/questions/38144/hessian-free-instead-of-lstm-for-recurrent-net-machine-translation
Question: <p>Consider the following eqautions used in LSTM ( taken from Andrew ng's course on Sequential model)</p> <p>In an LSTM model, LSTM Cell has three inputs at any time step t</p> <ul> <li>Input(<span class="math-container">$X_t , a^{(t-1)}, C^{(t-1)})$</span>, <br><br> Here <span class="math-container">$X_t$</s...
https://cs.stackexchange.com/questions/129526/what-happens-if-i-swap-the-forget-gate-and-update-gate-in-lstm-model
Question: <p>Can someone explain the mathematical intuition behind the forget layer of an LSTM?</p> <p>So as far as I understand it, the cell state is essentially long term memory embedding (correct me if I'm wrong), but I'm also assuming it's a matrix. Then the forget vector is calculated by concatenating the previou...
https://cs.stackexchange.com/questions/118865/how-does-the-forget-layer-of-an-lstm-work
Question: <p>I am a CS undergraduate (but I don't know much about AI though, did not take any courses on it, and definitely nothing about NN until recently) who is about to do a school project in AI, so I pick a topics regarding grammar induction (of context-free language and perhaps some subset of context-sensitive la...
https://cs.stackexchange.com/questions/12871/intuitive-description-for-training-of-lstm-with-forget-gate-peephole
Question: <p>I am training a model for ham and spam classification using LSTM. I am indicating the spams as 0, and the hams as 1. However, the dataset has much more hams than spams, so I tend to get an output very close to 1. That means the output is almost always above 0.5. So I have two questions about this :</p> <p>...
https://cs.stackexchange.com/questions/134959/lstm-what-should-i-do-if-i-am-always-getting-an-output-too-close-to-one-value
Question: <p>I was just reading this paper: <a href="https://arxiv.org/pdf/1701.05923.pdf" rel="nofollow noreferrer">Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks Rahul Dey and Fathi M. Salem</a></p> <p>It seems to me that perhaps the architecture of LSTMs and GRUs are overly complicated. And that the sa...
https://cs.stackexchange.com/questions/83939/is-there-something-as-good-as-a-gru-or-lstm-but-simpler
Question: <p>For a recurrent neural network, the LSTM was a model of how the network worked. However, consider the case where an input was a long paragraph or even an article. <span class="math-container">$$c_1c_2...c_n$$</span> where <span class="math-container">$c_i$</span> were some characters. The LSTM would work a...
https://cs.stackexchange.com/questions/142325/how-long-can-the-short-memory-last-in-the-rnn
Question: <p>I've set up an RNN LSTM network in Java using DL4J as the library.</p> <p>I currently have 500 examples of positive text, and 500 examples of negative text.</p> <p>When I fitness the training data by first training all the negatives and then all the positives, my predictions only favor high positive resp...
https://cs.stackexchange.com/questions/113158/why-does-a-rnn-network-output-different-based-on-the-training-sequence
Question: <p>This question is about de paper <a href="https://arxiv.org/pdf/2103.15330.pdf" rel="nofollow noreferrer">Extending Multi-Sense Word Embedding to Phrases and Sentences for Unsupervised Semantic Applications</a>.</p> <p>I am interested in the transformer part of the paper and the main structures of the algor...
https://cs.stackexchange.com/questions/144325/how-can-i-modify-this-detail-in-the-article-extending-multi-sense-word-embeddi
Question: <p>I have a dataset that contains some strings. A numeric value is assigned to each string. I want to develop a machine learning (deep learning) model to get a string and predict its value. What neural network do you suggest for this model? Should I use RNN (LSTM)?</p> Answer: <p>Assuming the strings are var...
https://cs.stackexchange.com/questions/131318/which-neural-network-is-good-for-predecting-the-value-of-strings
Question: <p>I'm currently doing some research on signal processing and I got a dataset which includes the signal in itself and its &quot;translation&quot;.</p> <p><a href="https://i.sstatic.net/Bnp2P.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Bnp2P.png" alt="A signal and its translation" /></a></p>...
https://cs.stackexchange.com/questions/130020/signal-translation-with-seq2seq-model
Question: <p>Given cartesian coordinates $x$ and $y$ as input, can a neural network output $r$ and $\theta$, the equivalent polar coordinates?</p> <p>This would seem to require an approximation of the pythagorean theorem (which requires approximations of $x^2$ and $\sqrt{x}$) and $\sin$, $\cos$, or $\tan$ approximatio...
https://cs.stackexchange.com/questions/51090/can-an-artificial-neural-network-convert-from-cartesian-coordinates-to-polar-coo
Question: <p>I would like to train a RNN with LSTM cells in Tensorflow to predict the next word of a sequence. Words are N-length vectors of 0s and 1s. By looking at different tutorials, I saw that the input tensor has a shape like this</p> <pre><code>seq_input = tf.placeholder(tf.float32, [n_steps, batch_size, seq_wi...
https://cs.stackexchange.com/questions/68612/rnn-input-shape-for-sequence-generation-on-tensorflow
Question: <p>Most descriptions of modern RNNs present a "folded" characterisation, that is to say, a single cell with a loop back to itself transmitting the hidden state from one step to the next. However, in implementations the RNN is computed "unfolded", so a new cell is created for every step of the sequence up to s...
https://cs.stackexchange.com/questions/88891/do-all-the-cells-in-a-recurrent-neural-network-share-learned-parameters
Question: <p>I need to create an algorithm that is going to create a shakespearean sonnet for a specific theme. This theme should be generated out of twitter tweets that have some hashtag.</p> <p>My current idea goes like </p> <p><strong>While training:</strong></p> <ul> <li>break up sonnets and other kinds of poems...
https://cs.stackexchange.com/questions/92523/how-would-you-go-about-creating-a-algorithm-that-should-generate-a-shakespearean
Question: <p>What's the input to the decoder part of a sequence to sequence autoencoder? I've seen certain examples of such an autoencoder (using LSTM's more often than not) but am still unclear.</p> <ul> <li><p>For example, here in this often-cited <a href="https://pdfs.semanticscholar.org/6506/d13a84f90f8620fd028cfe...
https://cs.stackexchange.com/questions/69432/whats-the-input-to-the-decoder-in-a-sequence-to-sequence-autoencoder
Question: <p>In the paper by <a href="https://arxiv.org/pdf/1406.1078.pdf" rel="nofollow noreferrer">Cho et.al.</a>, section 2.3 details the equations for the modified LSTM cell in RNN used in the paper's implementation. The equation in question is :</p> <p><a href="https://i.sstatic.net/nRRBI.png" rel="nofollow norefe...
https://cs.stackexchange.com/questions/148739/clarification-about-rnn-encoder-decoder-equation
Question: <p>I'm thinking of doing a project on deepfake detection, but I'm not entirely sure if it is viable. Based on my understanding, how it works is that deepfake generation programs have a generative and discriminative network, and eventually after training, the systems reaches an equilibrium where the discrimina...
https://cs.stackexchange.com/questions/131326/is-deepfake-detection-viable
Question: <p>I'm trying to generate some history-dependent model with machine learning, whose underline physical model has a clear definition of its &quot;internal state variable&quot; (a state derived from historical inputs) and how this variable interacts with the inputs to get the outputs. Mathematically this reads:...
https://cs.stackexchange.com/questions/141532/can-we-supervise-on-the-hidden-states-of-rnn
Question: <p>Most of the discussion about RNN and LSTM alludes to the varying ability of different RNNs to capture &quot;long term dependency&quot;. However, most demonstrations use generated text to show the absence of long term dependency for vanilla RNN.</p> <p>Is there any way to explicitly measure the time depende...
https://cs.stackexchange.com/questions/129437/how-can-one-measure-the-time-dependency-of-an-rnn