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

what is frequency count with examble? examble?

1. Use the Weierstrass condition, find the (Strongly) minimizing curve and the value of J min for the cases where x(1) = 0, x(2) = 3. 2. The system = x 1 + 2u; where

what is the impoartance of average case analysis of algorithm

infix to revrse polish

Q. Take an array A[20, 10] of your own. Suppose 4 words per memory cell and the base address of array A is 100. Find the address of A[11, 5] supposed row major storage.

This section prescribes additional exercise with the recursive and iterative handling of a binary search tree. Adding to the Binary Search Tree Recursively Add implementation

Game trees An interesting application of trees is the playing of games such as tie-tac-toe, chess, nim, kalam, chess, go etc. We can picture the sequence of possible moves by m

(a) Describe the steps involved in the process of decision making under uncertainty. (b) Explain the following principles of decision making: (i) Laplace, (ii) Hurwicz. (c

Prim's algorithm employs the concept of sets. Rather than processing the graph by sorted order of edges, this algorithm processes the edges within the graph randomly by building up