Question: 11. What will be the worst case time complexity for the following code?<div class="hk1_style-wrap4"><div class="hk1_style-wrap3"><div class="hk1_style-wrap2"><div class="hk1_style-wrap"><div class="hk1_style"><div class="c"><pre class="de1"><span class="co2">#include &lt;stdio.h&gt; </span> bool func<span class="br0">(</span><span class="kw4">int</span> arr<span class="br0">[</span><span class="br0">]</span><span class="sy0">,</span> <span class="kw4">int</span> n<span class="sy0">,</span> <span class="kw4">int</span> sum<span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span> <span class="br0">(</span>sum <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">)</span> <span class="kw1">return</span> <span class="kw2">true</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">(</span>n <span class="sy0">==</span> <span class="nu0">0</span> <span class="sy0">&amp;&amp;</span> sum <span class="sy0">!=</span> <span class="nu0">0</span><span class="br0">)</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">(</span>arr<span class="br0">[</span>n<span class="sy0">-</span><span class="nu0">1</span><span class="br0">]</span> <span class="sy0">&gt;</span> sum<span class="br0">)</span> <span class="kw1">return</span> func<span class="br0">(</span>arr<span class="sy0">,</span> n<span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,</span> sum<span class="br0">)</span><span class="sy0">;</span> <span class="kw1">return</span> func<span class="br0">(</span>arr<span class="sy0">,</span> n<span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,</span> sum<span class="br0">)</span> <span class="sy0">||</span> func<span class="br0">(</span>arr<span class="sy0">,</span> n<span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,</span> sum<span class="sy0">-</span>arr<span class="br0">[</span>n<span class="sy0">-</span><span class="nu0">1</span><span class="br0">]</span><span class="br0">)</span><span class="sy0">;</span> <span class="br0">}</span> <span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> <span class="kw4">int</span> arr<span class="br0">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">{</span><span class="nu0">4</span><span class="sy0">,</span><span class="nu0">6</span><span class="sy0">,</span> <span class="nu0">12</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">}</span><span class="sy0">;</span> <span class="kw4">int</span> sum <span class="sy0">=</span> <span class="nu0">12</span><span class="sy0">;</span> <span class="kw4">int</span> n <span class="sy0">=</span> <span class="kw4">sizeof</span><span class="br0">(</span>arr<span class="br0">)</span><span class="sy0">/</span><span class="kw4">sizeof</span><span class="br0">(</span>arr<span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="br0">)</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">(</span>func<span class="br0">(</span>arr<span class="sy0">,</span> n<span class="sy0">,</span> sum<span class="br0">)</span> <span class="sy0">==</span> <span class="kw2">true</span><span class="br0">)</span> <span class="kw3">printf</span><span class="br0">(</span><span class="st0">"true"</span><span class="br0">)</span><span class="sy0">;</span> <span class="kw1">else</span> <span class="kw3">printf</span><span class="br0">(</span><span class="st0">"false"</span><span class="br0">)</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">}</span></pre></div></div></div></div></div></div>
Options:
O(n log n)
O(n2)
O(2n)
O(n2 log n)
Answer: B