<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Algorithms Q&amp;A - Recent questions and answers in Asymptotic Analysis</title>
<link>https://notexponential.com/qa/asymptotic-analysis</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: Analyze Triple Loop - j and k start with i^2 and j^2 respectively</title>
<link>https://notexponential.com/975/analyze-triple-loop-j-and-k-start-with-i-2-and-j-2-respectively?show=978#a978</link>
<description>&lt;p&gt;For the innermost loop to execute, the condition j&lt;sup&gt;2&amp;nbsp;&lt;/sup&gt;≤ n must hold, meaning j ≤ n&lt;sup&gt;0.5&lt;/sup&gt;.&lt;/p&gt;&lt;p&gt;In the middle loop, j&amp;nbsp;ranges from i&lt;sup&gt;2&lt;/sup&gt;&amp;nbsp;to n. Since j ≤ n&lt;sup&gt;0.5&lt;/sup&gt;, the range for j is from i&lt;sup&gt;2&lt;/sup&gt;&amp;nbsp;to n&lt;sup&gt;0.5&lt;/sup&gt;. For the middle loop to run, the condition i&lt;sup&gt;2&amp;nbsp;&lt;/sup&gt;≤ n&lt;sup&gt;0.5&lt;/sup&gt; must be satisfied, which implies i ≤ n&lt;sup&gt;0.25&lt;/sup&gt;.&lt;/p&gt;&lt;p&gt;Therefore, the outer loop runs from i = 1 to i = n&lt;sup&gt;0.25&lt;/sup&gt;.&lt;/p&gt;&lt;p&gt;Thus, the total time complexity is n&lt;sup&gt;0.25&lt;/sup&gt;⋅n&lt;sup&gt;0.5&lt;/sup&gt;⋅n =&lt;span style=&quot;font-family:sans-serif,Arial,Verdana,&amp;quot;Trebuchet MS&amp;quot;,&amp;quot;Apple Color Emoji&amp;quot;,&amp;quot;Segoe UI Emoji&amp;quot;,&amp;quot;Segoe UI Symbol&amp;quot;&quot;&gt;&amp;nbsp;&lt;/span&gt;O(n&lt;sup&gt;1.75&lt;/sup&gt;) or&amp;nbsp;O(n&lt;sup&gt;7/4&lt;/sup&gt;).&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/975/analyze-triple-loop-j-and-k-start-with-i-2-and-j-2-respectively?show=978#a978</guid>
<pubDate>Thu, 12 Dec 2024 07:30:05 +0000</pubDate>
</item>
<item>
<title>Answered: Analyze Double Loop - j starts from i*i</title>
<link>https://notexponential.com/976/analyze-double-loop-j-starts-from-i-i?show=977#a977</link>
<description>This is explained here: &lt;a href=&quot;https://www.youtube.com/watch?v=tngRU1Mp8M0&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=tngRU1Mp8M0&lt;/a&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/976/analyze-double-loop-j-starts-from-i-i?show=977#a977</guid>
<pubDate>Fri, 22 Nov 2024 15:12:26 +0000</pubDate>
</item>
<item>
<title>Answered: Highest sum of tree heights when one recoloring is allowed</title>
<link>https://notexponential.com/706/highest-sum-of-tree-heights-when-one-recoloring-is-allowed?show=963#a963</link>
<description>1.Initialization: &lt;br /&gt;
Make an array color_heights to hold the total height for each colour. Set current_height and maximum_height to zero. &lt;br /&gt;
&lt;br /&gt;
2.Iteration&lt;br /&gt;
Using a sliding window method, begin iterating through the trees.&lt;br /&gt;
Create two pointers, one to the left and one to the right, both pointing to the first tree.&lt;br /&gt;
&lt;br /&gt;
3.Window Expansion: &lt;br /&gt;
Increase the right pointer to expand the window to the right.&lt;br /&gt;
Add the newly inserted tree to color_heights and current_height.&lt;br /&gt;
&lt;br /&gt;
4.Recoloring Attempt: &lt;br /&gt;
Attempt a recoloring operation for the full window from colour C1 to colour C2. &lt;br /&gt;
Correctly update color_heights and current_height.&lt;br /&gt;
&lt;br /&gt;
5. Update Maximum Height:&lt;br /&gt;
Update max_height with the new value if the current contiguous height is greater than the &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;existing max_height.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
6. Window Size Control:&lt;br /&gt;
If the window size is greater than k, adjust the left cursor to keep the window size constant. Update the outgoing tree&amp;#039;s current_height and color_heights.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
7. Repeat Iteration:&lt;br /&gt;
Repeat steps 3-6 until the right pointer reaches the end of the trees.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
8. Result:&lt;br /&gt;
The final value of max_height represents the maximum contiguous height achievable after the recoloring operation.&lt;br /&gt;
&lt;br /&gt;
9. Time Complexity:&lt;br /&gt;
Because it only iterates through the trees once and the sliding window assures that each tree is considered at most twice, the technique has a time complexity of O(n), where n is the number of trees.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
Conclusion:&lt;br /&gt;
With a single recoloring operation, the algorithm uses a sliding window approach to maximize the total height of a continuous block of trees. Iterating through the trees, attempting recoloring, and adjusting the maximum height are all part of the step-by-step procedure. The temporal complexity of the algorithm is O(n), where n is the number of trees.</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/706/highest-sum-of-tree-heights-when-one-recoloring-is-allowed?show=963#a963</guid>
<pubDate>Fri, 22 Dec 2023 17:32:51 +0000</pubDate>
</item>
<item>
<title>Answered: outer loop until log n, inner loop exponential increase</title>
<link>https://notexponential.com/579/outer-loop-until-log-n-inner-loop-exponential-increase?show=958#a958</link>
<description>&lt;p&gt;1. Let the inner loop run &lt;em&gt;&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;x&lt;/span&gt;&lt;/em&gt; time&lt;/p&gt;&lt;p&gt;Since k = k&lt;sup&gt;1.3&lt;/sup&gt; while k &amp;lt; n:&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;p&gt;5&lt;sup&gt;(1.3)^&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt; &lt;/sup&gt;= n&lt;/p&gt;&lt;p&gt;log&lt;sub&gt;5&amp;nbsp;&lt;/sub&gt;n = 1.3&lt;em&gt;&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;&lt;sup&gt;x&lt;/sup&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;x &lt;/span&gt;&lt;/em&gt;= log&lt;sub&gt;1.3&lt;/sub&gt;log&lt;sub&gt;5&lt;/sub&gt; n&lt;/p&gt;&lt;p&gt;After ignoring the constants, the running time of the inner loop is &lt;strong&gt;loglog n&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;2. Let the outer loop run &lt;span style=&quot;font-family:Trebuchet MS, Helvetica, sans-serif&quot;&gt;&lt;em&gt;y&lt;/em&gt;&lt;/span&gt;&amp;nbsp;time&lt;/p&gt;&lt;p&gt;Since&amp;nbsp;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;j = 1.3 * j while&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;j &amp;lt; log n:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;5 * 1.3&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;&lt;em&gt;&lt;sup&gt;y&lt;/sup&gt;&lt;/em&gt;&lt;/span&gt; = log n&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;1.3&lt;/span&gt;&lt;span style=&quot;font-family:&amp;quot;Trebuchet MS&amp;quot;,Helvetica,sans-serif; font-size:14.5349px&quot;&gt;&lt;em&gt;&lt;sup&gt;y&lt;/sup&gt;&lt;/em&gt;&lt;/span&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;&amp;nbsp;= (log n) / 5&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family:Trebuchet MS,Helvetica,sans-serif&quot;&gt;y&lt;/span&gt;&lt;/em&gt; = log&lt;sub&gt;1.3&lt;/sub&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family:monospace; font-size:14.5349px&quot;&gt;(log n) / 5&lt;/span&gt;&lt;/p&gt;&lt;p&gt;After ignoring the constants, the running time of the outer loop is &lt;strong&gt;loglog n&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;3. Since&lt;span style=&quot;color:#374151; font-family:Söhne,ui-sans-serif,system-ui,-apple-system,&amp;quot;Segoe UI&amp;quot;,Roboto,Ubuntu,Cantarell,&amp;quot;Noto Sans&amp;quot;,sans-serif,&amp;quot;Helvetica Neue&amp;quot;,Arial,&amp;quot;Apple Color Emoji&amp;quot;,&amp;quot;Segoe UI Emoji&amp;quot;,&amp;quot;Segoe UI Symbol&amp;quot;,&amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse:preserve&quot;&gt; the inner loop runs &lt;em&gt;loglog n &lt;/em&gt;times &lt;/span&gt;in&amp;nbsp;&lt;span style=&quot;color:#374151; font-family:Söhne,ui-sans-serif,system-ui,-apple-system,&amp;quot;Segoe UI&amp;quot;,Roboto,Ubuntu,Cantarell,&amp;quot;Noto Sans&amp;quot;,sans-serif,&amp;quot;Helvetica Neue&amp;quot;,Arial,&amp;quot;Apple Color Emoji&amp;quot;,&amp;quot;Segoe UI Emoji&amp;quot;,&amp;quot;Segoe UI Symbol&amp;quot;,&amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse:preserve&quot;&gt;each iteration of the outer loop&lt;/span&gt;&lt;span style=&quot;color:#374151; font-family:Söhne,ui-sans-serif,system-ui,-apple-system,&amp;quot;Segoe UI&amp;quot;,Roboto,Ubuntu,Cantarell,&amp;quot;Noto Sans&amp;quot;,sans-serif,&amp;quot;Helvetica Neue&amp;quot;,Arial,&amp;quot;Apple Color Emoji&amp;quot;,&amp;quot;Segoe UI Emoji&amp;quot;,&amp;quot;Segoe UI Symbol&amp;quot;,&amp;quot;Noto Color Emoji&amp;quot;; white-space-collapse:preserve&quot;&gt;, t&lt;/span&gt;he overall running time&amp;nbsp;is:&lt;/p&gt;&lt;p&gt;loglog&amp;nbsp;n *&amp;nbsp;loglog&amp;nbsp;n =&amp;nbsp;log(log(n)) log(log(n)) &lt;strong&gt;= O(log&lt;sup&gt;2&lt;/sup&gt;(log(n)))&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/579/outer-loop-until-log-n-inner-loop-exponential-increase?show=958#a958</guid>
<pubDate>Mon, 18 Dec 2023 07:29:55 +0000</pubDate>
</item>
<item>
<title>Answered: Solve the recurrence Relation T(n)=T(n/5)+T(7n/10)+(n^2)</title>
<link>https://notexponential.com/428/solve-the-recurrence-relation-t-n-t-n-5-t-7n-10-n-2?show=925#a925</link>
<description>&lt;p&gt;Using Estimation Method, we get&lt;/p&gt;&lt;p&gt;R(n) = 2T(n/5) + n&lt;sup&gt;2&lt;/sup&gt;&amp;nbsp; &amp;amp; S(n) = 2T(7n/10) + n&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;&lt;p&gt;Applying Masters Theorem to both equations, we get&lt;/p&gt;&lt;p&gt;R(n) = O(n&lt;sup&gt;2&lt;/sup&gt;)&amp;nbsp;&amp;nbsp;&amp;amp; S(n) = O(n&lt;sup&gt;2&lt;/sup&gt;)&amp;nbsp;&lt;/p&gt;&lt;p&gt;Hence, the time complexity for T(n) is O(n&lt;sup&gt;2&lt;/sup&gt;).&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/428/solve-the-recurrence-relation-t-n-t-n-5-t-7n-10-n-2?show=925#a925</guid>
<pubDate>Tue, 12 Dec 2023 09:19:52 +0000</pubDate>
</item>
<item>
<title>Answered: For-While Nested Loops Time Complexity - Inner Loop increments by n^1/3</title>
<link>https://notexponential.com/277/for-while-nested-loops-time-complexity-inner-loop-increments?show=922#a922</link>
<description>&lt;p&gt;&lt;u&gt;Inner Loop&lt;/u&gt;:&lt;/p&gt;&lt;p&gt;k goes till n and increments by n&lt;sup&gt;1/3&lt;/sup&gt; in every iteration&lt;br&gt;k, k+n&lt;sup&gt;1/3&lt;/sup&gt;, k+n&lt;sup&gt;1/3&lt;/sup&gt;+n&lt;sup&gt;1/3&lt;/sup&gt; ...... k+(n&lt;sup&gt;1/3&lt;/sup&gt;)x&lt;/p&gt;&lt;p&gt;equating this to n, we get &lt;strong&gt;x = O(n&lt;sup&gt;2/3&lt;/sup&gt;)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;Outer Loop&lt;/u&gt;:&lt;/p&gt;&lt;p&gt;j goes till n and increments by 1 with every iteration&lt;/p&gt;&lt;p&gt;Therefore, time complexity of the outer loop is &lt;strong&gt;O(n).&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Time Complexity = n*n&lt;sup&gt;2/3&lt;/sup&gt; = n&lt;sup&gt;(1+2/3)&lt;/sup&gt; = &lt;strong&gt;O(n&lt;sup&gt;5/3&lt;/sup&gt;).&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/277/for-while-nested-loops-time-complexity-inner-loop-increments?show=922#a922</guid>
<pubDate>Tue, 12 Dec 2023 08:11:27 +0000</pubDate>
</item>
<item>
<title>Answered: Solve this recurrence using master theorem: T(n) = 2 T(n/2) + n^0.75</title>
<link>https://notexponential.com/831/solve-this-recurrence-using-master-theorem-t-n-2-t-n-2-n-0-75?show=909#a909</link>
<description>Using Masters theorem:&lt;br /&gt;
&lt;br /&gt;
A = 2, B = 2, K = 0.75(power of n)&lt;br /&gt;
&lt;br /&gt;
log 2 (2) &amp;gt; K (Case 1)&lt;br /&gt;
&lt;br /&gt;
T(n) = n ^ log 2 (2) == Theta(n)</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/831/solve-this-recurrence-using-master-theorem-t-n-2-t-n-2-n-0-75?show=909#a909</guid>
<pubDate>Mon, 11 Dec 2023 04:02:37 +0000</pubDate>
</item>
<item>
<title>Answered: Given f(n) = o(g(n)), prove that 2^f(n) = o(2^g(n))</title>
<link>https://notexponential.com/261/given-f-n-o-g-n-prove-that-2-f-n-o-2-g-n?show=892#a892</link>
<description>f(n) = o(g(n)) means 0&amp;lt;= f(n) &amp;lt; g(n) for all n&amp;gt;= n0&lt;br /&gt;
&lt;br /&gt;
as f(n) is always less than g(n) and both are positive&lt;br /&gt;
&lt;br /&gt;
2^f(n) &amp;lt; c. 2^g(n) for all n &amp;gt;= n0 and c is a constant&lt;br /&gt;
&lt;br /&gt;
Therefore we can say that 2^f(n) = o (2^g(n)) when f(n) = o(g(n))</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/261/given-f-n-o-g-n-prove-that-2-f-n-o-2-g-n?show=892#a892</guid>
<pubDate>Sun, 10 Dec 2023 21:54:15 +0000</pubDate>
</item>
<item>
<title>Answered: Prove Ө(log 1 + log2 + log3 + log4 +... + logn) = Ө(n log n)</title>
<link>https://notexponential.com/284/prove-%D3%A9-log-1-log2-log3-log4-logn-%D3%A9-n-log-n?show=891#a891</link>
<description>log1 + log 2 + log 3 + ...... + log n = log ( 1*2*3 .... *n) = log(n!)&lt;br /&gt;
&lt;br /&gt;
log1 + log 2 + log 3 + ...... + log n &amp;nbsp;&amp;lt;= log n + log n + log n + ..... + log n&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;= n log n&lt;br /&gt;
&lt;br /&gt;
log1 + log 2 + log 3 + ...... + log n &amp;nbsp;= O(n log n)&lt;br /&gt;
&lt;br /&gt;
log1 + log 2 + log 3 + ...... + log n &amp;nbsp;&amp;gt;= n/2 log n/2&lt;br /&gt;
&lt;br /&gt;
log1 + log 2 + log 3 + ...... + log n &amp;nbsp;= big-omega(n log n)&lt;br /&gt;
&lt;br /&gt;
so, log1 + log 2 + log 3 + ...... + log n &amp;nbsp;= Theta(n log n)</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/284/prove-%D3%A9-log-1-log2-log3-log4-logn-%D3%A9-n-log-n?show=891#a891</guid>
<pubDate>Sun, 10 Dec 2023 21:49:07 +0000</pubDate>
</item>
<item>
<title>Answered: Asymptotically compare 14 T(n/4) + O(n) and 7 R(n/2) + O(n).</title>
<link>https://notexponential.com/770/asymptotically-compare-14-t-n-4-o-n-and-7-r-n-2-o-n?show=877#a877</link>
<description>Using masters theorem: a=14 b=4 &lt;br /&gt;
n^log_4(14) = n^1.9 &amp;gt; n&lt;br /&gt;
T(n) = O(n^log_4(14))&lt;br /&gt;
&lt;br /&gt;
Using masters theorem: a=7 b=2&lt;br /&gt;
n^log_2(7) = n^2.8 &amp;gt; n&lt;br /&gt;
R(n) = O(n^log_2(7))&lt;br /&gt;
&lt;br /&gt;
T(n) = o(R(n) as n^1.9 &amp;lt; n^2.8</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/770/asymptotically-compare-14-t-n-4-o-n-and-7-r-n-2-o-n?show=877#a877</guid>
<pubDate>Sat, 09 Dec 2023 18:48:47 +0000</pubDate>
</item>
<item>
<title>Answered: Nested loop analysis, outer loop grows by sqrt n, inner randomly</title>
<link>https://notexponential.com/839/nested-loop-analysis-outer-loop-grows-by-sqrt-inner-randomly?show=873#a873</link>
<description>&lt;p&gt;Let&#039;s analyze the time complexity:&lt;/p&gt;&lt;p&gt;1. &lt;strong&gt;Outer Loop (&lt;code&gt;j&lt;/code&gt; Loop)&lt;/strong&gt;: The loop variable &lt;code&gt;j&lt;/code&gt; starts at 1 and increases by 0.1 * sq(n)  in each iteration. The number of iterations for the outer loop is approximately 10 * sq(n).&lt;/p&gt;&lt;p&gt;2. &lt;strong&gt;Inner Loop (&lt;code&gt;k&lt;/code&gt; Loop)&lt;/strong&gt;: This loop runs until &lt;code&gt;k&lt;/code&gt; is less than &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;log⁡n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;. The increase in &lt;code&gt;k&lt;/code&gt; depends on a random condition:&lt;/p&gt;&lt;p&gt;If &lt;code&gt;random() &amp;lt; 0.5&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt; is doubled.Otherwise, &lt;code&gt;k&lt;/code&gt; increases by 1.&lt;/p&gt;&lt;p&gt;The doubling of &lt;code&gt;k&lt;/code&gt; will rapidly increase its value, reaching &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;log⁡n&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;in &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;/span&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span style=&quot;margin-right:0.02778em&quot; class=&quot;mathnormal mord&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mathnormal mord&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;steps because doubling represents an exponential growth. The increment by 1 is less significant compared to the doubling and will not dominate the time complexity. Therefore, the average case for the inner loop is dominated by the case where &lt;code&gt;k&lt;/code&gt; is doubled, giving us &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;/span&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span style=&quot;margin-right:0.02778em&quot; class=&quot;mathnormal mord&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mathnormal mord&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; iterations.&lt;/p&gt;&lt;p&gt;3. &lt;strong&gt;Overall Complexity&lt;/strong&gt;: The total time complexity is the product of the number of iterations of each loop, which gives us:&lt;/p&gt;&lt;p&gt;10 * sq(n) * &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mathnormal mord&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;) = O(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;sq(n) * &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mathnormal mord&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Therefore, the time complexity of the given code can be approximated as &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;mclose&quot;&gt;O(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;sq(n) * &lt;span class=&quot;math math-inline&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span aria-hidden=&quot;true&quot; class=&quot;katex-html&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.01389em&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mathnormal mord&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/839/nested-loop-analysis-outer-loop-grows-by-sqrt-inner-randomly?show=873#a873</guid>
<pubDate>Sat, 09 Dec 2023 16:43:03 +0000</pubDate>
</item>
<item>
<title>Answered: Use the limit method to prove the asymptotic relation between these 3 functions</title>
<link>https://notexponential.com/767/limit-method-prove-asymptotic-relation-between-functions?show=781#a781</link>
<description>&lt;p&gt;&lt;strong style=&quot;font-family:Helvetica,Arial,sans-serif; font-size:14px&quot;&gt;lim (n --&amp;gt; infinity)&amp;nbsp; n&amp;nbsp;/ 2n tends to 1/2 ; n = theta(2n)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong style=&quot;font-family:Helvetica,Arial,sans-serif; font-size:14px&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;strong style=&quot;font-family:Helvetica,Arial,sans-serif; font-size:14px&quot;&gt;lim (n --&amp;gt; infinity)&amp;nbsp; n&amp;nbsp;/ n^2 , it will be&amp;nbsp;1/n and tends to 0&amp;nbsp;; n = o(n^2)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong style=&quot;font-family:Helvetica,Arial,sans-serif; font-size:14px&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;strong style=&quot;font-family:Helvetica,Arial,sans-serif; font-size:14px&quot;&gt;lim (n --&amp;gt; infinity)&amp;nbsp; 2n&amp;nbsp;/&amp;nbsp;n^2 , it will be&amp;nbsp;1/n and tends to 0&amp;nbsp;; 2n = o(n^2)&lt;/strong&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/767/limit-method-prove-asymptotic-relation-between-functions?show=781#a781</guid>
<pubDate>Tue, 20 Dec 2022 03:59:53 +0000</pubDate>
</item>
<item>
<title>Answered: Time Complexity 0.25 * n and k +=k</title>
<link>https://notexponential.com/513/time-complexity-0-25-n-and-k-k?show=677#a677</link>
<description>j=kn&lt;br /&gt;
&lt;br /&gt;
n totally</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/513/time-complexity-0-25-n-and-k-k?show=677#a677</guid>
<pubDate>Thu, 02 May 2019 06:19:23 +0000</pubDate>
</item>
<item>
<title>Answered: The executive time of program in eclipse seems to be randomly when the times are not very large</title>
<link>https://notexponential.com/421/executive-time-program-eclipse-seems-randomly-times-large?show=669#a669</link>
<description>Since you know the bigger the better, you can be as big as possible. Maybe you can try a few small numbers and then find the law. Hahaha</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/421/executive-time-program-eclipse-seems-randomly-times-large?show=669#a669</guid>
<pubDate>Thu, 02 May 2019 05:32:21 +0000</pubDate>
</item>
<item>
<title>Answered: Solve the Recurrence Relation: T(n) = T(n/4) + T(3n/4) + n^2</title>
<link>https://notexponential.com/557/solve-the-recurrence-relation-t-n-t-n-4-t-3n-4-n-2?show=558#a558</link>
<description>&lt;p&gt;We can solve this using substitution method.&lt;/p&gt;&lt;p&gt;Claim: T(n) &amp;lt;= c n^2&lt;/p&gt;&lt;p&gt;IH: We assume that claim is true for all values of n &amp;lt; m.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Inductive Step: T(m) = T(m/4) + T(3m/4) + m^2&lt;/p&gt;&lt;p&gt;&amp;lt;= cm^2/16 + c 9 m^2 / 16 + m^2&lt;/p&gt;&lt;p&gt;= cm^2 (1/16&amp;nbsp;+ 9/16 + 1/c)&lt;/p&gt;&lt;p&gt;= c m^2 (10/16 + 1/c)&lt;/p&gt;&lt;p&gt;&amp;lt;= c m^2&amp;nbsp; &amp;nbsp;as long as 1/c &amp;lt;= 6/16.&amp;nbsp; &amp;nbsp;So, we can choose a value of c &amp;gt;= 16/6&amp;nbsp;and the rest of the math holds up.&lt;/p&gt;&lt;p&gt;QED.&lt;/p&gt;&lt;p&gt;Therefore, by PMI, T(n) &amp;lt;= c n^2, that is, T(n) = O(n^2).&lt;/p&gt;&lt;h2&gt;Alternative Proof:&lt;/h2&gt;&lt;p&gt;&amp;nbsp;Follow the same logic, but instead of c, use a larger constant such as 10.&lt;/p&gt;&lt;p&gt;T(n) = 10 n^2/16 +&amp;nbsp; 10 9n^2/16 + n^2.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;= 10 n^2.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/557/solve-the-recurrence-relation-t-n-t-n-4-t-3n-4-n-2?show=558#a558</guid>
<pubDate>Tue, 08 May 2018 03:12:34 +0000</pubDate>
</item>
<item>
<title>Answered: Time Complexity (3 loops with gcd)</title>
<link>https://notexponential.com/512/time-complexity-3-loops-with-gcd?show=523#a523</link>
<description>&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;Normally, these three loops runs O(n) respectively, making the time complexity O(n&lt;sup&gt;2&lt;/sup&gt;). &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;However, consider the second loop, where there is &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If (gcd(i,j) == 1) {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = n&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;Then, since there is gcd(i,j) == 1, the loop ends. Since the GCD of any two consecutive integer is 1, the second loop would always ends when j == i + 1. Thus, the second loop runs O(1) times only.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;span style=&quot;color:windowtext&quot;&gt;As a result, the time complexity is&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:Arial,Helvetica,sans-serif&quot;&gt;&lt;strong&gt;&lt;u&gt;T(n) = O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/512/time-complexity-3-loops-with-gcd?show=523#a523</guid>
<pubDate>Tue, 06 Mar 2018 14:49:31 +0000</pubDate>
</item>
<item>
<title>Answered: Time Complexity increasing by n^(1/3)log(n)</title>
<link>https://notexponential.com/509/time-complexity-increasing-by-n-1-3-log-n?show=510#a510</link>
<description>&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;strong&gt;Outer loop Analysis (for j)&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;j goes from 2 to n, multiplied by a constant at ever stype&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;n = (2 * sqrt(5)) * sqrt(5)).... = &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;Therefore, number of steps = 2log[5,(n/2)] = O(log(n))&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;
&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;strong&gt;Inner loop Analysis (for k) &lt;/strong&gt;

n = k * n^(1/3)* log(n) &lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;Number of steps: O(n^(2/3)/log(n))&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;Overall:&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;O(log(n) * n^(2/3)/log(n))&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;
&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-size:14px&quot;&gt;= O(n^(2/3))&lt;/span&gt;
&lt;/pre&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/509/time-complexity-increasing-by-n-1-3-log-n?show=510#a510</guid>
<pubDate>Sun, 04 Mar 2018 19:07:54 +0000</pubDate>
</item>
<item>
<title>Answered: What&#039;s the time complexity when j increases by j += log(j+5)?</title>
<link>https://notexponential.com/479/whats-the-time-complexity-when-j-increases-by-j-log-j-5?show=480#a480</link>
<description>&lt;p&gt;One way to think about this question is to break the range that j starts from and ends at, into two parts:&lt;br&gt;&lt;br&gt;j starts from 1, reaches n.&lt;br&gt;&lt;br&gt;Let us break this into two separate journeys:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Part 1: j goes from 1 to sqrt(n)&lt;/li&gt;&lt;li&gt;Part 2: j goes from sqrt(n) to n.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Let us analyze these two separately.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Part 1 - This can not take more than O(sqrt(n)) time&lt;/li&gt;&lt;li&gt;Part 2 - This can not take more than O(n / log (sqrt(n))) time.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;We observe that O(n/log (sqrt(n))) = O( 2 n / log n) = O(n / log n) time.&lt;br&gt;&lt;br&gt;Therefore, total time = O(sqrt(n)) + O(n/log n), that is, O(n/log n)&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/479/whats-the-time-complexity-when-j-increases-by-j-log-j-5?show=480#a480</guid>
<pubDate>Wed, 13 Sep 2017 10:45:35 +0000</pubDate>
</item>
<item>
<title>Answered: Time Complexity Analysis - Nested Loops - Inner Increments by sqrt(k)</title>
<link>https://notexponential.com/467/time-complexity-analysis-nested-loops-inner-increments-sqrt?show=470#a470</link>
<description>&lt;p&gt;Outer loop runs only 4 times. So, we could just start with the first iteration of the loop where k starts with 1.&amp;nbsp; Needs to get to n.&amp;nbsp; Then we could multiply the answer by 4, and that would be the worst case.&lt;/p&gt;&lt;p&gt;So, effectively, the question is:&lt;/p&gt;&lt;pre&gt;// In this code, how many times does the while loop run?
k = 1
while (k &amp;lt; n){
    k += sqrt(k)
}&lt;/pre&gt;&lt;p&gt;One can conclude that that only takes THETA(sqrt(n)) time, using two different arguments.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;We claim that this must be OMEGA(sqrt(n)), because k needs to go from 1 to n, and it never increments by anything larger than sqrt(n). &amp;nbsp;Therefore, it must require at least sqrt(n) steps.&lt;/li&gt;&lt;li&gt;We claim that this must be BIG OH(sqrt(n)), because of the following:&lt;ul&gt;&lt;li&gt;Number of steps taken when k goes from n/4 to n is at most 2*sqrt(n) because square root of k is at least sqrt(n) / 2.&lt;/li&gt;&lt;li&gt;Similarly number of iterations of inner loop, when k moves from n/16 to n/4 &amp;nbsp;= &amp;nbsp;sqrt(n), because square root of k is at least sqrt(n)/4.&lt;/li&gt;&lt;li&gt;Similarly for k to go from n/64 to n/16 &amp;nbsp;= &amp;nbsp;sqrt(n) / 2&lt;/li&gt;&lt;li&gt;Summing up all together = &amp;nbsp;sqrt(n) * [ 2 + 1 + 0.5 + 0.25 + .... ] &amp;nbsp; &amp;lt;= 4*sqrt(n)&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color:#FFFF00&quot;&gt;[Thanks to Piyush Gupta for his suggestion in simplification of big oh analysis.]&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/467/time-complexity-analysis-nested-loops-inner-increments-sqrt?show=470#a470</guid>
<pubDate>Wed, 12 Jul 2017 21:17:11 +0000</pubDate>
</item>
<item>
<title>Answered: log(n!) = Theta(nlogn)</title>
<link>https://notexponential.com/459/log-n-theta-nlogn?show=462#a462</link>
<description>log(n!) = log(1) + log(2) + ... + log(n-1) + log(n)&lt;br /&gt;
&lt;br /&gt;
You can get the upper bound by&lt;br /&gt;
&lt;br /&gt;
log(1) + log(2) + ... + log(n) &amp;lt;= log(n) + log(n) + ... + log(n)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= n*log(n)&lt;br /&gt;
&lt;br /&gt;
And you can get the lower bound by doing a similar thing after throwing away the first half of the sum:&lt;br /&gt;
&lt;br /&gt;
log(1) + ... + log(n/2) + ... + log(n) &amp;gt;= log(n/2) + ... + log(n)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt;= log(n/2) + ... + log(n/2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= n/2 * log(n/2)</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/459/log-n-theta-nlogn?show=462#a462</guid>
<pubDate>Thu, 15 Jun 2017 16:57:19 +0000</pubDate>
</item>
<item>
<title>Answered: Solve the recurrence relation: T(n)=T(n/2)+T(n^0.5)+n</title>
<link>https://notexponential.com/436/solve-the-recurrence-relation-t-n-t-n-2-t-n-0-5-n?show=448#a448</link>
<description>Simple guess that anyone can make is that T(n) = O(n). This can be proved using PMI.&lt;br /&gt;
&lt;br /&gt;
Further, since T(n) includes n, we know that T(n) = Big Omega(n). &amp;nbsp;Therefore, we can reach the conclusion that T(n) = Theta(n).</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/436/solve-the-recurrence-relation-t-n-t-n-2-t-n-0-5-n?show=448#a448</guid>
<pubDate>Mon, 20 Mar 2017 21:25:29 +0000</pubDate>
</item>
<item>
<title>Answered: How to get the time complexity of these algorithms, in terms of n in quiz 2?</title>
<link>https://notexponential.com/434/how-to-get-the-time-complexity-of-these-algorithms-terms-quiz?show=435#a435</link>
<description>&lt;p&gt;My answer would be O(logn * log log n) for #1 and O(n&lt;sup&gt;5/3&lt;/sup&gt;) for #2. &amp;nbsp;I don&#039;t know about others, I have an alternative way to quantify time complexity: the total times for executing each line of code.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Explanation:&amp;nbsp;&lt;/p&gt;&lt;p&gt;#1: for the inner loop&lt;/p&gt;&lt;p&gt;while (k &amp;lt; n) {&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Sum += 1; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;k = k * sqrt(k); &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/p&gt;&lt;p&gt;How many iterations will be executed depends on value k, in this loop, k starts as 2, goes with 2&lt;sup&gt;&lt;span style=&quot;font-size:10.8333px&quot;&gt;3/2&lt;/span&gt;&lt;/sup&gt;&lt;span style=&quot;font-size:10.8333px&quot;&gt;, (2&lt;sup&gt;3/2&lt;/sup&gt;)&lt;sup&gt;3/2&lt;/sup&gt;, .... , 2&lt;sup&gt;(3/2)^z&lt;/sup&gt;, until it becomes greater than&amp;nbsp;n. the value z here is the times of iteration, assume&amp;nbsp;2&lt;/span&gt;&lt;sup&gt;(3/2)^z&lt;/sup&gt;&amp;nbsp;= n, there exists z = log log n.&lt;/p&gt;&lt;p&gt;For the outer loop,&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (j &amp;lt; n) {&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;k = 2;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//inner loop, takes log log n&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;j += 5*j/3;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/p&gt;&lt;p&gt;Similarly, j starts as 2, goes with 2, 5/3 * 2, (5/3)&lt;sup&gt;2&lt;/sup&gt;&amp;nbsp;* 2, ...., (5/3)&lt;sup&gt;z&lt;/sup&gt;&amp;nbsp;* 2, until it becomes&amp;nbsp;&lt;span style=&quot;font-size:10.8333px&quot;&gt;greater than&amp;nbsp;n. the value z = log&lt;sub&gt;5/3&lt;/sub&gt;n/2,&amp;nbsp;&lt;/span&gt;approximately, log n.&lt;/p&gt;&lt;p&gt;The time complexity of the total algorithm is the product of each loop, which is O(log n * log log n).&lt;/p&gt;&lt;p&gt;#2: &lt;strong&gt;I&amp;nbsp;take&amp;nbsp;&lt;span style=&quot;font-family:calibri; font-size:11pt&quot;&gt;k += n&lt;/span&gt;&lt;span style=&quot;font-family:calibri; font-size:7pt&quot;&gt;1/3 &amp;nbsp;&lt;/span&gt;as&amp;nbsp;&lt;span style=&quot;font-family:calibri; font-size:14.6667px&quot;&gt;k +=&amp;nbsp;&lt;/span&gt;n&lt;/strong&gt;&lt;sup&gt;&lt;strong&gt;1/3&lt;/strong&gt;&lt;/sup&gt;. Again, for inner loop, k starts as j, goes with j + n&lt;sup&gt;1/3&lt;/sup&gt;, j + 2 * n&lt;sup&gt;1/3&lt;/sup&gt;, ... , j + z * n&lt;sup&gt;1/3&amp;nbsp;&lt;/sup&gt;&lt;span style=&quot;font-size:10.8333px&quot;&gt;until it becomes greater than&amp;nbsp;n. (omit constant z) the value z = n&lt;sup&gt;2/3&lt;/sup&gt;. For the outer loop. j starts as 1 to n, so z = n. For the whole algorithm , it&#039;s O(n&lt;sup&gt;5/3&lt;/sup&gt;).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:10.8333px&quot;&gt;We can&#039;t&amp;nbsp;&lt;/span&gt;accurately&amp;nbsp;calculate each algorithm&amp;nbsp;manually, because constant will be omitted during the process, the base number of log will always count as 2, etc. However, we can know the order of&amp;nbsp;magnitude&amp;nbsp;after doing some simple math, which is the meaning of O().&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/434/how-to-get-the-time-complexity-of-these-algorithms-terms-quiz?show=435#a435</guid>
<pubDate>Tue, 21 Feb 2017 01:23:32 +0000</pubDate>
</item>
<item>
<title>Answered: Loop i through log n incremented by constant multiplication</title>
<link>https://notexponential.com/394/loop-i-through-log-incremented-by-constant-multiplication?show=396#a396</link>
<description>&lt;p&gt;So let&#039;s say there are k steps taken in the program.&lt;/p&gt;&lt;p&gt;1.3^k = log n&lt;/p&gt;&lt;p&gt;k = log&lt;sub&gt;1.3&lt;/sub&gt;log n&lt;/p&gt;&lt;p&gt;Time complexity is O(loglog n).&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/394/loop-i-through-log-incremented-by-constant-multiplication?show=396#a396</guid>
<pubDate>Mon, 05 Dec 2016 02:37:48 +0000</pubDate>
</item>
<item>
<title>Answered: Asymptotic Analysis - Triple Loop - k starts from j^2</title>
<link>https://notexponential.com/181/asymptotic-analysis-triple-loop-k-starts-from-j-2?show=378#a378</link>
<description>&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://s16.postimg.org/sxgrkect1/ans.jpg&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#FFFFFF&quot;&gt;&lt;span style=&quot;font-family:helvetica,arial,sans-serif; font-size:14px&quot;&gt;Please provide more information - at least 12 characters&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/181/asymptotic-analysis-triple-loop-k-starts-from-j-2?show=378#a378</guid>
<pubDate>Sun, 06 Nov 2016 01:57:48 +0000</pubDate>
</item>
<item>
<title>Time Complexity - Recursive function - Two recursive calls, and double nested loop</title>
<link>https://notexponential.com/348/complexity-recursive-function-recursive-calls-double-nested</link>
<description>&lt;pre&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;function T(int n) {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int n1 = T((n-1)/4) &lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int n2 = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;T((n+1)/4) &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int sum = 0 &lt;/span&gt;

&lt;span style=&quot;font-size:medium&quot;&gt;  for i = 1 to n {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;    for j = 1 to n {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;      sum+=n1*i + n2*j&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;    }&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  }&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  return sum&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;T(n) =&amp;nbsp;?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/348/complexity-recursive-function-recursive-calls-double-nested</guid>
<pubDate>Wed, 05 Oct 2016 16:46:20 +0000</pubDate>
</item>
<item>
<title>Time complexity of recursive function - Single recursive call of size n/3 and n^2 loop</title>
<link>https://notexponential.com/342/time-complexity-recursive-function-single-recursive-call</link>
<description>&lt;pre&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;function T(int n) {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int n1 = 2T(n/3) + 5&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int n2 = 2*n1*n1&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  int sum = 0 &lt;/span&gt;

&lt;span style=&quot;font-size:medium&quot;&gt;  for i = 1 to n {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;    for j = 1 to n {&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;      sum+=n1*i + n2*j&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;    }&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  }&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;  return sum&lt;/span&gt;
&lt;span style=&quot;font-size:medium&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;// Assume T(1) = 1&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:medium&quot;&gt;T(n) =&amp;nbsp;?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/342/time-complexity-recursive-function-single-recursive-call</guid>
<pubDate>Mon, 03 Oct 2016 15:24:17 +0000</pubDate>
</item>
<item>
<title>MT for T(n) = 2T(n/2) + n^2 log n</title>
<link>https://notexponential.com/323/mt-for-t-n-2t-n-2-n-2-log-n</link>
<description>How do we use MT to solve T(n) = 2T(n/2) + n^2 log n?&lt;br /&gt;
&lt;br /&gt;
c = 2 &amp;gt; log_b(a) here, but f(n) = Theta (n^2 log n) instead of purely Theta(n^2).&lt;br /&gt;
&lt;br /&gt;
Besides, for T(n) = 2T(n/2) + n logn, f(n) / n^log_b(a) = log n, there is a non-polynomial difference right? Then why can we use MT for it?</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/323/mt-for-t-n-2t-n-2-n-2-log-n</guid>
<pubDate>Thu, 22 Sep 2016 15:25:55 +0000</pubDate>
</item>
<item>
<title>Recurrence relation : T(n) = T(n/3) + 2 T(2n/3) + n</title>
<link>https://notexponential.com/293/recurrence-relation-t-n-t-n-3-2-t-2n-3-n</link>
<description>Solve the recurrence relation:T(n)=T(n/3)+2T(2n/3)+n.</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/293/recurrence-relation-t-n-t-n-3-2-t-2n-3-n</guid>
<pubDate>Fri, 16 Sep 2016 00:44:00 +0000</pubDate>
</item>
<item>
<title>Given f(n) = o(g(n)), show that it is not necessary that  log (f(n)) = o(log (g(n)))</title>
<link>https://notexponential.com/260/given-f-n-o-g-n-show-that-it-is-not-necessary-that-log-f-n-o-log-g-n</link>
<description>&lt;p&gt;Given f(n) = o(g(n)), show that it is not necessary that&amp;nbsp; log (f(n)) = o(log (g(n)))&lt;/p&gt;&lt;p&gt;&lt;em&gt;[Hint, use a counterexample]&lt;/em&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/260/given-f-n-o-g-n-show-that-it-is-not-necessary-that-log-f-n-o-log-g-n</guid>
<pubDate>Mon, 12 Sep 2016 20:39:25 +0000</pubDate>
</item>
<item>
<title>Count Primes - Time Complexity</title>
<link>https://notexponential.com/250/count-primes-time-complexity</link>
<description>&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;strong&gt;What is the time complexity of this algorithm, in terms of n?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;public int countPrimes(int n) {&lt;br&gt;&amp;nbsp; &amp;nbsp;boolean[] isPrime = new boolean[n];&lt;br&gt;&amp;nbsp; &amp;nbsp;for (int i = 2; i &amp;lt; n; i++) {&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; isPrime[i] = true;&lt;br&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&amp;nbsp;&amp;nbsp; // Loop&#039;s ending condition is i * i &amp;lt; n instead of i &amp;lt; sqrt(n)&lt;br&gt;&amp;nbsp; &amp;nbsp;// to avoid repeatedly calling an expensive function sqrt().&lt;br&gt;&amp;nbsp; &amp;nbsp;for (int i = 2; i * i &amp;lt; n; i++) {&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!isPrime[i]) continue;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for (int j = i * i; j &amp;lt; n; j += i) {&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;isPrime[j] = false;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br&gt;&amp;nbsp; &amp;nbsp;}&lt;br&gt;&amp;nbsp; &amp;nbsp;int count = 0;&lt;br&gt;&amp;nbsp; &amp;nbsp;for (int i = 2; i &amp;lt; n; i++) {&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (isPrime[i]) count++;&lt;br&gt;&amp;nbsp; &amp;nbsp;}&lt;br&gt;&amp;nbsp; &amp;nbsp;return count;&lt;br&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Credit:&amp;nbsp;&lt;a href=&quot;https://leetcode.com/problems/count-primes/&quot; rel=&quot;nofollow&quot;&gt;https://leetcode.com/problems/count-primes/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/250/count-primes-time-complexity</guid>
<pubDate>Sun, 11 Sep 2016 06:47:05 +0000</pubDate>
</item>
<item>
<title>Compare 2^n^2 and 10^n asymptotically</title>
<link>https://notexponential.com/249/compare-2-n-2-and-10-n-asymptotically</link>
<description>&lt;p&gt;Prove that 10&lt;sup&gt;n&amp;nbsp;&lt;/sup&gt;&amp;nbsp;= o(2&lt;sup&gt;n^2&lt;/sup&gt;)&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/249/compare-2-n-2-and-10-n-asymptotically</guid>
<pubDate>Sat, 10 Sep 2016 22:16:07 +0000</pubDate>
</item>
<item>
<title>Order these time complexities from best (lowest) to worst (highest)</title>
<link>https://notexponential.com/233/order-these-time-complexities-from-best-lowest-worst-highest</link>
<description>&lt;p&gt;O(n)&lt;/p&gt;&lt;p&gt;O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;/p&gt;&lt;p&gt;O(n&lt;sup&gt;3&lt;/sup&gt;)&lt;/p&gt;&lt;p&gt;O(log n^ log n)&lt;/p&gt;&lt;p&gt;O(log log n ^ log log n)&lt;/p&gt;&lt;p&gt;O(log n ^ log log n)&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/233/order-these-time-complexities-from-best-lowest-worst-highest</guid>
<pubDate>Thu, 01 Sep 2016 02:22:55 +0000</pubDate>
</item>
<item>
<title>Time Complexity Analysis - Double Loop - Second increments by 0.01</title>
<link>https://notexponential.com/214/time-complexity-analysis-double-loop-second-increments-by</link>
<description>&lt;pre&gt;What is the time complexity of the following program?&lt;/pre&gt;&lt;hr&gt;&lt;pre&gt;for (int j = 1 to n) {
  int k = j
  while (k &amp;lt; n) {
    Sum += a[k]*b[k]
    k += 0.01 * n
  }
}&lt;/pre&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/214/time-complexity-analysis-double-loop-second-increments-by</guid>
<pubDate>Sat, 20 Aug 2016 20:00:28 +0000</pubDate>
</item>
<item>
<title>Trichotomy in Context of Asymptotic Functions</title>
<link>https://notexponential.com/162/trichotomy-in-context-of-asymptotic-functions</link>
<description>&lt;p&gt;Given two functions &lt;em&gt;f(n)&lt;/em&gt; and &lt;em&gt;g(n)&lt;/em&gt;, both strictly increasing with &lt;em&gt;n&lt;/em&gt;, is it possible that &lt;em&gt;f(n)&lt;/em&gt; and &lt;em&gt;g(n)&lt;/em&gt; cannot be compared asymptotically? Either prove that such two functions can always be compared asymptotically, or give a counter example, such that neither &lt;em&gt;f(n)&lt;/em&gt; is in &lt;em&gt;O(g(n))&lt;/em&gt; nor is &lt;em&gt;g(n)&lt;/em&gt; in &lt;em&gt;O(f(n))&lt;/em&gt;.&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/162/trichotomy-in-context-of-asymptotic-functions</guid>
<pubDate>Fri, 29 Jan 2016 13:00:46 +0000</pubDate>
</item>
<item>
<title>Time Complexity Analysis - Odd Even - Big Jumps</title>
<link>https://notexponential.com/144/time-complexity-analysis-odd-even-big-jumps</link>
<description>&lt;pre&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;j = 1&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;while ( j &amp;lt; n ) {&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;     k = j&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;     while ( k &amp;lt; n ) {&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;          If  ( k is odd )&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;              k++&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;          else   &lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;              k + = 0.01 * n&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;    j+=0.1*n&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;&lt;span style=&quot;font-size:14px&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/144/time-complexity-analysis-odd-even-big-jumps</guid>
<pubDate>Tue, 19 Jan 2016 17:30:01 +0000</pubDate>
</item>
<item>
<title>Time Complexity Analysis - 2 (2nd by log n)</title>
<link>https://notexponential.com/143/time-complexity-analysis-2-2nd-by-log-n</link>
<description>&lt;p&gt;&lt;span style=&quot;font-size:14px&quot;&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;for (int j=1 to n) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;k=j;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;while (k&amp;lt;n) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sum += a[k]*b[k];&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;k += logn;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/143/time-complexity-analysis-2-2nd-by-log-n</guid>
<pubDate>Tue, 19 Jan 2016 16:24:13 +0000</pubDate>
</item>
<item>
<title>Time Complexity Analysis - Inner loop var gets squared</title>
<link>https://notexponential.com/127/time-complexity-analysis-inner-loop-var-gets-squared</link>
<description>&lt;pre&gt;j = 1
while (j &amp;lt; n) {
  k = 2
  while (k &amp;lt; n) {
    Sum += a[j]*b[k]
    k = k * k
  }
  j++
}&lt;/pre&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/127/time-complexity-analysis-inner-loop-var-gets-squared</guid>
<pubDate>Fri, 15 Jan 2016 11:13:41 +0000</pubDate>
</item>
<item>
<title>Time complexity of GCD algorithm</title>
<link>https://notexponential.com/126/time-complexity-of-gcd-algorithm</link>
<description>&lt;pre&gt;&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;gcd(n,m) {&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;  r = n%m&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;  if r == 0 return m;&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;  // else&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;  return gcd(m, r)&lt;/span&gt;
&lt;span style=&quot;font-family:lucida sans unicode,lucida grande,sans-serif&quot;&gt;}&lt;/span&gt;

&lt;/pre&gt;</description>
<category>Asymptotic Analysis</category>
<guid isPermaLink="true">https://notexponential.com/126/time-complexity-of-gcd-algorithm</guid>
<pubDate>Fri, 15 Jan 2016 00:20:21 +0000</pubDate>
</item>
</channel>
</rss>