implement Bag ADT for generic objects in two ways: using a resizable array, and using linked nodes.
Fantastic news! We've Found the answer you've been seeking!
Question:
implement Bag ADT for generic objects in two ways: using a resizable array, and using linked nodes. Bag is similar to Set except that duplicates are allowed.
You will be supplied with a basic Junit tester. It is NOT a thorough tester so you should modify it to test thoroughly.
File Names: ArrayBag LinkedBag & The JUnit
Transcribed Image Text:
Highlights of the Bag ADT: Order is unimportant (and unpredictable) Duplicates are allowed We want to be able to: o Add items to the bag o Remove items from the bag (2 ways: remove a specific item, and remove an arbitrary item) Find the number of items stored in the bag (i.e., size) o o Check if an item is in the bag O o o o Count the number of times an item is found in the bag Remove duplicates from the bag Check if the bag contains all the elements that are in another bag (ignoring duplicates) Check if this bag contains exactly the same elements as those in another bag (i.e., anagram) Note: even though order is unimportant in a bag, you should not change the order of the elements except in methods that are supposed to add or remove items. Highlights of the Bag ADT: Order is unimportant (and unpredictable) Duplicates are allowed We want to be able to: o Add items to the bag o Remove items from the bag (2 ways: remove a specific item, and remove an arbitrary item) Find the number of items stored in the bag (i.e., size) o o Check if an item is in the bag O o o o Count the number of times an item is found in the bag Remove duplicates from the bag Check if the bag contains all the elements that are in another bag (ignoring duplicates) Check if this bag contains exactly the same elements as those in another bag (i.e., anagram) Note: even though order is unimportant in a bag, you should not change the order of the elements except in methods that are supposed to add or remove items. Highlights of the Bag ADT: Order is unimportant (and unpredictable) Duplicates are allowed We want to be able to: o Add items to the bag o Remove items from the bag (2 ways: remove a specific item, and remove an arbitrary item) Find the number of items stored in the bag (i.e., size) o o Check if an item is in the bag O o o o Count the number of times an item is found in the bag Remove duplicates from the bag Check if the bag contains all the elements that are in another bag (ignoring duplicates) Check if this bag contains exactly the same elements as those in another bag (i.e., anagram) Note: even though order is unimportant in a bag, you should not change the order of the elements except in methods that are supposed to add or remove items.
Expert Answer:
Answer rating: 100% (QA)
Heres the Java implementation of the ArrayBag class that follows the specified requirements import javautilArrays public class ArrayBag E implements B... View the full answer
Related Book For
Java Software Structures Designing And Using Data Structures
ISBN: 9780133250121
4th Edition
Authors: John Lewis, Joe Chase
Posted Date:
Students also viewed these programming questions
-
Fossil fuels such as oil, natural gas and coal are called non-renewable. Of course, we understand this fact from a physical viewpoint since at some point in time we will run out of those fuels....
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
What is a time series? Explain the four characteristics that time series may exhibit and provide some practical examples.
-
Why do children of depressed parents have difficulty regulating emotion (see page 153 in Chapter 4)? What implications do their weak self-regulatory skills have for their response to cognitive and...
-
1. If the RMT strike had gone ahead, what do you think might have been the result? How would the general public view RMT? How would Network Rail be viewed? 2. Do you think the union was a help or a...
-
Prepayments, Collections in Advance} Genstar Properties Inc. owns a building in which it leases office space to small businesses and professionals. During 2018, Genstar Properties engaged in the...
-
Dinkel Company is considering three long-term capital investment proposals. Each investment has a useful life of 5 years. Relevant data on each project are as follows. Depreciation is computed by the...
-
The common stock and debt of Northern Sludge are valued at $75 million and $25 million, respectively. Investors currently require a return of 16.1% on the common stock and 7.6% on the debt. If...
-
Plan a controlled experiment to investigate how much the temperature of cold sand and cold water change when hot water is added to them. Assume you have access to water, sand, containers, ice, a heat...
-
In light of change theory, if resistant forces are strong and change forces are strong, then what type of organisational change is likely to occur?
-
Transport is becoming increasingly less important, as e-commerce and other developments become widespread. Do you think that this is true?
-
Orientation for a staff auditor includes: a. Explaining the working paper format established by the auditor's organization. b. Providing the auditor with an overview of the company organization. c....
-
What types of technology are used in transport? How do you expect this to change in the future?
-
A modern internal audit staff should preferably include individuals: a. With an earned degree in accounting. b. Who have had previous experience with the organization. c. With a business...
-
One of the major trends in logistics is the move towards contract transport. Why?
-
9 The following transactions were selected from among those completed by Bear's Retail Store: November 20 Sold two itens of merchandise to Cheryl Jahn, who paid the $530 sales price in cash. The...
-
Construct a 4 x 25 design confounded in two blocks of 16 observations each. Outline the analysis of variance for this design.
-
Determine the growth function and order of the following code fragment: for (int count = 0; count < n; count ++) { for (int count2 = 0; count2 < n; count2 = count2 * 2) { System.out.println(count,...
-
Draw the UML description for the PriorityQueue class described in this chapter.
-
Implement an OrderedList using a LinkedList object to store the list elements.
-
Discuss the ethical choices in the situations below. In each instance, describe the ethical dilemma, determine the alternative courses of action, and tell what you would do. 1. You are the payroll...
-
The summer after finishing her junior year in college, Beth Murphy started a lawn service business in her neighborhood. On June 1, she deposited $2,700 in a new bank account in the name of her...
-
H&R Block, Inc. is a well-known income tax services firm. Information for 2004 and 2003 from the companys annual report is presented below.16 (All numbers are in thousands.) Three students who were...
Study smarter with the SolutionInn App