0
What is the purpose of iterations?
Please state 1 reason about iterations
4 Réponses
+ 3
Iterating is the essence of what makes computers more productive than humans. Computers perform repetitive operations tirelessly, with accuracy, and faster than humans can. Computer languages provide iterative program elements because, without iteration, there would be no gain in productivity. That is because writing program instructions takes longer than running them. But iteration allows us to write one set of instructions and have the computer repeat them. As a rule of thumb, the more iteration we use in programs, the more gain in productivity.
+ 4
<p>Coding Director</p>
iteration or iteration blocks
iteration blocks allow you to define a set of instructions that will be applied to each element in a collection (like a list) one by one. This eliminates the need to rewrite the same logic for every single record, making your code more concise and easier to maintain.
0
in programming languages when you working with arrays, lists and other similar data structures it is very inefficient sometimes. The reason is because these structures need a continuous space in memory, so if remove a element, it also must move every element after it, at x-1 index.
Iterators working different. It is like a chain. For every element it also save the address of the previous and the next element. So when a element removed it not move any element, but it will simply adjust the address of the previous and next elements where it need. More specific:
A) from the previous element it will change its next pointer to the next of the deleted element.
B) from the next element it will change its previous pointer to the previous of the deleted element.
Example:
We want to delete the y.
'p' means previous, 'n' means next
array =
{
x, //p=0, n=y
y, //p=x, n=z
z //p=y, n=0
}
To delete/unlink the y, need to change:
A) the n at the x to z.
B) the p at the z to x
So we have this:
x, //p=0, n=z
z //p=x, n=0
0
Thank u guys for these answers. Its highly appreciated!