+ 3
How can we reduce time complexity of programmes
Just to reduce O(n^2) to O(n)
4 ответов
+ 6
We will need to look at the code for that purpose. The complexity of some algorithms simply cannot be reduced, possibly because it's already optimal for that particular task.
+ 4
One example for moving from O(n) to O(log n) is to use a binary rather than a linear search on a sorted array.
+ 3
That depends on your code. Sometimes it is enough to choose the right data structure (eg. set instead of list). At other times you need to implement a completely different algorithm to get big O down.
+ 3
In simple way use minimum variable as far as possible and loops too.