
Spring 2023 Lesson 18 Updates and Reminders
Discover important updates and reminders for Spring 2023 Lesson 18 with details on assignment due dates, upcoming events, exam schedules, TA nominations, course evaluations, and more. Stay informed and prepared for the rest of the term.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
CSE 121 Lesson 18 Miya Natsuhara Spring 2023 Music: 121 23sp Lecture Vibes TAs: Jasmine Shananda Vidhi Larry Jacqueline Afifah Atharva Julia Anju Lydia Jonus Hugh Mia Archit Grace Kailye Joshua James Justin Aishah Claire Lydia Kai sli.do #cse121
Announcements, Reminders P3 due tonight Wednesday, May 31 11:59pm Gumball (& friends) Visit on Monday, June 5 1:00pm-3:00pm Final Exam: Thursday, June 8 2:30pm-4:20pm TA-led Final Review Session Tuesday, June 6 4:30pm-7:00pm One 8.5x11 inch sheet of notes (double-sided, handwritten or typed) Seating assignments posted! Bob Bandes TA Award Nominations Open! Course Evaluations open now, and close Sunday June 4 at 11:59pm Currently at about 11% response rate! Also do your TAs' evals in section tomorrow! Lesson 18 - Spring 2023 2
C3 Drawings! Lesson 18 - Spring 2023 3
Poll in with your answer! public static void main(String[] args) { int x = 0; int[] a = new int[4]; x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); Four lines of output would be produced by this code. What would those four lines be? x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); } public static void mystery(int x, int[] a) { x++; a[x]++; System.out.println(x + " " + Arrays.toString(a)); } Lesson 18 - Spring 2023 4
Poll in with your answer! public static void main(String[] args) { int x = 0; int[] a = new int[4]; x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); x++; mystery(x, a); System.out.println(x + " " + Arrays.toString(a)); } public static void mystery(int x, int[] a) { x++; a[x]++; System.out.println(x + " " + Arrays.toString(a)); } Lesson 18 - Spring 2023 5
(PCM) Counting Elements that Meet a Condition "one" "two" "three" "six" "seven" "eight" "ten" public static int evenLength(String[] list) { int countEven = 0; for (int i = 0; i < list.length; i++) { if ( ) { countEven++; } } return countEven; } Lesson 18 - Spring 2023 6
(PCM) Modifying Elements of an Array 4 8 15 16 23 42 public static void clamp(int min, int max, int[] list) { for (int i = 0; i < list.length; i++) { if ( > max) { = max; } else if ( < min) { = min; } } } Lesson 18 - Spring 2023 7
(PCM) Searching for an Element "one" "two" "three" "six" "seven" "eight" "ten" public static int indexOfIgnoreCase(String phrase, String[] list) { for (int i = 0; i < list.length; i++) { if ( ) { return ; } } return ; } Lesson 18 - Spring 2023 8
(PCM) Shifting Elements 9.6 -88.0 4.815 0.009 7.0184 42.9 public static void rotateRight(double[] list) { double lastElement = list[list.length - 1]; for (int i = list.length - 1; i > 0; i--) { list[i] = list[i - 1]; } } Lesson 18 - Spring 2023 9
(PCM) Looking at Multiple Elements in an Array 0 1 9 1 0 public static boolean isPalindrome(int[] list) { for (int i = 0; i < list.length / 2; i++) { if (list[i] != list[list.length - 1 - i]) { return ; } } return ; } Lesson 18 - Spring 2023 10
(PCM) Array of Counters or "Tallying" 8 3 0 1 2 2 0 7 2 public static int[] numCount(Scanner input) { int[] counts = ; while (input.hasNextInt()) { int num = input.nextInt(); } return counts; } Lesson 18 - Spring 2023 11
(PCM) Common Ideas in Array Patterns Loop bounds Direction of traversal Indexing into an array Lesson 18 - Spring 2023 12