Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. Implement Bag , by using a LinkedList, i.e., set up an instance variable of type List , fill it in with a LinkedList at

6. Implement Bag, by using a LinkedList, i.e., set up an instance variable of type List, fill it in with a LinkedListat the time of the Bags creation, and use it to store new elements as they come in. Note that the LinkedList can provide a working iterator, so you dont need a private class for the iterator, or the Node class either. Your iterator from LinkedList will have a working remove(), but thats OK.Write a client program, TestBag, that puts apple, pear, and apple in a Bag, and then counts the apples in the bag. What methods are available on the Bag object in this client program? In your answer, show Bag.java, TestBag.java, and the answer to the question. Also think about how you could implement a proper Stack ADT by similar means (no answer needed).

7. A basic Map has methods size, isEmpty, containsKey,get,put,remove,clear,keySet, and values, 9 methods. The basic ST has 7 methods (not counting the constructor) listed on page 363.(a) Study each Map method in this order, and for each:i. give its method header ii. say which ST method is closest in action, its method header, and whether it is the same or if different, how

(b) Finally, explain what methods dont match up. Explain how to work around any missing actions by use of the provided methods.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

4. How would you deal with the store manager?

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago