Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to Java
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Lecture Comments (8)

1 answer

Last reply by: Professor Quayle
Mon May 5, 2014 4:24 PM

Post by Bobby Dong on May 1, 2014

Professor 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 answer

Last reply by: Professor Quayle
Mon Dec 24, 2012 5:36 PM

Post by Alex Moon on December 23, 2012

Please answer this question.
On the example with Inserting an Order into an array, there is

a[k] = a[k-1];


a[k-1] > newValue

You 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 answer

Last reply by: xueping liu
Fri Apr 19, 2013 1:16 PM

Post by Vivaldo Ribeiro on June 8, 2012

Some 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
  • Roadmap 0:13
  • 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