Back to Blog
![]() The idea is to reduce number of multiplications to 3 and make the recurrence as T(n) = 3T(n/2) + O(n) The solution of the recurrence is O(n 2) which is same as the above simple solution. ![]() ![]() Therefore the time complexity is T(n) = 4T(n/2) + O(n). So the above divide and conquer approach requires 4 multiplications and O(n) time to add all 4 results. The polynomial 'B' can be written as B0 + B1*x n/2įor example 1 + 10x + 6x 2 - 4x 3 + 5x 4 can be The polynomial 'A' can be written as A0 + A1*x n/2 Same degree and have degree in powers of 2, i.e., n = 2 i Following is one simple method that divides the given polynomial (of degree n) into two polynomials one containing lower degree terms(lower than n/2) and other containing higher degree terns (higher than or equal to n/2) Let the two given polynomials be A and B.įor simplicity, Let us assume that the given two polynomials are of These methods are mainly based on divide and conquer. There are methods to do multiplication faster than O(n 2) time. If size of two polynomials same, then time complexity is O(n 2). Time complexity of the above solution is O(mn).
0 Comments
Read More
Leave a Reply. |