<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Algorithms Q&amp;A - Recent questions in Divide &amp; Conquer</title>
<link>https://notexponential.com/questions/d%26c</link>
<description>Powered by Question2Answer</description>
<item>
<title>Solve or estimate this recurrence relation T(n) = 2 T(n/3) + T(n/2) + n</title>
<link>https://notexponential.com/768/solve-or-estimate-this-recurrence-relation-t-n-2-t-n-3-t-n-2-n</link>
<description></description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/768/solve-or-estimate-this-recurrence-relation-t-n-2-t-n-3-t-n-2-n</guid>
<pubDate>Tue, 01 Jun 2021 21:39:32 +0000</pubDate>
</item>
<item>
<title>N-th power of complex number z = x + iy in O(log n) time</title>
<link>https://notexponential.com/709/n-th-power-of-complex-number-z-x-iy-in-o-log-n-time</link>
<description>&lt;p&gt;&lt;span style=&quot;font-family:&amp;quot;Calibri&amp;quot;,sans-serif; font-size:11.0pt; line-height:115%; mso-ansi-language:EN-US; mso-ascii-theme-font:minor-latin; mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;; mso-bidi-language:AR-SA; mso-bidi-theme-font:minor-bidi; mso-fareast-font-family:&amp;quot;MS Mincho&amp;quot;; mso-fareast-language:EN-US; mso-fareast-theme-font:minor-fareast; mso-hansi-theme-font:minor-latin&quot;&gt;You are given a complex number z = x + iy.&amp;nbsp; The n-th power of z is given (x + iy)^n.&amp;nbsp; Describe a O(log n) time algorithm to do the same.&amp;nbsp; Recall that that i^2 = -1, and that z^2 = x^2 – y^2 + 2ixy.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/709/n-th-power-of-complex-number-z-x-iy-in-o-log-n-time</guid>
<pubDate>Sat, 13 Jun 2020 15:43:36 +0000</pubDate>
</item>
<item>
<title>Solve this recurrence relation: T(n) = 3 T(n/4) + O(n^0.75)</title>
<link>https://notexponential.com/708/solve-this-recurrence-relation-t-n-3-t-n-4-o-n-0-75</link>
<description></description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/708/solve-this-recurrence-relation-t-n-3-t-n-4-o-n-0-75</guid>
<pubDate>Sat, 13 Jun 2020 15:40:39 +0000</pubDate>
</item>
<item>
<title>Solve this recurrence relation: T(n) = T(n-1) + T(n/2) + 1</title>
<link>https://notexponential.com/707/solve-this-recurrence-relation-t-n-t-n-1-t-n-2-1</link>
<description></description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/707/solve-this-recurrence-relation-t-n-t-n-1-t-n-2-1</guid>
<pubDate>Sat, 13 Jun 2020 15:39:20 +0000</pubDate>
</item>
<item>
<title>Solving this recurrence relation: T(n) = 2 T(n/2) + f(n)</title>
<link>https://notexponential.com/696/solving-this-recurrence-relation-t-n-2-t-n-2-f-n</link>
<description>How do we solve this recurrence relation generically?&lt;br /&gt;
&lt;br /&gt;
For example, we can say something like: if f(n) = omega(n^1+epsilon), then T(n) = f(n). &amp;nbsp;etc?</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/696/solving-this-recurrence-relation-t-n-2-t-n-2-f-n</guid>
<pubDate>Tue, 24 Sep 2019 14:30:02 +0000</pubDate>
</item>
<item>
<title>Solve this recurrence relation: T(n) = T(n/3) + T(n/5) + T(n/6) + n</title>
<link>https://notexponential.com/693/solve-this-recurrence-relation-t-n-t-n-3-t-n-5-t-n-6-n</link>
<description>Solve this recurrence relation: T(n) = T(n/3) + T(n/5) + T(n/6) + n</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/693/solve-this-recurrence-relation-t-n-t-n-3-t-n-5-t-n-6-n</guid>
<pubDate>Thu, 19 Sep 2019 14:22:51 +0000</pubDate>
</item>
<item>
<title>The Subarray with the Minimum Peak</title>
<link>https://notexponential.com/596/the-subarray-with-the-minimum-peak</link>
<description>&lt;p&gt;Let X[1:n]: be an array of real numbers, and let L be a given fixed positive integer. An L-subarray is any sequence of consecutive elements of the array X, such as X[k: k + L − 1], and is identified simply by the index k of the first element of the subarray. The array has (n &amp;nbsp;− L + 1) L-subarrays. The peak of an L-subarray is the maximum value in that subarray.&lt;br&gt;&lt;br&gt;Give a divide-and-conquer algorithm that takes as input an array X[1:n] and a positive integer L ≤ n, and returns the L-subarray with the smallest peak. Analyze the time complexity of your algorithm.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;[We observe that a simple brute force O(NL) time algorithm is straightforward, simply evaluate each L-subarray.&amp;nbsp; Our interest is in something like O(N log N) or O(N log L) time algorithm.]&lt;/strong&gt;&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/596/the-subarray-with-the-minimum-peak</guid>
<pubDate>Sat, 20 Oct 2018 18:37:58 +0000</pubDate>
</item>
<item>
<title>Find the smallest domain value where the function becomes negative.</title>
<link>https://notexponential.com/595/find-smallest-domain-value-where-function-becomes-negative</link>
<description>We consider a monotonically decreasing function f : N → Z (monotonically decreasing means that f(i) &amp;gt; f(i + 1) for all i values in the domain). We can evaluate f at any i in constant time, we want to find n = min{i ∈ N such that f(i) ≤ 0}.&lt;br /&gt;
&lt;br /&gt;
Give an O(log n) time to find such an n.</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/595/find-smallest-domain-value-where-function-becomes-negative</guid>
<pubDate>Thu, 27 Sep 2018 01:59:10 +0000</pubDate>
</item>
<item>
<title>Three Set Sum: Given an integer k and 3 sets A, B and C, find a, b, c such that a + b + c = k</title>
<link>https://notexponential.com/475/three-set-sum-given-an-integer-k-and-3-sets-a-and-find-such-that</link>
<description>&lt;p&gt;You are given an integer &lt;em&gt;k&lt;/em&gt; and 3 sets A, B and C, each containing &lt;em&gt;n&lt;/em&gt; numbers.&amp;nbsp; Give an efficient algorithm to determine if there exist 3 integers &lt;em&gt;a, b, c&lt;/em&gt; (in sets A, B, C respectively), such that &lt;em&gt;a + b + c = k.&lt;/em&gt;&amp;nbsp; The time complexity of your algorithm should be &lt;em&gt;O(n&lt;sup&gt;2&lt;/sup&gt;)&lt;/em&gt; or better.&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/475/three-set-sum-given-an-integer-k-and-3-sets-a-and-find-such-that</guid>
<pubDate>Mon, 24 Jul 2017 05:22:48 +0000</pubDate>
</item>
<item>
<title>Solve the recurrence relation: T(n)=T(n/2)+T(n/3)+T(n/4) + n</title>
<link>https://notexponential.com/431/solve-the-recurrence-relation-t-n-t-n-2-t-n-3-t-n-4-n</link>
<description>Solve the recurrence relation: T(n)=T(n/2)+T(n/3)+T(n/4) + n</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/431/solve-the-recurrence-relation-t-n-t-n-2-t-n-3-t-n-4-n</guid>
<pubDate>Tue, 14 Feb 2017 22:56:25 +0000</pubDate>
</item>
<item>
<title>In Quickselect, T(n)&lt;=T(n/5)+T(7n/10)+cn, prove that T(n) = O(n)</title>
<link>https://notexponential.com/425/in-quickselect-t-n-t-n-5-t-7n-10-cn-prove-that-t-n-o-n</link>
<description></description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/425/in-quickselect-t-n-t-n-5-t-7n-10-cn-prove-that-t-n-o-n</guid>
<pubDate>Wed, 08 Feb 2017 01:01:38 +0000</pubDate>
</item>
<item>
<title>Solve the recurrence relation: T(n) = 3 T(n/2) + n^1.5 log n</title>
<link>https://notexponential.com/420/solve-the-recurrence-relation-t-n-3-t-n-2-n-1-5-log-n</link>
<description>&lt;p&gt;Solve the recurrence relation: T(n) = 3 T(n/2) + n&lt;sup&gt;1.5&lt;/sup&gt; log n&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/420/solve-the-recurrence-relation-t-n-3-t-n-2-n-1-5-log-n</guid>
<pubDate>Thu, 15 Dec 2016 01:24:17 +0000</pubDate>
</item>
<item>
<title>Solve the recurrence Relation: T(n) = T(n/3) + T(2n/3) + n</title>
<link>https://notexponential.com/419/solve-the-recurrence-relation-t-n-t-n-3-t-2n-3-n</link>
<description>Solve this recurrence relation: T(n) = T(n/3) + T(2n/3) + n</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/419/solve-the-recurrence-relation-t-n-t-n-3-t-2n-3-n</guid>
<pubDate>Wed, 14 Dec 2016 20:25:59 +0000</pubDate>
</item>
<item>
<title>Rectangles overlap</title>
<link>https://notexponential.com/395/rectangles-overlap</link>
<description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;“Rectangles”&lt;/em&gt;&lt;/strong&gt; A rectangle can be specified in a 2-dimensional plane using the top left (north west) point and the bottom right (south east) point.&amp;nbsp; Given n rectangles (using 2 points each), give an O(n log n) algorithm that tells if any two rectangles from the list overlap.&amp;nbsp; Two rectangles are said to overlap, if there is a common point in both of them.&amp;nbsp; [If a rectangle is entirely contained in another, they are still said to “overlap”, even though their lines don’t cross.]&lt;/p&gt;&lt;p&gt;How to solve this problem?&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/395/rectangles-overlap</guid>
<pubDate>Mon, 05 Dec 2016 02:21:50 +0000</pubDate>
</item>
<item>
<title>MVCS using Divide and Conquer</title>
<link>https://notexponential.com/392/mvcs-using-divide-and-conquer</link>
<description>&lt;p&gt;Recall the Maximum Value Contiguous Subsequence problem that we studied in class: “&lt;strong&gt;Given an Array A(1..n) of positive and negative values, find a contiguous subsequence A(i..j) such that the sum of the terms in the subarray is maximized&lt;/strong&gt;”.&amp;nbsp; We studied a linear time O(n) dynamic programming solution that finds the best subsequence.&lt;/p&gt;&lt;p&gt;Now, you need to design a divide and conquer algorithm for the same problem that is also optimal (so it needs to find the maximum value, not something approximate).&amp;nbsp; It is acceptable for the time complexity of your algorithm to be larger than O(n).&amp;nbsp; If you can show an O(n&lt;sup&gt;2&lt;/sup&gt;) algorithm, you get 5+ points.&amp;nbsp; If you show O(n log n) algorithm, you get 10 points.&amp;nbsp; &lt;em&gt;[If your algorithm is &lt;/em&gt;&lt;em&gt;w(&lt;/em&gt;n&lt;sup&gt;2&lt;/sup&gt;&lt;em&gt;), that is sadly not worth anything. &lt;/em&gt;&lt;em&gt;L]&lt;/em&gt;&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/392/mvcs-using-divide-and-conquer</guid>
<pubDate>Sat, 03 Dec 2016 13:38:03 +0000</pubDate>
</item>
<item>
<title>Tree method or PMI?</title>
<link>https://notexponential.com/336/tree-method-or-pmi</link>
<description>&lt;p&gt;For some recurrence we can not use MT, we often guess an answer and prove it through PMI. However, I think that the answer is not close.&lt;/p&gt;&lt;p&gt;For example:&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://notexponential.com/293/recurrence-relation-t-n-t-n-3-2-t-2n-3-n&quot;&gt;http://notexponential.com/293/recurrence-relation-t-n-t-n-3-2-t-2n-3-n&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The PMI answer here is T(n) = T(n/3) + 2T(2n/3)+n =&amp;nbsp;O(n&lt;sup&gt;2&lt;/sup&gt;).&lt;/p&gt;&lt;p&gt;In my solution, I assume that the tree could fully extend.&lt;/p&gt;&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;http://blog.terryx.com/qa1.png&quot; style=&quot;height:195px; width:500px&quot;&gt;&lt;/p&gt;&lt;p&gt;The 1st level is&amp;nbsp;Θ(n);&lt;/p&gt;&lt;p&gt;The 2nd level is&amp;nbsp;Θ((5/3)*n);&lt;/p&gt;&lt;p&gt;The 3rd level is&amp;nbsp;Θ((5/3)&lt;sup&gt;2&lt;/sup&gt;*n);&lt;/p&gt;&lt;p&gt;....&lt;/p&gt;&lt;p&gt;The nth level is&amp;nbsp;Θ((5/3)&lt;sup&gt;n-1&lt;/sup&gt;*n).&lt;/p&gt;&lt;p&gt;And the height of the left tree is log&lt;sub&gt;3&lt;/sub&gt;n, because the height of&amp;nbsp;right tree is less than the value. Here&amp;nbsp;I just assume they have the same height.&amp;nbsp;Then the bottom level is n*T(1) since the tree&amp;nbsp;has n leaves.&lt;/p&gt;&lt;p&gt;Thus,&lt;/p&gt;&lt;p&gt;T(n) = n*T(1) + n +&amp;nbsp;(5/3)*n +&amp;nbsp;(5/3)&lt;sup&gt;2&lt;/sup&gt;*n + ... +&amp;nbsp;(5/3)&lt;sup&gt;log&lt;sub&gt;3&lt;/sub&gt;n&lt;/sup&gt;&lt;sup&gt;-1&lt;/sup&gt;*n = n + n*((1 - (5/3)&lt;sup&gt;log&lt;sub&gt;3&lt;/sub&gt;n-1&lt;/sup&gt;)/(1 - (5/3)))&amp;nbsp;&lt;/p&gt;&lt;p&gt;= n + (3/2)*n*(5/3)&lt;sup&gt;&lt;span style=&quot;font-size:10.833333015441895px&quot;&gt;log&lt;/span&gt;&lt;sub&gt;3&lt;/sub&gt;&lt;span style=&quot;font-size:10.833333015441895px&quot;&gt;n-1 &lt;/span&gt;&lt;/sup&gt;&lt;span style=&quot;font-size:10.833333015441895px&quot;&gt;~&lt;/span&gt;&amp;nbsp;n&amp;nbsp;+ (3/2)*n*(5/3)&lt;sup&gt;log&lt;sub&gt;3&lt;/sub&gt;n &lt;/sup&gt;=&amp;nbsp;n + (3/2)*n*n&lt;sup&gt;log&lt;sub&gt;3&lt;/sub&gt;(5/3)&lt;/sup&gt;&amp;nbsp;~&amp;nbsp;n + n&lt;sup&gt;1.5&lt;/sup&gt;.&lt;/p&gt;&lt;p&gt;Actually, the tree can not fully extend, T(n) &amp;lt;&amp;nbsp;n + n&lt;sup&gt;1.5&lt;/sup&gt;, T(n) = O(n&lt;sup&gt;1.5&lt;/sup&gt;).&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;PMI answer is&amp;nbsp;O(n&lt;sup&gt;2&lt;/sup&gt;) while tree method answer is&amp;nbsp;O(n&lt;sup&gt;1.5&lt;/sup&gt;). Which one is the right answer?&lt;/p&gt;</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/336/tree-method-or-pmi</guid>
<pubDate>Wed, 28 Sep 2016 19:24:47 +0000</pubDate>
</item>
<item>
<title>Can T(n) = 2T(n/2) + nlogn use master theorem?</title>
<link>https://notexponential.com/306/can-t-n-2t-n-2-nlogn-use-master-theorem</link>
<description></description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/306/can-t-n-2t-n-2-nlogn-use-master-theorem</guid>
<pubDate>Wed, 21 Sep 2016 03:51:57 +0000</pubDate>
</item>
<item>
<title>How to find the &quot;joint&quot; median of 3 sorted lists, in less than linear time?</title>
<link>https://notexponential.com/174/how-find-the-joint-median-sorted-lists-less-than-linear-time</link>
<description>We are given 3 sorted lists of size: n1, n2 and n3. &amp;nbsp;We want to find the median of the merged list. &amp;nbsp;Can we do that in less than linear time? &amp;nbsp;If so, how?</description>
<category>Divide &amp; Conquer</category>
<guid isPermaLink="true">https://notexponential.com/174/how-find-the-joint-median-sorted-lists-less-than-linear-time</guid>
<pubDate>Sat, 05 Mar 2016 11:27:06 +0000</pubDate>
</item>
</channel>
</rss>