Slide 1

Slide 1 text

jgs CSE 205 Object-Oriented Programming and Data Structures Lecture 04: Programming with Java III Dr. Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment

Slide 2

Slide 2 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 2 jgs Homework § Quiz 03 (1 hour quiz). Multiple-choice and Open questions

Slide 3

Slide 3 text

jgs Midterm Exam 3

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 4 jgs Calendar

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 5 jgs Lecture 30 Arrays of Objects John Mary Alice Robert 4 1 3 2

Slide 6

Slide 6 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 6 jgs Lecture 27, 28, 29 Searching § Linear Search § Binary Search Sorting § Bubble Sort § Selection Sort

Slide 7

Slide 7 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 7 jgs Lecture 30 Searching and Sorting Arrays of Objects John Mary Alice Robert 4 1 3 2

Slide 8

Slide 8 text

jgs Bubble Sort Code (

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 9 jgs Bubble sort

Slide 10

Slide 10 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 10 jgs Bubble sort

Slide 11

Slide 11 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 11 jgs Bubble sort

Slide 12

Slide 12 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 12 jgs More Efficient Bubble sort public static void bubbleSort(int[ ] array1) { for(int position=array1.length-2; position>=0; position--) { for (int index=0; index<=position; index++) { //compare the element at index and at index+1 if (array1[index] > array1[index+1]){ //swap them if they are not in the order int temp = array1[index+1]; array1[index+1] = array1[index]; array1[index] = temp; } } } }

Slide 13

Slide 13 text

jgs Bubble Sort Code )

Slide 14

Slide 14 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 14 jgs Lecture 31 2D Array § Declaration § Initializer List § Add values § Print values § Etc… 0 1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2

Slide 15

Slide 15 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 15 jgs Lecture 32 3D Arrays (Multidimensional) § Declaration § Initializer List § Add values § Print values § Etc… 12 24 8 16 4 8 9 18 6 12 3 6 6 12 4 8 2 4 3 6 2 4 1 2

Slide 16

Slide 16 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 16 jgs Lecture 33 Recursion § How does it work § Understand factorial. Fibonacci, Searching, etc. § What about print numbers n to m? § What about add numbers 0 to n?

Slide 17

Slide 17 text

Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 17 jgs Questions

Slide 18

Slide 18 text

jgs CSE 205 Object-Oriented Programming and Data Structures Javier Gonzalez-Sanchez, Ph.D. [email protected] Spring 2022 Copyright. These slides can only be used as study material for the class CSE205 at Arizona State University. They cannot be distributed or used for another purpose.