Discussion 5: APTs and More
Groups, Say Hello (10 minutes)
Useful Methods and Classes (15 minutes)
Complete the reflection form found here: D5 Reflect Form. Each of the parts of Discussion below has its own section in the form; you can complete them as you go.
Today, your UTAs will assign you to your pre-assigned breakout rooms from last week. The students in your breakout room will be a more permanent group of peers for you to work with. You will likely work with this group in every discussion and during lecture.
Your TA will give you a link to the Microsoft Teams channel for your group, where you can communicate about the course and work on peer instructions together during lecture. You all already have access to the course Team, so this will just be making sure that you join the correct channel. Make sure those in your discussion group know each other's names and your section UTAs' names.
Read the PairDown APT writeup.
Discuss in your groups the following ideas.
for(int k=0; k < list.length; k += 2) {...
Explain how to index, in terms of k, the two values from list that will be added together and stored in the returned array.
Based on these ideas, what is the group consensus on how long it will take to use these ideas and get an all green solution: D5 Reflect Form.
This part is about the SetAside APT.
Some background information:
Explore in your group this idea: Start with a set common containing the Strings in the first element of the array list. Then loop over each of the other strings in list making common the intersection of itself and each set created from the string.
Answer questions in D5 Reflect Form.
This is about the MaxDonor APT.
This problem was from a previous APT quiz. To start thinking about these quizzes, we'd like you, in your group, to read the problem description on your own for 3-5 minutes and then discuss what questions you have and what high-level ideas you have to solve the problem.
Answer questions in D5 Reflect Form.
See the jshell session below to understand conversion between arrays and ArrayList/List objects. Answer these questions
Answer questions in D5 Reflect Form.
| Welcome to JShell -- Version 10.0.1
| For an introduction type: /help intro
jshell> String[] a = {"zoo", "yak", "ant", "cat"};
a ==> String[4] { "zoo", "yak", "ant", "cat" }
jshell> List<String> list = Arrays.asList(a);
list ==> [zoo, yak, ant, cat]
jshell> String[] b = list.toArray(new String[0])
b ==> String[4] { "zoo", "yak", "ant", "cat" }
jshell> a == b
$4 ==> false
jshell> a.equals(b)
$5 ==> false
jshell> a[0] == b[0]
$6 ==> true
jshell> a[1] == b[1]
$7 ==> true
jshell> a[2] == b[2]
$8 ==> true
jshell> a[3] == b[3]
$9 ==> true
jshell> List<String> list2 = Arrays.asList(b)
list2 ==> [zoo, yak, ant, cat]
jshell> list == list2
$11 ==> false
jshell> list.equals(list2)
$12 ==> true
jshell> int[] a = {1,2,3,4};
a ==> int[4] { 1, 2, 3, 4 }
jshell> List<Integer> xyz = Arrays.asList(a)
| Error:
| incompatible types: inference variable T has incompatible bounds
| equality constraints: java.lang.Integer
| lower bounds: int[]
| List<Integer> xyz = Arrays.asList(a);
| ^--------------^
jshell> ArrayList<Integer> xyz = new ArrayList<>();
xyz ==> []
jshell> for(int i : a) xyz.add(i)
jshell> xyz
xyz ==> [1, 2, 3, 4]
jshell> String[] nums = {"12", "35", "78"}
nums ==> String[3] { "12", "35", "78" }
jshell> int[] anums = new int[nums.length]
anums ==> int[3] { 0, 0, 0 }
jshell> for(int k=0; k < nums.length; k += 1)
...> anums[k] = Integer.parseInt(nums[k])
jshell> anums
anums ==> int[3] { 12, 35, 78 }
jshell> nums
nums ==> String[3] { "12", "35", "78" }
jshell>