Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Daniel Bedialauneta
- def suma(v): #n=len(v)
- result=0
- for i in v:
- result+=i
- return result
- """
- En este caso el problema es len(v)=n
- result=0 tiene coste fijo
- el for tiene un coste fijo también, aunque dependiente de n
- y el return coste fijo también
- Por tanto,
- t(n)=1+n+1=n+2
- Siempre tiene ese coste, y t(n) está en O(n)
Add Comment
Please, Sign In to add comment