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
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?
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.