Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE205 Lecture 04

CSE205 Lecture 04

Object-Oriented Programming and Data Structures
Programming with Java III
(202201)

Javier Gonzalez-Sanchez

September 14, 2021
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. 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
  2. Javier Gonzalez-Sanchez | CSE205 | Fall 2021 | 2 jgs

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

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

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

    Lecture 30 Searching and Sorting Arrays of Objects John Mary Alice Robert 4 1 3 2
  6. 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; } } } }
  7. 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
  8. 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
  9. 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?
  10. 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.