CSCI 1105 Lecture Notes - Lecture 17: Linear Search
CSCI 1105 verified notes
17/25View all
Document Summary
Iterate as count controlled loop which iterated over a range of integer values: for any container, such as a list or a string (anything that contains or stores elements. ) Initialisation: conditions, updates (check if the condition is still true) Off by one errors: common errors in loops, think through simple test cases to avoid this type of error, quickest way to test this is to test a boundary of your loops. Sentinel values: end a data set but are not a part of the data set. Boolean variables: you can use boolean variables to control loops, common in while loops, set variable to true before entering the loop, set variable to false to leave the loop, boolean variables are inherently equal to true. Loops can be used in conjunction with many string processing tasks. In a simulation, you use the computer to simulate an activity: you can introduce randomness by calling the random number generator. rand, and randint.