(Key) Csa U8l7 Searching and Sorting Extra Practice
(Key) Csa U8l7 Searching and Sorting Extra Practice
return choices;
}
1
Which two code segments can be inserted in for /* missing code 1 */ and /* missing code 2 */ in
order to return a list of menu items that are equal to or below the budget?
AP Exam Prep
Your city is hosting a charity marathon that will occur on two different dates and stores the names of registered
participants in two ArrayLists of String objects called day1Runners and day2Runners. Interested
participants could register for one or both of the dates. When a participant registers, their name is added to
either the day1Runners list, the day2Runners list, or both.
The city wants a new list created containing the names of all unique participants that have registered for either
or both dates of the marathon. Write pseudocode or Java code to merge the two lists into one new list without
any duplicates.
if (!alreadyInList) {
merged.add(s);
}
}
2
Extra Practice
Do This: You have implemented standard algorithms that utilize array traversal to determine if multiple
elements have a particular property. Let's use this algorithm to check a word for the game of Wordle, and
update each character's color property.
Assume the class Letter has already been defined, and is described by this UML diagram:
Letter
- letter: String
- color: String
+ getLetter()
+ getColor()
+ setColor(String color)
Implement updateColor(Letter[] guess, Letter[] goal) which accepts a guess word and a goal word,
then changes the letter property of the goal word based on the following rules:
if (partOfWord) {
guess[i].setColor("Yellow");
}
else {
guess[i].setColor("Gray");
}
}
}
}