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
State the ways to construct container taxonomy There are several ways that we could construct our container taxonomy from here; one way that works well is to make a fundamental

How to create an General Tree and how to search general tree?

what are the applications of multikey file organization?

Enumerate the Types in Ruby Ruby is a pure object-oriented language, meaning that all types in Ruby are classes, and each value in a Ruby program is an instance of a class. Thi

Define Complete Binary Tree Complete Binary Tree:- A whole binary tree of depth d is that strictly binary tree all of whose leaves are at level D.

What are the different ways of representing a graph? The different ways of representing a graph is: Adjacency list representation: This representation of graph having of an

Multilist Representation of graph

Arrays are simple, however reliable to employ in more condition than you can count. Arrays are utilized in those problems while the number of items to be solved out is fixed. They

Pre-order Traversal The method of doing a pre-order traversal iteratively then has the several steps(suppose that a stack is available to hold pointers to the appropriate nodes

Given is the structure of an AVL tree: struct avl { struct node *left; int info; int bf; struct node *right; }; 2) A multiway tree of n order is an ord