recategorized by
538 views
2 votes
2 votes

Consider the following two languages.

$\begin{array}{rcl} \text{PRIME} &  = & \{ 1^{n} \mid n \text{ is a prime number} \}, \\ \text{FACTOR} &  = & \{ 1^{n}0 1^{a} 01^{b} \mid n \text{ has a factor in the range }[a,b] \} \end{array}$.

What can you say about the languages $\text{PRIME}$ and $\text{FACTOR}$?

  1. $\text{PRIME}$ is in $\text{P}$, but $\text{FACTOR}$ is not in $\text{P}$.
  2. Neither $\text{PRIME}$ nor $\text{FACTOR}$ are in $\text{P}$.
  3. Both $\text{PRIME}$ and $\text{FACTOR}$ are in $\text{P}$.
  4. $\text{PRIME}$ is not in $\text{P}$, but $\text{FACTOR}$ is in $\text{P}$.
  5. None of the above since we can answer this question only if we resolve the status of the $\text{NP}$ vs. $\text{P}$ question.
recategorized by

1 Answer

Best answer
1 votes
1 votes

PRIME is in P :

References: AKS primality test

Primality testing with Gaussian periods

FACTOR is also in P :

Algorithm:

$ \text{if} \left (b-a +1 \right ) \geq n : \\ \qquad \text{return “Yes”} \\ \text{else if } (a\text{ mod }n ==0) \text{ or } (a\text{ mod }n > b\text{ mod }n )  : \\ \qquad \text{return “Yes”} \\ \text{else}: \\ \qquad \text{retrun “No”} $

Time complexity is $O(1)$ : polynomial time.

(C) is correct.

selected by
Answer:

Related questions

724
views
1 answers
1 votes
soujanyareddy13 asked Mar 25, 2021
724 views
For a language $L$ over the alphabet $\{a, b\}$, let $\overline{L}$ denote the complement of $L$ and let $L^{\ast}$ denote the Kleene-closure of $L$. Consider the ... ?Both (i) and (iii)Only (i)Only (iii)Only (ii)None of the above
656
views
2 answers
1 votes
soujanyareddy13 asked Mar 25, 2021
656 views
Which of the following regular expressions defines a language that is different from the other choices? ...
715
views
1 answers
2 votes
soujanyareddy13 asked Mar 25, 2021
715 views
Let $L$ be a context-free language generated by the context-free grammar $G = (V, \Sigma, R, S)$ where $V$ is the finite set of variables, $\Sigma$ the finite set of ... ast }${L}'=\left \{ xx \mid x \in L \right \}$None of the above
961
views
2 answers
2 votes
soujanyareddy13 asked Mar 25, 2021
961 views
Consider the following statements about propositional formulas.$\left ( p\wedge q \right )\rightarrow r$ ... $\text{(ii)}$ is always false.