English 中文(简体)
计算增额,作为 lo或 not的一个步骤
原标题:counting increment as a step in a for loop or not
  • 时间:2012-01-12 09:00:27
  •  标签:
  • for-loop
for(int i=0;i<n;i++)
{
   // Some code
}

We generally say that this loop runs for n+1 times so n+1 steps for this and there is one step is of initialisation i=0. This I have read in most of the text books. My question is this that everytime the loop runs there is one more step of incrementing i to i+1 that is i=i+1, this is also one of the step which should be counted in calculating the time complexity.As I am a newbie to algorithm analysis help me with this problem.

最佳回答

我们一般说来,这一轮机为零+1倍,为这一[......]步骤。

无,我们说的是n。 这在将<代码>0的起始指数与作为<代码>和t;n书写的边界-核对数相结合方面起了重要作用。 反射线一旦到达n <>t>后,将退出该航程(0,1,1,2,......1,0,1,0,1,0,1,0,0)。

为加固该柜台而做的工作,即:i++>/code>、i += 1i = compute_the_next_index(i),并不算作“步骤”。 这些步骤是劝说,即处决尸体。

问题回答

暂无回答




相关问题
Memory Leak when using for(object in array) with iPhone SDK

I am running into some serious memory leaks in one of my applications I am building. I have a UINavigatonController that is inside a UITabBarview. Inside the NavView is a MKMap view. When you click an ...

PHP - Foreach loops and ressources

I m using a foreach loop to process a large set of items, unfortunately it s using alot of memory. (probably because It s doing a copy of the array). Apparently there is a way to save some memory with ...

as2 simple for loop not populating textbox

I have got an xml file that brings text into a flash movie in the form of an array, I need to population some textboxes and want to do this using a for loop. My loop look like this: for(var i=...

Weird acting loop in C#

Note: I added actual code snippets. Just scroll to end. // files is created by a OpenFileDialog. public void Function(String[] files, ...) { for(int i; i<files.Length; i++) { ...

iterating over map and array simultaneously in a for loop

I am having some trouble creating a for loop within a constructor to iterate over a map and an array at the same time. Here, it is indicated that this cannot be done with an enhanced for loop. I have ...

Are one-line if / for -statements good Python style?

Every so often on here I see someone s code and what looks to be a one-liner , that being a one line statement that performs in the standard way a traditional if statement or for loop works. I ...

Geocoding town names to their coordinates in a loop

I ve read similar posts, but still didn t find a solution for myself. Basically I have an array with countries+towns in PHP and I need to show them on the map with markers. Here is my code: function ...