Question: Please answer . Based on the header file for the class Array Bag below, which of the following is/are A data field of the ADT
Please answer .
Based on the header file for the class Array Bag below, which of the following is/are
A data field of the ADT data structure (as opposed to the interface)?
(select all that apply)
#ifndef _ARRAY_BAG #define _ARRAY_BAG #include "BagInterface.h" using namespace std; templateclass ArrayBag : public BagInterface { private: static const int DEFAULT_CAPACITY = 6; ItemType items[DEFAULT_CAPACITY]; int itemCount; int maxItems; int getIndexOf(const ItemType& target) const; public: ArrayBag(); int getCurrentSize() const; bool isEmpty() const; bool add(const ItemType& anEntry); bool remove(const ItemType& newEntry); void clear(); bool contains(const ItemType& anEntry) const; int getFrequencyOf(const ItemType& anEntry) const; vector toVector() const; }; #include "ArrayBag.cpp" #endif
eof
| DEFAULT_CAPACITY |
| items |
| itemCount |
| maxItems |
| getIndexOf |
| getCurrentSize |
| isEmpty |
| add |
| remove |
| clear |
| contains |
| getFrequencyOf |
Based on the textbook's implementation of the ArrayBag remove method (below), which of the following are steps of a successful remove function (the remove function returns True)? (Select all that apply).
templatebool ArrayBag ::remove(const ItemType& anEntry) { int locatedIndex = getIndexOf(anEntry); bool canRemoveItem = !isEmpty() && (locatedIndex > -1); if (canRemoveItem) { itemCount-; items[locatedIndex] = items[itemCount]; } // end if return canRemoveItem; } // end remove
eof
| Swap the anEntry value with the LAST value in the array. |
| Swap the anEntry value with the FIRST value in the array. |
| Overwrite the anEntry value in the array with the LAST value in the array. |
| Overwrite the anEntry value in the array with the FIRST value in the array. |
| Decrement the current count of bag items. |
| Increment the start position of the array. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
