elcocodrilotito

6.5.3

Mar 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. #Daniel Bedialauneta
  2.  
  3. def suma(v): #n=len(v)
  4.     result=0
  5.     for i in v:
  6.         result+=i
  7.     return result
  8.  
  9. """
  10. En este caso el problema es len(v)=n
  11. result=0 tiene coste fijo
  12. el for tiene un coste fijo también, aunque dependiente de n
  13. y el return coste fijo también
  14.  
  15. Por tanto,
  16. t(n)=1+n+1=n+2
  17.  
  18. Siempre tiene ese coste, y t(n) está en O(n)
Add Comment
Please, Sign In to add comment