Start learning today, and be successful in your academic & professional career. Start Today!

• ## Related Services

 1 answerLast reply by: Professor QuayleMon May 5, 2014 4:24 PMPost by Bobby Dong on May 1, 2014Professor Quayle:For the Inserting in Order algorithm, the program shifts everything towards the end of the array when a new value is inserted. However, what if the array is set at length = n (current number of items in an array). When I run the program, will I get an ArrayOutOfBoundsException or will I get a runtime error? 1 answerLast reply by: Professor QuayleMon Dec 24, 2012 5:36 PMPost by Alex Moon on December 23, 2012Please answer this question. On the example with Inserting an Order into an array, there is a[k] = a[k-1]; whenever a[k-1] > newValueYou describe as the "8" as being moved to the right, and the space in the original box being opened up. The original 8 doesn't disappear immediately does it? I see the shifting as "copying" 1 answerLast reply by: xueping liuFri Apr 19, 2013 1:16 PMPost by Vivaldo Ribeiro on June 8, 2012Some people can't see a cow infront of them!The professor is awesome.

### Algorithms: Iteration

• Iteration is repeating the same action multiple times over a range of values
• Iteration is usually implemented with a for loop or while loop
• Iterating over a multi-dimensional range of values requires nested loops
• Finding minimum and/or maximum values is a common use of iteration
• Inserting a value in an ordered collection is another common use of iteration

### Algorithms: Iteration

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

• Intro 0:00
• Iteration 0:36
• Iteration Defined
• For Loop / While Loop
• Example
• Iteration 3:11
• Two-Dimensional Range
• Using Two Nested While Loops
• Finding Minimum and Maximum Values 5:54
• Finding Minimum and Maximum Values Examples 7:50
• Finding Minimum and Maximum Values Example 12:52
• Inserting in Order 15:19
• Inserting in Order Code 17:42
• Loop Invariants 21:53
• Example
• Summary 24:37