Write a complete generic program that implements the adt bag

Assignment Help Programming Languages
Reference no: EM131493021

Assignment
Write a complete generic program that implements the ADT Bag using a singly-linked list. A Bag is just a container for a collection of items (analogy: a bag of candy) with the following behaviors:

- The positions of data items do not matter. For instance, {3, 2, 10, 6} is equivalent to {2, 3, 6, 10}
- There can be duplicate items (e.g., {7, 2, 10, 7, 5})

Your program does not need to write the main() method, but must implement the ADT

Bag class with the following definitions/methods:

• class definitions, constructor, and help methods
• add(item): add item to the Bag (you may insert it at the front/tail - the order of insertions does not matter).
• remove(item): remove one occurrence of item (if any) from the Bag
• contains(item): check if item is in the Bag
• grab(): get an item at random, without removing it, which reflects the fact that the items don't have a position (and thus we can't say "get the 5th item in the Bag")
• size(): return the number of elements in the Bag
• isEmpty0: indicate whether no items are stored in the Bag.

Reference no: EM131493021

Questions Cloud

Company you will analyze for the project : Determine which company you will analyze for the project. Your selection may be subject to your professor's approval.
Social responsibility could be not polluting environment : Should corporate firms be socially responsible? Social responsibility could be like not polluting the environment etc.
Discuss manufacturers of care such as hospitals : HSHA 433:Discuss manufacturers, distributors and providers of care such as hospitals, health systems, and physician offices.
Describe a strategy using pseudo code : A timing circuit is needed that can generate a time delay longer than counter clock cycles of the timer/counter comparison circuit shown in Figure.
Write a complete generic program that implements the adt bag : Write a complete generic program that implements the ADT Bag using a singly-linked list. A Bag is just a container for a collection of items.
What is the cash flow to stockholders-cash flow to creditors : What is the 2009 operating cash flow? What is the 2009 cash flow to creditors? What is the 2009 cash flow to stockholders?
What is a pending interrupt : Why, in most processors with interrupts. are further interrupts disabled when the processor reaches the interrupt service routine?
What is net income for firm : Papa Roach Exterminators, Inc., has sales of $554,000, costs of $265,000, depreciation expense of $46,000, What is the net income for firm?
What are vectored interrupts : Which type of interrupt. vectored or polled. requires hardware for priority resolution?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd