
Winter 2024 Array Patterns Lesson with Announcements and Coding Exercises
Explore the Winter 2024 CSE 121 Lesson 17 on Array Patterns featuring announcements, reminders, and coding exercises like counting elements, modifying arrays, and shifting elements. Join the array exploration journey and stay updated on important dates and events in the programming realm.
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 17: Array Patterns Elba Garza & Matt Wang Winter 2024 Abby Aishah Anju Annie Archit Ayesha Christian TAs: Hannah Heather Hibbah Jacob James Janvi Jasmine Jonus Julia Lucas Luke Maria Nicole Shananda Shayna Trey Vidhi Vivian sli.do #CSE121-17 Today s playlist: CSE 121 24wi lecture beats :D
Announcements & Reminders P3 due Thursday March 7that 11:59pm Fun news: for R7, any assignment can be resubmitted Gigi (& friends) Visit on Monday, March 11th 1:00pm-3:00pm Final Exam: Tuesday, March 12th 12:30pm-2:20pm Left-Handed Seating Requests Form, closes end-of-day Monday, March 4th TA-led Final Review Session on Monday, March 11th, 4:30-6:50 at SMI 120 Next week: focus on hand-writing! Lesson 17 - Winter 2024 2
(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 17 - Winter 2024 3
(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 17 - Winter 2024 4
(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 17 - Winter 2024 5
(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 17 - Winter 2024 6
(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 17 - Winter 2024 7
(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 17 - Winter 2024 8
(PCM) Common Ideas in Array Patterns Loop bounds Direction of traversal Indexing into an array Lesson 17 - Winter 2024 9
(PCM) Your Questions on Arrays! (1/3) When do we use quick initialization and when do we not or does it not matter? What is a simple(r) way of deciding what pattern to utilize to perform certain functions? how would I switch every third element in an array? Lesson 17 - Winter 2024 10
(PCM) Your Questions on Arrays! (2/3) How do you interact with an array that has a lot of elements in it quickly? Why do arrays have a completely different syntax (requiring java.util.*) in comparison to other data types? Is it just because they're more simple? Lesson 17 - Winter 2024 11
(PCM) Your Questions on Arrays! (2/3) In a real computer science job, how likely is it you would have something like an array of arrays where each array is an array of arrays? Lesson 17 - Winter 2024 12