# Pseudo-polynomial Algorithms

**What is Pseudo-polynomial? **

An algorithm whose worst case time complexity depends on numeric value of input (not number of inputs) is called Pseudo-polynomial algorithm.

For example, consider the problem of counting frequencies of all elements in an array of positive numbers. A pseudo-polynomial time solution for this is to first find the maximum value, then iterate from 1 to maximum value and for each value, find its frequency in array. This solution requires time according to maximum value in input array, therefore pseudo-polynomial. On the other hand, an algorithm whose time complexity is only based on number of elements in array (not value) is considered as polynomial time algorithm.

**Pseudo-polynomial and NP-Completeness**

Some NP-Complete problems have Pseudo Polynomial time solutions. For example, Dynamic Programming Solutions of 0-1 Knapsack, Subset-Sum and Partition problems are Pseudo-Polynomial. NP complete problems that can be solved using a pseudo-polynomial time algorithms are called weakly NP-complete.

**Reference:**

https://en.wikipedia.org/wiki/Pseudo-polynomial_time

This article is contributed by **Dheeraj Gupta**. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details

## Recommended Posts:

- Algorithms | Recurrences | Set 1
- Analysis of Algorithms | Set 5 (Practice Problems)
- Analysis of algorithms | little o and little omega notations
- Analysis of Algorithms | Set 3 (Asymptotic Notations)
- Algorithms Sample Questions | Recurrences | Set 2
- Analysis of Algorithms | Set 2 (Worst, Average and Best Cases)
- Sorting Algorithms Visualization : Bubble Sort
- Asymptotic Analysis and comparison of sorting algorithms
- Loop Invariant Condition with Examples of Sorting Algorithms
- Algorithms Sample Questions | Set 3 | Time Order Analysis
- Analysis of Algorithms | Set 1 (Asymptotic Analysis)
- Analysis of Algorithms | Set 4 (Analysis of Loops)
- Difference between Deterministic and Non-deterministic Algorithms
- Analysis of Algorithms | Big-O analysis