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...

  • 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...

  • 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 Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...

    Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...

  • 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...

  • Question 4: CLO5 Write a class called Rectangle that has length and width as instance variables,...

    Question 4: CLO5 Write a class called Rectangle that has length and width as instance variables, a constructor with two parameter to initialize length and width, set and get methods for each variables and the following methods: a. The first method calculates and returns the value of the ratio of the length to the width of the rectangle. b. The second method determines whether a rectangle is a Square depending on the value of the ratio, which should be calculated...

  • Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int....

    Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int. There is also an attribute of the class, points, which does not have a corresponding instance variable. Also note the constructor and methods of the class and what they do. TournamentAdmin class code: public class RankAdmin {    /**     * Constructor for objects of class...

  • Write a Java program to work with a generic list ADT using a fixed size array,...

    Write a Java program to work with a generic list ADT using a fixed size array, not ArrayList. Create the interface ListInterface with the following methods a) add(newEntry): Adds a new entry to the end of the list. b) add(newPosition, newEntry): Adds a new entry to the list at a given position. c) remove(givenPosition): Removes the entry at a given position from the list. d) clear( ): Removes all entries from the list . e) replace(givenPosition, newEntry): Replaces the entry...

  • Hello! I know this has been answered before but I would love a new solution for it. This would be in C++ Create a class...

    Hello! I know this has been answered before but I would love a new solution for it. This would be in C++ Create a class named Building with one public pure virtual function computerEnergyConsumption() that returns a double value of the instance variable which stores the energy consumed by the building. Create the two classes SolarBuilding and WindMill that both publicly inherit from Building. SolarBuilding has an instance variable that stores the energy generated by the solar panels. WindMill has...

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
ADVERTISEMENT