Jump to content

BebopSong

Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Location
    UK
  • Favorite Area of Science
    Computer Science

BebopSong's Achievements

Lepton

Lepton (1/13)

0

Reputation

  1. Ah ok, that makes sense now. So loop invariants explain the setup of the loop and the 3 parts of loop invariants; initialization, maintenance and termination explain the individual sections of the loop that must result in true for the loop to be correct. Initialization specifies that the variant meets the required condition to enter the loop. Maintenance states that the variant meets the required condition to stay in the loop for all the necessary times required to complete the task. Termination makes sure the variant will terminate after some time (hopefully a short amount of time). It's useful then to consider these concepts when designing a loop but, in my opinion, subconsciously they are. Still thinking up all scenarios of what will make the loop break is a good idea. Thanks for the help.
  2. Hi, I've been reading an algorithm book and after learning and understanding the insertion loop the topic of loop invariants comes up which confuses me somewhat. They appear, to me, to be just statements that the loop will work, i.e. the loop invariant remains true at the beginning of each iteration of the loop and when it terminates. This seems non-sensical to me as that is the entire reason for creating the algorithm in the first place so why do we need to state it? I'm more practical than theoretical which I believe is halting my ability to understand the theory behind it. Can someone explain the use of loop invariants please? Do they help to create algorithms or are they just to prove correctness, in which case what is the process of proving an algorithm before creating it using loop invariants? Thanks. BebopSong
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.