For loop, Data Structure & Algorithms

for (i = 0; i < n; i + +) {

sequence of statements


Here, the loop executes n times. Thus, the sequence of statements also executes n times. Since we suppose the time complexity of the statements are O(1), the overall time for the loop is n * O(1), that is O(n). Here, the number of statements does not matter as it will enhance the running time by a constant factor and the overall complexity will be same O(n).

Posted Date: 4/4/2013 5:55:53 AM | Location : United States

Related Discussions:- For loop, Assignment Help, Ask Question on For loop, Get Answer, Expert's Help, For loop Discussions

Write discussion on For loop
Your posts are moderated
Related Questions

Explain the concept of hidden lines The problem of hidden lines or surfaces was implicit even in 2-D graphics, but we did not mention it there, because what was intended to be

solve the following relation by recursive method: T(n)=2T(n^1/2)+log n

How many nodes in a tree have no ancestors 1 node in atree have no ancestors.

the deference between insertion,selection and bubble sort

Step-1: For the current node, verify whether it contain a left child. If it has, then go to step-2 or else go to step-3 Step-2: Repeat step-1 for left child Step-3: Visit (th

/* The program accepts matrix like input & prints the 3-tuple representation of it*/ #include void main() { int a[5][5],rows,columns,i,j; printf("enter the order of

Illustrate Trivariate Colour Models Conventional colour models based on the tristimulus theory all contain three variables and so are called trivariate models. Let us now consi

What is Keyed Access- Container A collection may allow its elements to be accessed by keys. For instance, maps are unstructured containers which allows their elements to be

the voltage wave forms are applied at the inputs of an EX-OR gate. determine the output wave form