Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extremely easy Time Complexity Question (correct nonTGML-version!)

Status
Not open for further replies.

Traveldixie

Programmer
Jul 31, 2003
14
BE
Table t[1...n]
int s, i;

i=1;
s=0;
while(i<=n){
s = s + t;
i++;
};

Complexity : is it n+2 or 2n+2 ?
At the
the line s = s + t;
isn't the adding of t a simple constant assignment?
Or am I traversing the whole table still making it an extra &quot;n&quot;-factor?

Please help us out here coz we're disagreeing :)

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top