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
Design  and implement  an algorithm  to simulate car  re-organizing of the train at the railway switching junction. You can only use stacks as the data structure to represent the t

What are stacks? A stack is a data structure that organizes data similar to how one organizes a pile of coins. The new coin is always placed on the top and the oldest is on the

What do we mean by algorithm? What are the characteristics of a good and relevant algorithm? An algorithm is "a step-by-step procedure for finishing some task'' An algorithm c

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

Question 1 Describe the following- Well known Sorting Algorithms Divide and Conquer Techniques Question 2 Describe in your own words the different asymptotic func

pls i want a psuedo code for hotel reservation system.

Technique for direct search is    Hashing is the used for direct search.

Comparison of Gouraud and Phong Shading Phong shading requires more calculations, but produces better results for specular reflection than Gouraud shading in the form of more r

Dequeue (a double ended queue) is an abstract data type alike to queue, where insertion and deletion of elements are allowed at both of the ends. Like a linear queue & a circular q

This algorithm inputs 3 numbers, every number goes through successive division by 10 until its value is less than 1. An output is produced which comprise the number input and a val