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;
}
}
}
}
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.