• edited by
693 views
1 1 vote

We have a procedure $P(n)$ that makes multiple calls to a procedure $Q(m)$, and runs in polynomial time in $n$. Unfortunately, a significant flaw was discovered in $Q(m)$, and it had to be replaced by $R(m)$, which runs in exponential time in $m$. Thankfully, $P$ is still correct when we replace each call to $Q(m)$ with a call to $R(m)$ instead. Which of the following can we definitely say about the modified version of $P$?

  1. $P(n)$ still runs in polynomial time in $n$.
  2. $P(n)$ requires exponential time in $n$.
  3. $P(n)$ runs in polynomial time in $n$ if the number of calls made to $Q$ is proportional to $log\;n.$
  4. $P(n)$ runs in polynomial time in $n$ if, for each call $Q(m),m \underline<log \;n.$

2 Answers

0 0 votes

We’ll assume  P(n) calls Q(m) or R(m) k times, and prove the claims to be right or wrong below:-

Note:- O(P(n))=O(k*R(m)) or O(k*2^m)……..(1)

 where k=# calls made to R(m), also k must be upper bounded by a polynomial function of n, else the original function wouldn’t have been polynomial in n

  1. Claims that P(n) runs in polynomial time in n, we can easily substitute m=n in (1)  to see that it clearly runs in exponential time in n.
  2. Claims that P(n) runs in exponential time in n, if we substitute m to be log(n) in (1), the complexity becomes O(k*n), which can be said to run in polynomial time.
  3. if k is proportional to log(n) or( k=c*log(n)), complexity becomes O(log(n)*2^m), here m can again be substituted to be n and it violates the claim in this statement.
  4. if m<=log(n), by taking the worst case i.e m=log(n) and putting it in O(k*2^m) we can see the ans is O(k*n) which we can safely say to be polynomial.
Answer:
Position:
Show:

Related questions

4 4 votes
3 3 answers
1.1k
1.1k views
soujanyareddy13 asked Jan 28, 2021
1,107 views
Which of the following languages over the alphabet $\{0,1\}$ are $not$ recognized by deterministic finite state automata $(DFA)$ with $three$ states?Words which do not ha...
0 0 votes
2 2 answers
630
630 views
soujanyareddy13 asked Jan 28, 2021
630 views
Consider the following regular expressions over alphabet$\{a,b\}$, where the notation $(a+b)^+$ means $(a+b)(a+b)^*$:$$r_1=(a+b)^+a(a+b)^*$$$$r_2=(a+b)^*b(a+b)^+$$Let $L_...
0 0 votes
1 1 answer
507
507 views
soujanyareddy13 asked Jan 28, 2021
507 views
Some children are given boxes containing sweets. Harish is happy if he gets either gems or toffees. Rekha is happy if she gets both bubble gums and peppermints. Some of t...
0 0 votes
1 1 answer
379
379 views
soujanyareddy13 asked Jan 28, 2021
379 views
In a class, every student likes exactly one novelist and one musician. If two students like the same novelist, they also like the same musician. The class can be divided ...