The following is a piece of python code:
sum=0
for i in range(1,f(n)+1):
sum=sum+i
f(n) is a function call. I need to find a tight big oh upper bound for the time taken by the above written piece of code in the following cases:
1. when the time taken for execution of f(n) is O(n) and f(n) is n factorial.
2. when the time taken for execution of f(n) is O(n) and f(n) is n
3. when the time taken for execution of f(n) is O(n^2) and f(n) is n
4. when the time taken for execution of f(n) is O(1) and f(n) is 0
Please tell me step by step how to solve this..please reply as soon as possible..
I'll be really thankful!!:?:
angelic_diva 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.