0
Should we consider the time complexity of inbuilt functions and operations
Say I have a list and what to find an element: I could do this: if element in list: .......... Or I could write my own binary search function: So how do I know the time complexity of (in)
3 Respuestas
+ 1
Every algorithm has its own time complexity.
But here is one of many websites that tell you time complexity of the most common algorithms:
https://www.bigocheatsheet.com/
0
Time complexity of "element in list" is O(n) as it is just a linear search...
(you could also know its just a linear search as it works with unsorted lists too)..
So if you want your code to operate quicker, you might consider making your own binary search function.
0
Aleksei Radchenkov is there a website where I can find a list of the time complexities