Is Trial Division Primality Check Considered in Polynomial Time?

In summary, the conversation discusses the concept of polynomial time in algorithms and how it relates to different algorithms, such as Dijkstra and trial division for primality testing. While trial division may appear to run in polynomial time, it is actually exponential in the size of the input data. The AKS primality test is a more efficient algorithm that runs in polynomial time.
  • #1
mourinho123
1
0
Greetings,

This is very simple, and obviously I'm missing something trivial, but I still don't get it.

An algorithm is said to run in polynomial time if it runs in O(n^K) time.

That's why dijkstra for example, who runs in O(V^2), runs in polynomial time.

That said, my doubt is the following:
If a brute-force trial division primality check algorithm, runs in O(n^(1/2)), why it isn't considered in polynomial time?

Thanks beforehands,
Mourinho
 
Mathematics news on Phys.org
  • #2
The running time of an algorithm is usually expressed in terms of the size of the input data.

If you want to test N for primality, the amount of data you need to need to give your algorithm is O(log N). (e.g. if your algorithm works in base 10, the size of the input is the number of decimal digits it takes to write N, so the input size is (log N) / log(10))

So, the size of the input is (log N), and the amount of work necessary is N^(1/2)... which is exponential in the size of the input.



(Of course, it would be accurate to say that the running time is polynomial in N)
 
  • #3
The AKS primality test takes O(n6) time* to check if an n-bit number is prime. Trial division takes O(2n/2).

* The exponent depends on the version used. I think the original was O(n12) time and the best versions so far are conjectured to run in O(n4) time.
 

1. What is trial division primality?

Trial division primality is a method used to determine if a given number is prime or not. It involves dividing the number by every integer smaller than it, and if the remainder is 0 for any division, then the number is not prime.

2. How does trial division primality work?

Trial division primality works by checking if a given number is divisible by any integer smaller than it. If there is no remainder for any of these divisions, then the number is prime.

3. What is the time complexity of trial division primality?

The time complexity of trial division primality is O(sqrt(n)), where n is the given number. This means that the number of operations increases proportionally to the square root of the input, making it less efficient for larger numbers.

4. Can trial division primality be used for large numbers?

While trial division primality can be used for large numbers, it becomes less efficient as the numbers get larger. For extremely large numbers, other primality tests such as the Miller-Rabin test are more commonly used.

5. Are there any limitations to trial division primality?

Yes, trial division primality can only determine if a number is prime or not. It cannot provide any other information about the number, such as its prime factors. It also becomes less efficient for larger numbers and is not the most commonly used primality test for large numbers.

Similar threads

  • General Math
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • General Math
Replies
16
Views
3K
Replies
3
Views
2K
Replies
14
Views
200
Replies
6
Views
1K
Replies
9
Views
1K
  • Programming and Computer Science
Replies
2
Views
766
  • Linear and Abstract Algebra
Replies
1
Views
2K
Replies
1
Views
2K
Back
Top