Question

An instance of the class ArrayBag has a fixed size, whereas an instance of ResizableArrayBag does...

An instance of the class ArrayBag has a fixed size, whereas an instance of ResizableArrayBag does not. Discuss and give at least two examples of situations where a bag would be appropriate if its size is: a. Fixed; b. Resizable.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A) Fixed size: array.

Because arrays are fixed in size.

Once we create an array, there is no chance of increasing or decreasing size based on our requirement. Hence to use the arrays concept compulsory we should know the size in advance.

  • Arrays can hold only homogeneous data.
  • Arrays concept not built on some datastructure.i.e, there is no underlying datastructure for arrays.

B) Resizable : Any collection class.

We use collections concept here.

Because collections are growable in nature.

  • Collections can hold homogenous as well as heterogenous data.
  • Every collection class is implemented using a datstructure. Method support is there for any collection class

Some collection classes:

ArrayList,

LinkedList

Vector etc.,

Thanks...

Add a comment
Know the answer?
Add Answer to:
An instance of the class ArrayBag has a fixed size, whereas an instance of ResizableArrayBag does...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • / Animal.hpp #ifndef ANIMAL_H_ #define ANIMAL_H_ #include <string> class Animal { public: Animal(); Animal(std::string, bool domestic=false,...

    / Animal.hpp #ifndef ANIMAL_H_ #define ANIMAL_H_ #include <string> class Animal { public: Animal(); Animal(std::string, bool domestic=false, bool predator=false); std::string getName() const; bool isDomestic() const; bool isPredator() const; void setName(std::string); void setDomestic(); void setPredator(); protected: // protected so that derived class can directly access them std::string name_; bool domestic_; bool predator_; }; #endif /* ANIMAL_H_ */ //end of Animal.h // /////////////////////////////////////////////////////////////////Animal.cpp #include "Animal.h" Animal::Animal(): name_(""),domestic_(false), predator_(false){ } Animal::Animal(std::string name, bool domestic, bool predator): name_(name),domestic_(domestic), predator_(predator) { } std::string Animal::getName() const{ return...

  • Java Write an intersection method for the ResizableArrayBag class. The intersection of two bags is the...

    Java Write an intersection method for the ResizableArrayBag class. The intersection of two bags is the overlapping content of the bags. Intersections are explained in more detail in Chapter 1, #6. An intersecion might contain duplicates. The method should not alter either bag. The current bag and the bag sent in as a parameter should be the same when the method ends. The method header is: public BagInterface<T> intersection(ResizableArrayBag <T> anotherBag) Example: bag1 contains (1, 2, 2, 3) bag2 contains...

  • postings and post a response to at least two class 1. Why is it necessary to...

    postings and post a response to at least two class 1. Why is it necessary to study both service successes and failures? Discuss in detail and provide examples. 2. What is the moment of truth impact analysis? Discuss in detail and provide examples. 3. What does it mean when a service organization "invents" its future? Discuss in detail and provide examples. Discussion Response Guid

  • 1 An instance variable refers to a data value that a is owned by an particular...

    1 An instance variable refers to a data value that a is owned by an particular instance of a class and no other b is shared in common and can be accessed by all instances of a given class 2 The name used to refer the current instance of a class within the class definition is a this b other c self 3 The purpose of the __init__ method in a class definition is to a build and return a...

  • Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of...

    Create Student class•Change header so that Student extends Person•A Student has-an additional instance variable, major of type String.•Add the instance variable, its getters and setters. •Add a toString method to the Student class. It should reuse the toString method of Person. •Add two constructors: –No args–Constructor that receives the student’s name, birth year and Major as parameters•Create a class TestInheritance3–Create 2 Student objects–Create an Instructor object–Print the information about the two students and the instructor using the getters of Person,...

  • Draw a UML class diagram that describes the following things. Use the standard UML stereotypes where...

    Draw a UML class diagram that describes the following things. Use the standard UML stereotypes where appropriate. Show visibility, but do not show method signatures, attribute types, constructors, or destructors. Where appropriate distinguish between class and instance attributes and between class and instance methods. (Assume that all are instance attributes/methods unless otherwise indicated.) When an attribute is not another class in the diagram, show it inside the appropriate compartment. Otherwise show it as an aggregation relationship, with the appropriate role...

  • In java code: Write a Temperature class that has two private instance variables: • degrees: a...

    In java code: Write a Temperature class that has two private instance variables: • degrees: a double that holds the temperature value • scale: a character either ‘C’ for Celsius or ‘F’ for Fahrenheit (either in uppercase or lowercase) The class should have (1) four constructor methods: one for each instance variable (assume zero degrees if no value is specified and assume Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument...

  • Java Write a Temperature class that has two private instance variables: • degrees: a double that...

    Java Write a Temperature class that has two private instance variables: • degrees: a double that holds the temperature value • scale: a character either ‘C’ for Celsius or ‘F’ for Fahrenheit (either in uppercase or lowercase) The class should have - four constructor methods: one for each instance variable (assume zero degrees if no value is specified and assume Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument constructor (set...

  • 1- Create the base class Book that has the following instance variables, constructor, and methods title...

    1- Create the base class Book that has the following instance variables, constructor, and methods title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method // that return sting representation of Book object. 2- Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title ( String) isbn...

  • Part C. The following dataset has 6 instances where each instance has two attributes al and...

    Part C. The following dataset has 6 instances where each instance has two attributes al and a2 and a label x, o, or +: pl: (0,1,x) p2: (1,1, x) p3: (1,2,0) p4: (2,2,0) p5: (2, 3, +) p6: (3, 2, +) Cl. If the city block distance is used along with INN classi- fication, then what would be the class of a new point pnew: (2.4,3) (a) + c) x (b) o d) no decision can be made C2. If...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT