Svoboda | Graniru | BBC Russia | Golosameriki | Facebook

To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

From Wikipedia, the free encyclopedia

In computer programs, an important form of control flow is the loop which causes a block of code to be executed more than once. A common idiom is to have a loop nested inside another loop, with the contained loop being commonly referred to as the inner loop.

Background

Two main types of loop exist and they can be nested within each other to, possibly, any depth as required. The two types are for loop and while loop.[1] Both are slightly different but may be interchanged. Research has shown that performance of the complete structure of a loop with an inner loop is different when compared with a loop without an inner loop.[2] Indeed, even the performance of two loops with different types of inner loop, where one is a for loop and the other a while loop, are different.

It was observed that more computations are performed per unit time when an inner for loop is involved than otherwise. This implies, given the same number of computations to perform, the one with an inner for loop will finish faster than the one without it. This is a machine- or platform-independent technique of loop optimization and was observed across several programming languages and compilers or interpreters tested. The case of a while loop as the inner loop performed badly, performing even slower than a loop without any inner loop in some cases. Two examples below written in python present a while loop with an inner for loop and a while loop without any inner loop. Although both have the same terminating condition for their while loops, the first example will finish faster because of the inner for loop. The variable innermax is a fraction of the maxticketno variable in the first example.[3]

while ticket_no * innermax < max_ticket_no:
    for j in range(0, innermax):
        if (ticket_no * innermax + j) == jackpot_no:
            return
    ticket_no += 1
while ticket_no < max_ticket_no:
    if ticket_no == jackpot_no:
        return
    ticket_no += 1

References

  1. ^ Ghezzi, C; Jazayeri, M (1996). Programming Language Concepts (3rd edn.). John Wiley & Sons.
  2. ^ Adewumi, Tosin (August 2018). "Inner loop program construct: a faster way for program execution". Open Computer Science. 8: 115–122. doi:10.1515/comp-2018-0004.
  3. ^ Vishal (2021-06-09). "Nested Loops in Python". PYnative. Retrieved 2022-09-07.

4. Python Nested For Loop From Techgeekbuz

This page was last edited on 22 January 2023, at 14:16
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.