Create a class called MyArrayList and implement the methods below, in addition to a main method to test your code. Focus on the special cases. 1. Write a method intersect that accepts two sorted array lists of integers as parameters and returns a new list that contains only the elements that are found in both lists. Example: if lists named list1 and list2 initially store: [1, 4, 8, 9, 11, 15, 17, 28, 41, 59] [4, 7, 11, 17, 19, 20, 23, 28, 37, 59, 81] Then the call of intersect(list1, list2) returns the list: [4, 11, 17, 28, 59]

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

Create a class called MyArrayList and implement the methods below, in addition to a main method to test
your code. Focus on the special cases.
1. Write a method intersect that accepts two sorted array lists of integers as parameters and returns a
new list that contains only the elements that are found in both lists. Example: if lists named list1 and
list2 initially store:
[1, 4, 8, 9, 11, 15, 17, 28, 41, 59]
[4, 7, 11, 17, 19, 20, 23, 28, 37, 59, 81]
Then the call of intersect(list1, list2) returns the list:
[4, 11, 17, 28, 59]
Write a main method to test your code. Focus on the special cases
2. Write a method reverse that reverses the order of the elements in an ArrayList of strings.
3. Write a method capitalizePlurals that accepts an ArrayList of strings and replaces every word ending
with an "s" with its uppercased version.
4. Write a method removePlurals that accepts an ArrayList of strings and removes every word in the list
ending with an "s", case-insensitively.
5. Write a method called scaleByK that takes an ArrayList of integers as a parameter and replaces every
integer of value K with K copies of itself. For example, if the list stores the values (4, 1 , 2, 0 ,3) before
the method is called, it should store the values (4, 4, 4, 4, 1, 2, 2, 3, 3, 3) after the method finishes
executing. Zeroes and negative numbers should be removed from the list by this method

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning