Question: Write a function that removes a String from the StringBag (if it is in the StringBag). It should do this by finding the index where

Write a function that removes a String from the StringBag (if it is in the StringBag). It should do this by finding the index where the String exists, and then overwriting it with the element at the last position. The last element should then be dropped from the bag. If an element is removed, return true, otherwise return false.

Write your test case for this method.

public void testRemove()

// Replace this test with your code

Write your method.

public boolean remove(String item)

{

// Replace this test with your code

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!